diff --git a/.travis.yml b/.travis.yml index a8bc7c6..179f2c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,24 +9,25 @@ env: global: - ROLE_NAME: k3s matrix: - - MOLECULE_DISTRO: centos8 - - MOLECULE_DISTRO: centos7 - - MOLECULE_DISTRO: debian10 - - MOLECULE_DISTRO: fedora29 - - MOLECULE_DISTRO: fedora30 - - MOLECULE_DISTRO: fedora31 - - MOLECULE_DISTRO: amazonlinux2 + - MOLECULE_DISTRO: geerlingguy/docker-centos8-ansible:latest + - MOLECULE_DISTRO: geerlingguy/docker-centos7-ansible:latest + - MOLECULE_DISTRO: geerlingguy/docker-debian10-ansible:latest + - MOLECULE_DISTRO: geerlingguy/docker-ubuntu1804-ansible:latest + - MOLECULE_DISTRO: geerlingguy/docker-fedora29-ansible:latest + - MOLECULE_DISTRO: geerlingguy/docker-fedora30-ansible:latest + - MOLECULE_DISTRO: geerlingguy/docker-fedora31-ansible:latest + - MOLECULE_DISTRO: geerlingguy/docker-amazonlinux2-ansible:latest # Test installing docker - - MOLECULE_DISTRO: centos7 + - MOLECULE_DISTRO: geerlingguy/docker-centos7-ansible:latest MOLECULE_PLAYBOOK: playbook-docker.yml # Test using alternate port and using wireguard as the flannel backend - - MOLECULE_DISTRO: debian10 + - MOLECULE_DISTRO: geerlingguy/docker-fedora30-ansible:latest MOLECULE_PLAYBOOK: playbook-docker-altport-wireguard.yml # Test disabling all deployments - - MOLECULE_DISTRO: fedora31 + - MOLECULE_DISTRO: geerlingguy/docker-fedora31-ansible:latest MOLECULE_PLAYBOOK: playbook-no-deploy.yml install: diff --git a/README.md b/README.md index 9e2cbdf..33a4e02 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ Kubernetes") as either a standalone server or cluster. ## Requirements +The control host requires the following Python dependencies: + + - `jmespath >= 0.9.0` + This role has been tested on Ansible 2.6.0+ against the following Linux Distributions: - Amazon Linux 2 diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 8874dac..33606bc 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -8,30 +8,30 @@ lint: name: yamllint platforms: - name: node1 - image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest" + image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}" command: ${MOLECULE_DOCKER_COMMAND:-""} volumes: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: true - pre_build_image: true + pre_build_image: ${MOLECULE_PREBUILT:-true} networks: - name: k3snet - name: node2 - image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest" + image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}" command: ${MOLECULE_DOCKER_COMMAND:-""} volumes: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: true - pre_build_image: true + pre_build_image: ${MOLECULE_PREBUILT:-true} networks: - name: k3snet - name: node3 - image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest" + image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}" command: ${MOLECULE_DOCKER_COMMAND:-""} volumes: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: true - pre_build_image: true + pre_build_image: ${MOLECULE_PREBUILT:-true} networks: - name: k3snet provisioner: diff --git a/tasks/install-docker-amazon.yml b/tasks/install-docker-amazon.yml deleted file mode 100644 index cd24d37..0000000 --- a/tasks/install-docker-amazon.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Ensure docker is installed using amazon-linux-extras - command: amazon-linux-extras install docker - args: - creates: /etc/docker - notify: - - restart docker - -- meta: flush_handlers diff --git a/tasks/install-docker-opensuse-leap.yml b/tasks/install-docker-opensuse-leap.yml new file mode 100644 index 0000000..536c338 --- /dev/null +++ b/tasks/install-docker-opensuse-leap.yml @@ -0,0 +1,10 @@ +--- + +- name: Ensure docker is installed using Zypper + zypper: + name: docker + state: present + notify: + - restart docker + +- meta: flush_handlers diff --git a/tasks/install-docker-prerequisites-redhat.yml b/tasks/install-docker-prerequisites-redhat.yml index 1089394..bb7c648 100644 --- a/tasks/install-docker-prerequisites-redhat.yml +++ b/tasks/install-docker-prerequisites-redhat.yml @@ -12,6 +12,13 @@ retries: 3 delay: 10 +- name: Check to see if Docker repository is available for this distribution + uri: + url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/{{ ansible_distribution_major_version }}" + register: k3s_redhat_repo_check + failed_when: false + changed_when: false + - name: Ensure Docker repository is installed and configured yum_repository: name: docker-ce @@ -22,3 +29,11 @@ gpgcheck: true state: present when: ansible_distribution | lower not in ['amazon'] + and k3s_redhat_repo_check.status == 200 + +- name: Ensure Docker repository is installed and configured from file + command: yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo + args: + creates: /etc/yum.repos.d/docker-ce.repo + when: ansible_distribution | lower not in ['amazon'] + and k3s_redhat_repo_check.status != 200 diff --git a/tasks/install-docker-prerequisites-suse.yml b/tasks/install-docker-prerequisites-suse.yml new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/tasks/install-docker-prerequisites-suse.yml @@ -0,0 +1 @@ +--- diff --git a/tasks/install-docker-suse.yml b/tasks/install-docker-suse.yml new file mode 100644 index 0000000..536c338 --- /dev/null +++ b/tasks/install-docker-suse.yml @@ -0,0 +1,10 @@ +--- + +- name: Ensure docker is installed using Zypper + zypper: + name: docker + state: present + notify: + - restart docker + +- meta: flush_handlers diff --git a/tasks/main.yml b/tasks/main.yml index c7dbedf..4135545 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,10 +11,10 @@ when: k3s_use_docker and ((k3s_control_workers) or (not k3s_control_workers and not k3s_control_node)) - and ansible_distribution | lower not in ['amazon'] + and ansible_distribution | replace(" ", "-") | lower not in ['amazon', 'suse', 'opensuse-leap'] -- include_tasks: install-docker-{{ ansible_distribution | lower }}.yml - when: ansible_distribution | lower in ['amazon'] +- include_tasks: install-docker-{{ ansible_distribution | replace(" ", "-") | lower }}.yml + when: ansible_distribution | replace(" ", "-") | lower in ['amazon', 'suse', 'opensuse-leap'] - import_tasks: get-version.yml when: k3s_release_version is not defined or not k3s_release_version