diff --git a/ansible-test-env.rc b/ansible-test-env.rc index b21feac17..b09d2f07c 100644 --- a/ansible-test-env.rc +++ b/ansible-test-env.rc @@ -9,6 +9,7 @@ export ANSIBLE_ROLES_PATH="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/roles.gal export ANSIBLE_INVENTORY="${TRIPLEO_ANSIBLE_WORKPATH}/tests/hosts.ini" export ANSIBLE_RETRY_FILES_ENABLED="0" export ANSIBLE_LOAD_CALLBACK_PLUGINS="1" +export ANSIBLE_HOST_KEY_CHECKING=False function unset-ansible-test-env { for i in $(env | grep ANSIBLE_ | awk -F'=' '{print $1}'); do diff --git a/doc/source/roles/role-tripleo-ceph-run-ansible.rst b/doc/source/roles/role-tripleo-ceph-run-ansible.rst index 9f87bef24..59c482fc0 100644 --- a/doc/source/roles/role-tripleo-ceph-run-ansible.rst +++ b/doc/source/roles/role-tripleo-ceph-run-ansible.rst @@ -4,3 +4,13 @@ Role - tripleo-ceph-run-ansible .. ansibleautoplugin:: :role: tripleo_ansible/roles/tripleo-ceph-run-ansible + + +Required test arguments +~~~~~~~~~~~~~~~~~~~~~~~ + ++--------------------------+-------------------------------------------------+ +| Environment Variable | Variable Value | ++==========================+=================================================+ +| TRIPLEO_JOB_ANSIBLE_ARGS | '--skip-tags=run_uuid_ansible,run_ceph_ansible' | ++--------------------------+-------------------------------------------------+ diff --git a/doc/source/roles/role-tripleo-ceph-uuid.rst b/doc/source/roles/role-tripleo-ceph-uuid.rst index 9afcdad06..7d1467a2b 100644 --- a/doc/source/roles/role-tripleo-ceph-uuid.rst +++ b/doc/source/roles/role-tripleo-ceph-uuid.rst @@ -4,3 +4,13 @@ Role - tripleo-ceph-uuid .. ansibleautoplugin:: :role: tripleo_ansible/roles/tripleo-ceph-uuid + + +Required test arguments +~~~~~~~~~~~~~~~~~~~~~~~ + ++--------------------------+-------------------------------------------------+ +| Environment Variable | Variable Value | ++==========================+=================================================+ +| TRIPLEO_JOB_ANSIBLE_ARGS | '--skip-tags=run_uuid_ansible' | ++--------------------------+-------------------------------------------------+ diff --git a/scripts/run-local-test b/scripts/run-local-test index 08d120e52..b2777698e 100755 --- a/scripts/run-local-test +++ b/scripts/run-local-test @@ -24,6 +24,7 @@ set -xeuo export PROJECT_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../" export ROLE_NAME="${ROLE_NAME:-$1}" +export TRIPLEO_JOB_ANSIBLE_ARGS=${TRIPLEO_JOB_ANSIBLE_ARGS:-"-v"} ## Main ---------------------------------------------------------------------- @@ -42,22 +43,27 @@ esac # Create a virtual env "${PYTHON_EXEC}" -m virtualenv --system-site-packages "${HOME}/test-python" +# Run bindep +"${HOME}/test-python/bin/pip" install pip setuptools bindep --upgrade +"${PROJECT_DIR}/scripts/bindep-install" + # Install local requirements +if [[ -d "${HOME}/.cache/pip/wheels" ]]; then + rm -rf "${HOME}/.cache/pip/wheels" +fi "${HOME}/test-python/bin/pip" install \ -r "${PROJECT_DIR}/requirements.txt" \ -r "${PROJECT_DIR}/test-requirements.txt" \ -r "${PROJECT_DIR}/molecule-requirements.txt" -# Run bindep -PS1="[\u@\h \W]\$" source "${HOME}/test-python/bin/activate" -"${PROJECT_DIR}/scripts/bindep-install" - # Run local test +PS1="[\u@\h \W]\$" source "${HOME}/test-python/bin/activate" source "${PROJECT_DIR}/ansible-test-env.rc" export ANSIBLE_ROLES_PATH="${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles" ansible-playbook -i "${PROJECT_DIR}/tests/hosts.ini" \ -e "tripleo_src=$(realpath --relative-to="${HOME}" "${PROJECT_DIR}")" \ -e "tripleo_role_name=${ROLE_NAME}" \ + -e "tripleo_job_ansible_args='${TRIPLEO_JOB_ANSIBLE_ARGS}'" \ -e "ansible_user=${USER}" \ -e "ansible_user_dir=${HOME}" \ "${PROJECT_DIR}/tripleo_ansible/playbooks/prepare-test-host.yml" \ diff --git a/tripleo_ansible/roles/test_deps/tasks/main.yml b/tripleo_ansible/roles/test_deps/tasks/main.yml index b40311d91..085b7cd4b 100644 --- a/tripleo_ansible/roles/test_deps/tasks/main.yml +++ b/tripleo_ansible/roles/test_deps/tasks/main.yml @@ -31,18 +31,25 @@ tags: - always -- name: install deplorean repo +- name: RHEL Block become: true - get_url: - url: "https://trunk.rdoproject.org/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-master/current-tripleo/delorean.repo" - dest: /etc/yum.repos.d/delorean.repo when: - (ansible_os_family | lower) == 'redhat' + block: + - name: install deplorean repo + become: true + get_url: + url: "https://trunk.rdoproject.org/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-master/current-tripleo/delorean.repo" + dest: /etc/yum.repos.d/delorean.repo + when: + - (ansible_os_family | lower) == 'redhat' -- name: install deplorean-deps repo - become: true - get_url: - url: "https://trunk.rdoproject.org/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-master/delorean-deps.repo" - dest: /etc/yum.repos.d/delorean-deps.repo - when: - - (ansible_os_family | lower) == 'redhat' + - name: install deplorean-deps repo + get_url: + url: "https://trunk.rdoproject.org/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-master/delorean-deps.repo" + dest: /etc/yum.repos.d/delorean-deps.repo + + - name: Install selinux python libs + package: + name: libselinux-python + state: present diff --git a/tripleo_ansible/roles/tripleo-ceph-common/defaults/main.yml b/tripleo_ansible/roles/tripleo-ceph-common/defaults/main.yml index fe832b2c4..e9077775e 100644 --- a/tripleo_ansible/roles/tripleo-ceph-common/defaults/main.yml +++ b/tripleo_ansible/roles/tripleo-ceph-common/defaults/main.yml @@ -126,7 +126,7 @@ blacklisted_hostnames: [] ceph_ansible_extra_vars: ireallymeanit: 'yes' container_binary: 'podman' -uuid_content: '' +uuid_content: {} ceph_ansible_playbook_verbosity: 3 ceph_ansible_playbooks_param: ['default'] local_ceph_ansible_fetch_directory_backup: "{{ playbook_dir }}/ceph-ansible/fetch_backup" diff --git a/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/Dockerfile b/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/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-ceph-common/molecule/default/molecule.yml b/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/molecule.yml new file mode 100644 index 000000000..5573a77ff --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/molecule.yml @@ -0,0 +1,53 @@ +--- +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: + ansible_user: root + 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-ceph-common/molecule/default/playbook.yml b/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/playbook.yml new file mode 100644 index 000000000..c6ede4789 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/playbook.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: Converge + hosts: all + roles: + - role: "tripleo-ceph-common" diff --git a/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/prepare.yml b/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/prepare.yml new file mode 100644 index 000000000..ef85c3128 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-common/molecule/default/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-ceph-common/tasks/main.yml b/tripleo_ansible/roles/tripleo-ceph-common/tasks/main.yml new file mode 100644 index 000000000..ba3225571 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-common/tasks/main.yml @@ -0,0 +1,45 @@ +--- +# 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. + + +# "tripleo-ceph-common" will search for and load any operating system variable file + +# found within the "vars/" path. If no OS files are found the task will skip. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - skip: true + files: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + +- name: set basic user fact + set_fact: + ansible_user: "{{ lookup('env', 'USER') }}" + when: + - ansible_user is undefined + +- name: set basic home fact + set_fact: + ansible_user_dir: "{{ lookup('env', 'HOME') }}" + when: + - ansible_user_dir is undefined diff --git a/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/Dockerfile b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/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-ceph-fetch-dir/molecule/default/molecule.yml b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/molecule.yml new file mode 100644 index 000000000..5573a77ff --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/molecule.yml @@ -0,0 +1,53 @@ +--- +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: + ansible_user: root + 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-ceph-fetch-dir/molecule/default/playbook.yml b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/playbook.yml new file mode 100644 index 000000000..de9b89a1a --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/playbook.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: Converge + hosts: all + roles: + - role: "tripleo-ceph-fetch-dir" diff --git a/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/prepare.yml b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/prepare.yml new file mode 100644 index 000000000..ef85c3128 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/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-ceph-fetch-dir/molecule/default/verify.yml b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/verify.yml new file mode 100644 index 000000000..dfd4c7352 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-fetch-dir/molecule/default/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-ceph-run-ansible/molecule/default/Dockerfile b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/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-ceph-run-ansible/molecule/default/molecule.yml b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/molecule.yml new file mode 100644 index 000000000..5573a77ff --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/molecule.yml @@ -0,0 +1,53 @@ +--- +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: + ansible_user: root + 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-ceph-run-ansible/molecule/default/playbook.yml b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/playbook.yml new file mode 100644 index 000000000..c311b0339 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/playbook.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: Converge + hosts: all + roles: + - role: "tripleo-ceph-run-ansible" diff --git a/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/prepare.yml b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/prepare.yml new file mode 100644 index 000000000..ef85c3128 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/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-ceph-run-ansible/molecule/default/verify.yml b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/verify.yml new file mode 100644 index 000000000..dfd4c7352 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-run-ansible/molecule/default/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-ceph-run-ansible/tasks/main.yml b/tripleo_ansible/roles/tripleo-ceph-run-ansible/tasks/main.yml index ec1b0b873..1672c49c6 100644 --- a/tripleo_ansible/roles/tripleo-ceph-run-ansible/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo-ceph-run-ansible/tasks/main.yml @@ -76,4 +76,5 @@ when: - outputs is changed - outputs.rc != 0 - tags: run_ceph_ansible + tags: + - run_ceph_ansible diff --git a/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/Dockerfile b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/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-ceph-uuid/molecule/default/molecule.yml b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/molecule.yml new file mode 100644 index 000000000..5573a77ff --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/molecule.yml @@ -0,0 +1,53 @@ +--- +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: + ansible_user: root + 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-ceph-uuid/molecule/default/playbook.yml b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/playbook.yml new file mode 100644 index 000000000..a98cc009a --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/playbook.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: Converge + hosts: all + roles: + - role: "tripleo-ceph-uuid" diff --git a/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/prepare.yml b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/prepare.yml new file mode 100644 index 000000000..ef85c3128 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/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-ceph-uuid/molecule/default/verify.yml b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/verify.yml new file mode 100644 index 000000000..dfd4c7352 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-uuid/molecule/default/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-ceph-uuid/tasks/gather.yml b/tripleo_ansible/roles/tripleo-ceph-uuid/tasks/gather.yml index 8f9b8ae56..830e7d512 100644 --- a/tripleo_ansible/roles/tripleo-ceph-uuid/tasks/gather.yml +++ b/tripleo_ansible/roles/tripleo-ceph-uuid/tasks/gather.yml @@ -33,3 +33,5 @@ # needs become to be able to read the ssh private key become: true shell: "{{ nodes_uuid_list|join(' ') }}" + tags: + - run_uuid_ansible diff --git a/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/Dockerfile b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/Dockerfile new file mode 100644 index 000000000..1b91a0e0b --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/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-ceph-work-dir/molecule/default/molecule.yml b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/molecule.yml new file mode 100644 index 000000000..5573a77ff --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/molecule.yml @@ -0,0 +1,53 @@ +--- +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: + ansible_user: root + 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-ceph-work-dir/molecule/default/playbook.yml b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/playbook.yml new file mode 100644 index 000000000..b2524ee5a --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/playbook.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: Converge + hosts: all + roles: + - role: "tripleo-ceph-work-dir" diff --git a/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/prepare.yml b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/prepare.yml new file mode 100644 index 000000000..ef85c3128 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/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-ceph-work-dir/molecule/default/verify.yml b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/verify.yml new file mode 100644 index 000000000..dfd4c7352 --- /dev/null +++ b/tripleo_ansible/roles/tripleo-ceph-work-dir/molecule/default/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-ceph-work-dir/tasks/prepare.yml b/tripleo_ansible/roles/tripleo-ceph-work-dir/tasks/prepare.yml index ebb53ca8e..fb809823f 100644 --- a/tripleo_ansible/roles/tripleo-ceph-work-dir/tasks/prepare.yml +++ b/tripleo_ansible/roles/tripleo-ceph-work-dir/tasks/prepare.yml @@ -34,6 +34,9 @@ src: "{{ inventory_file }}" dest: "{{ playbook_dir }}/ceph-ansible/inventory.yml" state: link + tags: + - run_uuid_ansible + - run_ceph_ansible - name: generate ceph-ansible group vars all copy: diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index 301a4f411..64faa7e89 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -18,6 +18,7 @@ - tripleo-ansible-centos-7-molecule-tripleo-transfer - tripleo-ansible-centos-7-molecule-tripleo-podman - tripleo-ansible-centos-7-molecule-tripleo-persist + - tripleo-ansible-centos-7-molecule-tripleo-ceph-run-ansible gate: jobs: - tripleo-ansible-centos-7-molecule-aide @@ -36,6 +37,7 @@ - tripleo-ansible-centos-7-molecule-tripleo-transfer - tripleo-ansible-centos-7-molecule-tripleo-podman - tripleo-ansible-centos-7-molecule-tripleo-persist + - tripleo-ansible-centos-7-molecule-tripleo-ceph-run-ansible name: tripleo-ansible-molecule-jobs - job: files: @@ -154,3 +156,11 @@ parent: tripleo-ansible-centos-7-base vars: tripleo_role_name: tripleo-persist +- job: + files: + - ^tripleo_ansible/roles/tripleo-ceph-run-ansible/.* + name: tripleo-ansible-centos-7-molecule-tripleo-ceph-run-ansible + parent: tripleo-ansible-centos-7-base + vars: + tripleo_role_name: tripleo-ceph-run-ansible + tripleo_job_ansible_args: '-v --skip-tags=run_uuid_ansible,run_ceph_ansible' diff --git a/zuul.d/playbooks/run.yml b/zuul.d/playbooks/run.yml index bd264dd21..02232bc64 100644 --- a/zuul.d/playbooks/run.yml +++ b/zuul.d/playbooks/run.yml @@ -12,6 +12,7 @@ --html={{ ansible_user_dir }}/zuul-output/logs/reports.html \ --self-contained-html \ -s \ + --ansible-args='{{ tripleo_job_ansible_args | default("-v") }}' \ {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/test_molecule.py args: chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tripleo_ansible/roles/{{ tripleo_role_name }}"