diff options
author | 2021-02-12 14:03:54 +0100 | |
---|---|---|
committer | 2021-02-12 14:19:43 +0100 | |
commit | d6908ed39dd5e58c539c1c818f371849dd0271eb (patch) | |
tree | 9a3453740a2acc4a980ec1893ece3d5f9eefcaaf /ansible/roles/chartmuseum/molecule/default | |
parent | 8fdadad54aa08b6c585549b74d1a8323eb751691 (diff) |
Run chartmuseum as a docker container
A docker container for chartmuseum is run with chart
storage volume mounted from hosts' resource dir for chart
repo persistence across container/infra restarts.
Change-Id: I692ff7a3d95414b439b15b5414bc8b959eb79414
Issue-ID: OOM-2665
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'ansible/roles/chartmuseum/molecule/default')
4 files changed, 17 insertions, 30 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 |