diff options
Diffstat (limited to 'ansible/roles/chartmuseum/molecule')
5 files changed, 25 insertions, 39 deletions
diff --git a/ansible/roles/chartmuseum/molecule/default/Dockerfile.j2 b/ansible/roles/chartmuseum/molecule/default/Dockerfile.j2 deleted file mode 100644 index e6aa95d3..00000000 --- a/ansible/roles/chartmuseum/molecule/default/Dockerfile.j2 +++ /dev/null @@ -1,14 +0,0 @@ -# Molecule managed - -{% if item.registry is defined %} -FROM {{ item.registry.url }}/{{ item.image }} -{% else %} -FROM {{ item.image }} -{% endif %} - -RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ - elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \ - elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ - elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ - elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ - elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi diff --git a/ansible/roles/chartmuseum/molecule/default/molecule.yml b/ansible/roles/chartmuseum/molecule/default/molecule.yml index 07652b7a..9c5d1c2a 100644 --- a/ansible/roles/chartmuseum/molecule/default/molecule.yml +++ b/ansible/roles/chartmuseum/molecule/default/molecule.yml @@ -7,7 +7,12 @@ lint: name: yamllint platforms: - name: instance-chartmuseum - image: centos:7 + image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6} + pre_build_image: True + privileged: true + override_command: False + volumes: + - /var/lib/docker groups: - infrastructure provisioner: @@ -18,13 +23,8 @@ provisioner: ANSIBLE_ROLES_PATH: ../../../../test/roles ANSIBLE_LIBRARY: ../../../../library inventory: - group_vars: - all: - app_name: moleculetestapp - app_data_path: "/opt/{{ app_name }}" - helm_bin_dir: /usr/local/bin - chartmuseum_storage_dir: "/opt/{{ app_name }}/chartmuseum" - chartmuseum_port: "1234" + links: + group_vars: ../../../../group_vars scenario: name: default verifier: diff --git a/ansible/roles/chartmuseum/molecule/default/prepare.yml b/ansible/roles/chartmuseum/molecule/default/prepare.yml index 5201bcec..dee6a976 100644 --- a/ansible/roles/chartmuseum/molecule/default/prepare.yml +++ b/ansible/roles/chartmuseum/molecule/default/prepare.yml @@ -1,5 +1,8 @@ --- - name: Prepare infra hosts: infrastructure + vars_files: + - ../../../../roles/chartmuseum/defaults/main.yml roles: + - prepare-docker-dind - prepare-chartmuseum diff --git a/ansible/roles/chartmuseum/molecule/default/tests/test_default.py b/ansible/roles/chartmuseum/molecule/default/tests/test_default.py index 71d1978d..40773065 100644 --- a/ansible/roles/chartmuseum/molecule/default/tests/test_default.py +++ b/ansible/roles/chartmuseum/molecule/default/tests/test_default.py @@ -6,11 +6,9 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') -def test_chartmuseum(host): - ansible_vars = host.ansible.get_variables() - p = host.process.get(comm="chartmuseum") - assert 'chartmuseum --storage local --storage-local-rootdir /opt/' +\ - ansible_vars['app_name'] + '/chartmuseum -port ' +\ - ansible_vars['chartmuseum_port'] in p.args - assert host.file("/opt/" + ansible_vars['app_name'] + - "/chartmuseum").is_directory +def test_chartmuseum_dir(host): + assert host.file("/chartmuseum").is_directory + + +def test_container_running(host): + assert host.docker('chartmuseum').is_running diff --git a/ansible/roles/chartmuseum/molecule/ubuntu/molecule.yml b/ansible/roles/chartmuseum/molecule/ubuntu/molecule.yml index d2851ccf..5f351a93 100644 --- a/ansible/roles/chartmuseum/molecule/ubuntu/molecule.yml +++ b/ansible/roles/chartmuseum/molecule/ubuntu/molecule.yml @@ -7,8 +7,12 @@ lint: name: yamllint platforms: - name: instance-ubuntu-chartmuseum - image: ubuntu:18.04 - dockerfile: ../default/Dockerfile.j2 + image: molecule-${PREBUILD_PLATFORM_DISTRO:-ubuntu}:${PREBUILD_DISTRO_VERSION:-18.04} + pre_build_image: True + privileged: true + override_command: False + volumes: + - /var/lib/docker groups: - infrastructure provisioner: @@ -19,13 +23,8 @@ provisioner: ANSIBLE_ROLES_PATH: ../../../../test/roles ANSIBLE_LIBRARY: ../../../../library inventory: - group_vars: - all: - app_name: moleculetestapp - app_data_path: "/opt/{{ app_name }}" - helm_bin_dir: /usr/local/bin - chartmuseum_storage_dir: "/opt/{{ app_name }}/chartmuseum" - chartmuseum_port: "1234" + links: + group_vars: ../../../../group_vars playbooks: prepare: ../default/prepare.yml converge: ../default/playbook.yml |