diff --git a/roles/container-engine/containerd/molecule/default/molecule.yml b/roles/container-engine/containerd/molecule/default/molecule.yml new file mode 100644 index 000000000..a6bb80e9c --- /dev/null +++ b/roles/container-engine/containerd/molecule/default/molecule.yml @@ -0,0 +1,31 @@ +--- +driver: + name: vagrant + provider: + name: libvirt +lint: + name: yamllint + options: + config-file: ../../../.yamllint +platforms: + - name: ubuntu18 + box: generic/ubuntu1804 + cpus: 2 + memory: 1024 + groups: + - kube-master +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../ + config_options: + defaults: + callback_whitelist: profile_tasks + lint: + name: ansible-lint + options: + c: ../../../.ansible-lint +verifier: + name: testinfra + lint: + name: flake8 diff --git a/roles/container-engine/containerd/molecule/default/playbook.yml b/roles/container-engine/containerd/molecule/default/playbook.yml new file mode 100644 index 000000000..b70dabf89 --- /dev/null +++ b/roles/container-engine/containerd/molecule/default/playbook.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + become: true + roles: + - role: kubespray-defaults + - role: containerd diff --git a/roles/container-engine/containerd/molecule/default/prepare.yml b/roles/container-engine/containerd/molecule/default/prepare.yml new file mode 100644 index 000000000..1afc51a04 --- /dev/null +++ b/roles/container-engine/containerd/molecule/default/prepare.yml @@ -0,0 +1,6 @@ +--- +- name: Prepare + hosts: all + gather_facts: False + roles: + - role: bootstrap-os diff --git a/roles/container-engine/containerd/molecule/default/tests/test_default.py b/roles/container-engine/containerd/molecule/default/tests/test_default.py new file mode 100644 index 000000000..523408be6 --- /dev/null +++ b/roles/container-engine/containerd/molecule/default/tests/test_default.py @@ -0,0 +1,21 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_service(host): + svc = host.service("containerd") + assert svc.is_running + assert svc.is_enabled + + +def test_run(host): + crictl = "/usr/local/bin/crictl" + path = "unix:///var/run/containerd/containerd.sock" + with host.sudo(): + cmd = host.command(crictl + " --runtime-endpoint " + path + " version") + assert cmd.rc == 0 + assert "RuntimeName: containerd" in cmd.stdout diff --git a/roles/container-engine/containerd/tasks/crictl.yml b/roles/container-engine/containerd/tasks/crictl.yml index 60a9c91aa..0e0459508 100644 --- a/roles/container-engine/containerd/tasks/crictl.yml +++ b/roles/container-engine/containerd/tasks/crictl.yml @@ -21,7 +21,13 @@ group: no delegate_to: "{{ inventory_hostname }}" +- name: Get crictl completion + shell: "{{ bin_dir }}/crictl completion" + changed_when: False + register: cri_completion + - name: Install crictl completion - shell: "{{ bin_dir }}/crictl completion >/etc/bash_completion.d/crictl" - ignore_errors: True - when: ansible_distribution in ["CentOS","RedHat", "Ubuntu", "Debian"] + copy: + dest: /etc/bash_completion.d/crictl + content: "{{ cri_completion.stdout }}" + become: True \ No newline at end of file