From 8e67d654bf1773091d647b11d36dc996a6d840f7 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Wed, 26 Jun 2019 07:47:17 -0500 Subject: [PATCH] Add legacy variable scenario tests This change adds scenario tests for legacy variables across all roles which use derived variables from legacy, un-namespaced, options. Task: 34742 Story: 2006049 Related-Bug: #1834283 Change-Id: I18b6be271331e59ff66741a958b27d7f044f42ab Signed-off-by: Kevin Carter --- tox.ini | 42 ++++++++++++ .../molecule/legacy_vars/molecule.yml | 48 +++++++++++++ .../molecule/legacy_vars/playbook.yml | 26 +++++++ .../molecule/legacy_vars/prepare.yml | 41 +++++++++++ .../molecule/legacy_vars/molecule.yml | 48 +++++++++++++ .../molecule/legacy_vars/playbook.yml | 30 ++++++++ .../molecule/legacy_vars/prepare.yml | 32 +++++++++ .../tripleo-container-tag/tasks/main.yml | 2 +- .../molecule/legacy_vars/Dockerfile | 36 ++++++++++ .../molecule/legacy_vars/molecule.yml | 68 +++++++++++++++++++ .../molecule/legacy_vars/playbook.yml | 24 +++++++ .../molecule/legacy_vars/prepare.yml | 21 ++++++ .../legacy_vars/tests/test_default.py | 43 ++++++++++++ .../molecule/legacy_vars/verify.yml | 15 ++++ .../molecule/legacy_vars/Dockerfile | 37 ++++++++++ .../molecule/legacy_vars/molecule.yml | 68 +++++++++++++++++++ .../molecule/legacy_vars/playbook.yml | 23 +++++++ .../molecule/legacy_vars/prepare.yml | 26 +++++++ .../molecule/legacy_vars/verify.yml | 15 ++++ .../molecule/legacy_vars/Dockerfile | 37 ++++++++++ .../molecule/legacy_vars/molecule.yml | 62 +++++++++++++++++ .../molecule/legacy_vars/playbook.yml | 22 ++++++ .../molecule/legacy_vars/prepare.yml | 26 +++++++ .../legacy_vars/tests/test_default.py | 28 ++++++++ .../molecule/legacy_vars/verify.yml | 15 ++++ zuul.d/molecule.yaml | 1 + 26 files changed, 835 insertions(+), 1 deletion(-) create mode 100644 tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/molecule.yml create mode 100644 tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/playbook.yml create mode 100644 tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/prepare.yml create mode 100644 tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/molecule.yml create mode 100644 tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/playbook.yml create mode 100644 tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/prepare.yml create mode 100644 tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/Dockerfile create mode 100644 tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/molecule.yml create mode 100644 tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/playbook.yml create mode 100644 tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/prepare.yml create mode 100644 tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/tests/test_default.py create mode 100644 tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/verify.yml create mode 100644 tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/Dockerfile create mode 100644 tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/molecule.yml create mode 100644 tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/playbook.yml create mode 100644 tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/prepare.yml create mode 100644 tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/verify.yml create mode 100644 tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/Dockerfile create mode 100644 tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/molecule.yml create mode 100644 tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/playbook.yml create mode 100644 tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/prepare.yml create mode 100644 tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/tests/test_default.py create mode 100644 tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/verify.yml diff --git a/tox.ini b/tox.ini index 21060d7f3..9643e16d1 100644 --- a/tox.ini +++ b/tox.ini @@ -222,12 +222,30 @@ deps = {[testenv:mol]deps} changedir = {toxinidir}/tripleo_ansible/roles/tripleo-module-load commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=remove_module +[testenv:mol-tripleo-module-load-legacy_vars] +basepython = {[testenv:mol]basepython} +deps = {[testenv:mol]deps} +changedir = {toxinidir}/tripleo_ansible/roles/tripleo-module-load +commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars + [testenv:mol-tripleo-ssh-known-hosts] basepython = {[testenv:mol]basepython} deps = {[testenv:mol]deps} changedir = {toxinidir}/tripleo_ansible/roles/tripleo-ssh-known-hosts commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py +[testenv:mol-tripleo-ssh-known-hosts-default] +basepython = {[testenv:mol]basepython} +deps = {[testenv:mol]deps} +changedir = {toxinidir}/tripleo_ansible/roles/tripleo-ssh-known-hosts +commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default + +[testenv:mol-tripleo-ssh-known-hosts-legacy_vars] +basepython = {[testenv:mol]basepython} +deps = {[testenv:mol]deps} +changedir = {toxinidir}/tripleo_ansible/roles/tripleo-ssh-known-hosts +commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars + [testenv:mol-tripleo-container-tag] basepython = {[testenv:mol]basepython} deps = {[testenv:mol]deps} @@ -246,6 +264,12 @@ deps = {[testenv:mol]deps} changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-tag commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=podman +[testenv:mol-tripleo-container-tag-legacy_vars] +basepython = {[testenv:mol]basepython} +deps = {[testenv:mol]deps} +changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-tag +commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars + [testenv:mol-tripleo-container-rm] basepython = {[testenv:mol]basepython} deps = {[testenv:mol]deps} @@ -270,12 +294,30 @@ deps = {[testenv:mol]deps} changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=docker_rm +[testenv:mol-tripleo-container-rm-legacy_vars] +basepython = {[testenv:mol]basepython} +deps = {[testenv:mol]deps} +changedir = {toxinidir}/tripleo_ansible/roles/tripleo-container-rm +commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars + [testenv:mol-tripleo-image-serve] basepython = {[testenv:mol]basepython} deps = {[testenv:mol]deps} changedir = {toxinidir}/tripleo_ansible/roles/tripleo-image-serve commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py +[testenv:mol-tripleo-image-serve-default] +basepython = {[testenv:mol]basepython} +deps = {[testenv:mol]deps} +changedir = {toxinidir}/tripleo_ansible/roles/tripleo-image-serve +commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=default + +[testenv:mol-tripleo-image-serve-legacy_vars] +basepython = {[testenv:mol]basepython} +deps = {[testenv:mol]deps} +changedir = {toxinidir}/tripleo_ansible/roles/tripleo-image-serve +commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py --scenario=legacy_vars + [testenv:mol-tripleo-transfer] basepython = {[testenv:mol]basepython} deps = {[testenv:mol]deps} diff --git a/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/molecule.yml b/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/molecule.yml new file mode 100644 index 000000000..97e31714b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/molecule.yml @@ -0,0 +1,48 @@ +--- +driver: + name: delegated + options: + managed: false + login_cmd_template: >- + ssh + -o UserKnownHostsFile=/dev/null + -o StrictHostKeyChecking=no + -o Compression=no + -o TCPKeepAlive=yes + -o VerifyHostKeyDNS=no + -o ForwardX11=no + -o ForwardAgent=no + {instance} + ansible_connection_options: + ansible_connection: ssh + +log: true + +platforms: + - name: instance + +provisioner: + name: ansible + inventory: + hosts: + all: + hosts: + instance: + ansible_host: localhost + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + +scenario: + test_sequence: + - prepare + - converge + - verify + +lint: + enabled: false + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/playbook.yml b/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/playbook.yml new file mode 100644 index 000000000..2d9d3bc3d --- /dev/null +++ b/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/playbook.yml @@ -0,0 +1,26 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + become: true + hosts: all + roles: + - role: tripleo-container-rm + container_cli: podman + containers_to_rm: + - podman-legacy-container1 + - podman-legacy-container2 diff --git a/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/prepare.yml b/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/prepare.yml new file mode 100644 index 000000000..51aaec8d6 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-container-rm/molecule/legacy_vars/prepare.yml @@ -0,0 +1,41 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + become: true + gather_facts: true + vars: + required_packages: + - podman + roles: + - role: test_deps + post_tasks: + - name: Install podman + become: true + package: + name: "{{ required_packages }}" + state: latest + + - name: Pull container image + command: "podman pull fedora:28" + + - name: Create test containers + command: "podman run -itd --systemd --name {{ item }} fedora bash" + with_items: + - podman-legacy-container1 + - podman-legacy-container2 diff --git a/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/molecule.yml b/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/molecule.yml new file mode 100644 index 000000000..97e31714b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/molecule.yml @@ -0,0 +1,48 @@ +--- +driver: + name: delegated + options: + managed: false + login_cmd_template: >- + ssh + -o UserKnownHostsFile=/dev/null + -o StrictHostKeyChecking=no + -o Compression=no + -o TCPKeepAlive=yes + -o VerifyHostKeyDNS=no + -o ForwardX11=no + -o ForwardAgent=no + {instance} + ansible_connection_options: + ansible_connection: ssh + +log: true + +platforms: + - name: instance + +provisioner: + name: ansible + inventory: + hosts: + all: + hosts: + instance: + ansible_host: localhost + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + +scenario: + test_sequence: + - prepare + - converge + - verify + +lint: + enabled: false + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/playbook.yml b/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/playbook.yml new file mode 100644 index 000000000..ae6d431d6 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/playbook.yml @@ -0,0 +1,30 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + hosts: all + become: true + roles: + - role: "tripleo-container-tag" + container_image: fedora:28 + container_image_latest: test-latest + container_cli: podman + - role: "tripleo-container-tag" + container_image: fedora:28 + container_image_latest: test-latest-2 + container_cli: podman + container_pull_image: false diff --git a/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/prepare.yml b/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/prepare.yml new file mode 100644 index 000000000..b3d30fb0e --- /dev/null +++ b/tripleo_ansible/roles/tripleo-container-tag/molecule/legacy_vars/prepare.yml @@ -0,0 +1,32 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + become: true + gather_facts: true + vars: + required_packages: + - podman + roles: + - role: test_deps + post_tasks: + - name: Install podman + become: true + package: + name: "{{ required_packages }}" + state: latest diff --git a/tripleo_ansible/roles/tripleo-container-tag/tasks/main.yml b/tripleo_ansible/roles/tripleo-container-tag/tasks/main.yml index 767ddeebb..161621d3a 100644 --- a/tripleo_ansible/roles/tripleo-container-tag/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo-container-tag/tasks/main.yml @@ -22,7 +22,7 @@ msg: >- The variable `tripleo_container_image` is an empty set. Check the settings. when: - - (tripleo_container_image | length) < 1 + - not tripleo_container_image - name: Pull {{ tripleo_container_image }} image shell: "{{ tripleo_container_cli }} pull {{ tripleo_container_image }}" diff --git a/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/Dockerfile b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/Dockerfile new file mode 100644 index 000000000..a3ab1ecc8 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/Dockerfile @@ -0,0 +1,36 @@ +# Molecule managed +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +{% 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 {{ item.pkg_extras | default('') }} && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && 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 {{ item.pkg_extras | default('') }} && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi + +{% for pkg in item.easy_install | default([]) %} +# install pip for centos where there is no python-pip rpm in default repos +RUN easy_install {{ pkg }} +{% endfor %} + +CMD ["sh", "-c", "while true; do sleep 10000; done"] \ No newline at end of file diff --git a/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/molecule.yml b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/molecule.yml new file mode 100644 index 000000000..c5b487da9 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/molecule.yml @@ -0,0 +1,68 @@ +--- +driver: + name: docker + +log: true + +platforms: + - name: centos7 + hostname: centos7 + image: centos:7 + dockerfile: Dockerfile + pkg_extras: python-setuptools + easy_install: + - pip + environment: &env + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + command: /sbin/init + tmpfs: + - /run + - /tmp + capabilities: + - ALL # CENT7 requires all due to the age of the software + volumes: + - /run/udev:/run/udev:ro + - /sys/fs/cgroup:/sys/fs/cgroup:ro + + - name: fedora28 + hostname: fedora28 + image: fedora:28 + dockerfile: Dockerfile + pkg_extras: python*-setuptools + environment: + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + command: /sbin/init + privileged: true + tmpfs: + - /run + - /tmp + capabilities: + - SYS_ADMIN + volumes: + - /run/udev:/run/udev:ro + - /sys/fs/cgroup:/sys/fs/cgroup:ro + +provisioner: + name: ansible + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + +scenario: + test_sequence: + - destroy + - create + - prepare + - converge + - verify + - destroy + +lint: + enabled: false + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/playbook.yml b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/playbook.yml new file mode 100644 index 000000000..49e9332e1 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/playbook.yml @@ -0,0 +1,24 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + hosts: all + roles: + - role: "tripleo-image-serve" + container_registry_host: 'localhost' + container_registry_port: 8787 + image_data_dir: "/var/lib/image-serve-legacy" diff --git a/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/prepare.yml b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/prepare.yml new file mode 100644 index 000000000..ef85c3128 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/prepare.yml @@ -0,0 +1,21 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + roles: + - role: test_deps diff --git a/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/tests/test_default.py b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/tests/test_default.py new file mode 100644 index 000000000..a52e5b3dd --- /dev/null +++ b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/tests/test_default.py @@ -0,0 +1,43 @@ +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import os + +import testinfra.utils.ansible_runner + + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_package_installed(host): + assert host.package("httpd").is_installed + + +def test_image_serve_conf_exists(host): + assert host.file("/etc/httpd/conf.d/image-serve.conf").exists + + +def test_image_serve_dir_exists(host): + assert host.file("/var/lib/image-serve-legacy").exists + + +def test_httpd_running(host): + assert host.service("httpd").is_running + + +def test_httpd_enabled(host): + assert host.service("httpd").is_enabled diff --git a/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/verify.yml b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/verify.yml new file mode 100644 index 000000000..dfd4c7352 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-image-serve/molecule/legacy_vars/verify.yml @@ -0,0 +1,15 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. diff --git a/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/Dockerfile b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/Dockerfile @@ -0,0 +1,37 @@ +# Molecule managed +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +{% 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 {{ item.pkg_extras | default('') }} && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && 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 {{ item.pkg_extras | default('') }} && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi + +{% for pkg in item.easy_install | default([]) %} +# install pip for centos where there is no python-pip rpm in default repos +RUN easy_install {{ pkg }} +{% endfor %} + + +CMD ["sh", "-c", "while true; do sleep 10000; done"] diff --git a/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/molecule.yml b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/molecule.yml new file mode 100644 index 000000000..4e21e8195 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/molecule.yml @@ -0,0 +1,68 @@ +--- +driver: + name: docker + +log: true + +platforms: + - name: centos7 + hostname: centos7 + image: centos:7 + dockerfile: Dockerfile + pkg_extras: python-setuptools + easy_install: + - pip + environment: &env + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + command: /sbin/init + tmpfs: + - /run + - /tmp + capabilities: + - ALL + volumes: + - /dev:/dev + - /lib/modules:/lib/modules + + - name: fedora28 + hostname: fedora28 + image: fedora:28 + dockerfile: Dockerfile + pkg_extras: python*-setuptools + environment: + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + command: /sbin/init + privileged: true + tmpfs: + - /run + - /tmp + capabilities: + - ALL + volumes: + - /dev:/dev + - /lib/modules:/lib/modules + +provisioner: + name: ansible + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + +scenario: + test_sequence: + - destroy + - create + - prepare + - converge + - verify + - destroy + +lint: + enabled: false + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/playbook.yml b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/playbook.yml new file mode 100644 index 000000000..f8a2ccee3 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/playbook.yml @@ -0,0 +1,23 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + hosts: all + roles: + - role: "tripleo-module-load" + modules: + - name: dummy diff --git a/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/prepare.yml b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/prepare.yml new file mode 100644 index 000000000..eaca6e17c --- /dev/null +++ b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/prepare.yml @@ -0,0 +1,26 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + roles: + - role: test_deps + post_tasks: + - name: Install additional dependencies + package: + name: kmod + state: present diff --git a/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/verify.yml b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/verify.yml new file mode 100644 index 000000000..dfd4c7352 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-module-load/molecule/legacy_vars/verify.yml @@ -0,0 +1,15 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. diff --git a/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/Dockerfile b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/Dockerfile @@ -0,0 +1,37 @@ +# Molecule managed +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +{% 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 {{ item.pkg_extras | default('') }} && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && 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 {{ item.pkg_extras | default('') }} && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi + +{% for pkg in item.easy_install | default([]) %} +# install pip for centos where there is no python-pip rpm in default repos +RUN easy_install {{ pkg }} +{% endfor %} + + +CMD ["sh", "-c", "while true; do sleep 10000; done"] diff --git a/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/molecule.yml b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/molecule.yml new file mode 100644 index 000000000..d34dc19df --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/molecule.yml @@ -0,0 +1,62 @@ +--- +driver: + name: docker + +log: true + +platforms: + - name: centos7 + hostname: centos7 + image: centos:7 + dockerfile: Dockerfile + pkg_extras: python-setuptools + easy_install: + - pip + environment: &env + http_proxy: "{{ lookup('env', 'http_proxy') }}" + https_proxy: "{{ lookup('env', 'https_proxy') }}" + + - name: fedora28 + hostname: fedora28 + image: fedora:28 + dockerfile: Dockerfile + pkg_extras: python*-setuptools + environment: + <<: *env + +provisioner: + name: ansible + inventory: + hosts: + all: + vars: + ssh_known_hosts: + "centos7": '[10.0.0.0]*,[test-0.localdomain]*,[test-0]*' + "fedora28": '[10.0.0.0]*,[test-0.localdomain]*,[test-0]*' + children: + overcloud: + hosts: + fedora28: + ansible_ssh_host_key_rsa_public: AAAATEST + centos7: + ansible_ssh_host_key_rsa_public: AAAATEST + log: true + env: + ANSIBLE_STDOUT_CALLBACK: yaml + +scenario: + test_sequence: + - destroy + - create + - prepare + - converge + - verify + - destroy + +lint: + enabled: false + +verifier: + name: testinfra + lint: + name: flake8 diff --git a/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/playbook.yml b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/playbook.yml new file mode 100644 index 000000000..602efb953 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/playbook.yml @@ -0,0 +1,22 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Converge + hosts: all + pre_tasks: + roles: + - role: "tripleo-ssh-known-hosts" diff --git a/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/prepare.yml b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/prepare.yml new file mode 100644 index 000000000..57929e854 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/prepare.yml @@ -0,0 +1,26 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +- name: Prepare + hosts: all + roles: + - role: test_deps + tasks: + - name: Install additional dependencies + package: + name: openssh + state: present diff --git a/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/tests/test_default.py b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/tests/test_default.py new file mode 100644 index 000000000..efbeb6795 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/tests/test_default.py @@ -0,0 +1,28 @@ +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import os + +import testinfra.utils.ansible_runner + + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_host_key_add(host): + assert '[10.0.0.0]*,[test-0.localdomain]*,[test-0]* ssh-rsa AAAATEST' \ + in host.file("/etc/ssh/ssh_known_hosts").content_string diff --git a/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/verify.yml b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/verify.yml new file mode 100644 index 000000000..dfd4c7352 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ssh-known-hosts/molecule/legacy_vars/verify.yml @@ -0,0 +1,15 @@ +--- +# Copyright 2019 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index ba2d2f06c..7096bf16e 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -98,6 +98,7 @@ - ^tripleo_ansible/roles/tripleo-module-load/.* name: tripleo-ansible-centos-7-molecule-tripleo-module-load parent: tripleo-ansible-centos + timeout: 1800 vars: tox_envlist: mol-tripleo-module-load - job: