diff options
author | Jan Benedikt <j.benedikt@partner.samsung.com> | 2020-02-10 16:29:43 +0100 |
---|---|---|
committer | Jan Benedikt <j.benedikt@partner.samsung.com> | 2020-05-18 09:21:52 +0200 |
commit | 2c34d1d7a33e34c9984ac78460fd8e7c815024c5 (patch) | |
tree | 1bac4c90b3d8f899248919f97af24f4fe31547e8 /ansible/roles/package-repository/molecule | |
parent | 17e0a5eacaed7519f13e2c0f19749fb4263fb46a (diff) |
Adding Ubuntu support in Ansible - package-repository role
Extending ansible playbooks of ubuntu support.
Creating new test with Ubuntu image for Molecule in package-repository role.
Issue-ID: OOM-1671
Signed-off-by: Jan Benedikt <j.benedikt@partner.samsung.com>
Change-Id: I85d4e6857536fa06c7eb4f4042c1ed64fcbf903e
Diffstat (limited to 'ansible/roles/package-repository/molecule')
5 files changed, 75 insertions, 9 deletions
diff --git a/ansible/roles/package-repository/molecule/default/Dockerfile.j2 b/ansible/roles/package-repository/molecule/default/Dockerfile.j2 index 0a605536..b76a6dd7 100644 --- a/ansible/roles/package-repository/molecule/default/Dockerfile.j2 +++ b/ansible/roles/package-repository/molecule/default/Dockerfile.j2 @@ -6,9 +6,12 @@ FROM {{ item.registry.url }}/{{ item.image }} 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; \ +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y sudo bash ca-certificates python3-apt && apt-get clean; \ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-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 + +# Create symlink python3 -> python +RUN if [ $(command -v apt-get) ]; then ln -s /usr/bin/python3 /usr/bin/python; fi diff --git a/ansible/roles/package-repository/molecule/default/molecule.yml b/ansible/roles/package-repository/molecule/default/molecule.yml index df2024d7..7abb08d4 100644 --- a/ansible/roles/package-repository/molecule/default/molecule.yml +++ b/ansible/roles/package-repository/molecule/default/molecule.yml @@ -36,8 +36,6 @@ provisioner: all: app_name: moleculetestapp app_data_path: "/opt/{{ app_name }}" -scenario: - name: default verifier: name: testinfra options: diff --git a/ansible/roles/package-repository/molecule/default/tests/test_infrastructure-server.py b/ansible/roles/package-repository/molecule/default/tests/test_infrastructure-server.py index 9fb1a4f9..5b3fce4d 100644 --- a/ansible/roles/package-repository/molecule/default/tests/test_infrastructure-server.py +++ b/ansible/roles/package-repository/molecule/default/tests/test_infrastructure-server.py @@ -7,10 +7,17 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( def test_onap_repo(host): - fc = host.file('/etc/yum.repos.d/moleculetestapp.repo').content_string - expected_content = """[moleculetestapp] + os = host.system_info.distribution + if os == "centos": + fc = host.file('/etc/yum.repos.d/moleculetestapp.repo').content_string + expected_content = """[moleculetestapp] baseurl = file:///opt/moleculetestapp/pkg/rpm enabled = 1 gpgcheck = 0 name = MOLECULETESTAPP offline repository""" - assert fc == expected_content + assert fc == expected_content + elif os == "ubuntu": + fc = host.file('/etc/apt/sources.list.d/moleculetestapp.list') + fc = fc.content_string + ec = "deb [trusted=yes] file:///opt/moleculetestapp/pkg/deb ./" + assert fc == ec diff --git a/ansible/roles/package-repository/molecule/default/tests/test_kubernetes-node-1.py b/ansible/roles/package-repository/molecule/default/tests/test_kubernetes-node-1.py index fda85e8d..c1831f70 100644 --- a/ansible/roles/package-repository/molecule/default/tests/test_kubernetes-node-1.py +++ b/ansible/roles/package-repository/molecule/default/tests/test_kubernetes-node-1.py @@ -7,10 +7,17 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( def test_onap_repo(host): - fc = host.file('/etc/yum.repos.d/moleculetestapp.repo').content_string - expected_content = """[moleculetestapp] + os = host.system_info.distribution + if os == "centos": + fc = host.file('/etc/yum.repos.d/moleculetestapp.repo').content_string + expected_content = """[moleculetestapp] baseurl = http://repo.infra-server/rpm enabled = 1 gpgcheck = 0 name = MOLECULETESTAPP offline repository""" - assert fc == expected_content + assert fc == expected_content + elif os == "ubuntu": + fc = host.file('/etc/apt/sources.list.d/moleculetestapp.list') + fc = fc.content_string + ec = "deb [trusted=yes] http://repo.infra-server/deb ./" + assert fc == ec diff --git a/ansible/roles/package-repository/molecule/ubuntu/molecule.yml b/ansible/roles/package-repository/molecule/ubuntu/molecule.yml new file mode 100644 index 00000000..07c2d888 --- /dev/null +++ b/ansible/roles/package-repository/molecule/ubuntu/molecule.yml @@ -0,0 +1,51 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: infrastructure-server + image: ${PLATFORM_DISTRO:-ubuntu}:${ISTRO_VERSION:-18.04} + dockerfile: ../default/Dockerfile.j2 + groups: + - infrastructure + # By design certain file like /etc/resolv.conf cannot be edited in docker + # container. To enable role to "edit" /etc/resolv.conf define value already to same. + dns_servers: + - 6.5.4.3 + + - name: kubernetes-node-1 + image: ${PLATFORM_DISTRO:-ubuntu}:${ISTRO_VERSION:-18.04} + dockerfile: ../default/Dockerfile.j2 + groups: + - kubernetes + # By design certain file like /etc/resolv.conf cannot be edited in docker + # container. To enable role to "edit" /etc/resolv.conf define value already to same. + dns_servers: + - 6.5.4.3 + +provisioner: + name: ansible + lint: + name: ansible-lint + playbooks: + converge: ../default/playbook.yml + inventory: + host_vars: + infrastructure-server: + cluster_ip: 6.5.4.3 + group_vars: + all: + app_name: moleculetestapp + app_data_path: "/opt/{{ app_name }}" +scenario: + name: ubuntu +verifier: + name: testinfra + options: + verbose: true + lint: + name: flake8 + directory: ../default/tests |