diff --git a/bindep.txt b/bindep.txt index 668bd4047..b5c04d700 100644 --- a/bindep.txt +++ b/bindep.txt @@ -19,7 +19,9 @@ git [platform:rpm] libffi-devel [platform:rpm] openssl-devel [platform:rpm] python-devel [platform:rpm !platform:rhel-8 !platform:centos-8] -python3-devel [platform:rpm !platform:rhel-7 !platform:centos-7] +python3-devel [platform:rpm !platform:rhel-7 !platform:centos-7] +PyYAML [platform:rpm !platform:rhel-8 !platform:centos-8] +python3-pyyaml [platform:rpm !platform:rhel-7 !platform:centos-7] python2-dnf [platform:fedora] # For SELinux diff --git a/tripleo_ansible/roles/tripleo-container-manage/molecule/default/Dockerfile b/tripleo_ansible/roles/tripleo-container-manage/molecule/default/Dockerfile deleted file mode 100644 index 1b91a0e0b..000000000 --- a/tripleo_ansible/roles/tripleo-container-manage/molecule/default/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -# 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-container-manage/molecule/default/molecule.yml b/tripleo_ansible/roles/tripleo-container-manage/molecule/default/molecule.yml index 3a32890d4..052c5d4bf 100644 --- a/tripleo_ansible/roles/tripleo-container-manage/molecule/default/molecule.yml +++ b/tripleo_ansible/roles/tripleo-container-manage/molecule/default/molecule.yml @@ -1,43 +1,51 @@ --- driver: - name: docker + 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: 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 + - name: instance provisioner: name: ansible + config_options: + defaults: + fact_caching: jsonfile + fact_caching_connection: /tmp/molecule/facts + inventory: + hosts: + all: + hosts: + instance: + ansible_host: localhost log: true env: ANSIBLE_STDOUT_CALLBACK: yaml + ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH:-/usr/share/ansible/roles}:${HOME}/zuul-jobs/roles" + ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}" + ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-/usr/share/ansible/plugins/filter}" scenario: + name: default test_sequence: - - destroy - - create - prepare - converge - verify - - destroy lint: enabled: false diff --git a/tripleo_ansible/roles/tripleo-container-manage/molecule/default/playbook.yml b/tripleo_ansible/roles/tripleo-container-manage/molecule/default/playbook.yml index 2ebc3006b..c669ccd52 100644 --- a/tripleo_ansible/roles/tripleo-container-manage/molecule/default/playbook.yml +++ b/tripleo_ansible/roles/tripleo-container-manage/molecule/default/playbook.yml @@ -17,5 +17,10 @@ - name: Converge hosts: all - roles: - - role: "tripleo-container-manage" + vars: + tripleo_container_manage_config: '/tmp/container-configs' + tripleo_container_manage_debug: true + tripleo_container_manage_config_patterns: '*.json' + tasks: + - include_role: + name: tripleo-container-manage diff --git a/tripleo_ansible/roles/tripleo-container-manage/molecule/default/prepare.yml b/tripleo_ansible/roles/tripleo-container-manage/molecule/default/prepare.yml index ef85c3128..f2f835b67 100644 --- a/tripleo_ansible/roles/tripleo-container-manage/molecule/default/prepare.yml +++ b/tripleo_ansible/roles/tripleo-container-manage/molecule/default/prepare.yml @@ -19,3 +19,18 @@ hosts: all roles: - role: test_deps + test_deps_extra_packages: + - podman + tasks: + - name: Prepare the contianer configs directory + file: + path: '/tmp/container-configs' + state: directory + - name: Create a configuration file for a fedora container + copy: + content: | + { + "image": "fedora:latest", + "net": "host" + } + dest: '/tmp/container-configs/fedora.json' diff --git a/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml b/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml index d93047341..4415e9be9 100644 --- a/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo-container-manage/tasks/main.yml @@ -52,7 +52,7 @@ slurp: src: "{{ item.path }}" register: containers_data - loop: "{{ hashed_files.files }}" + loop: "{{ matched_files.files }}" - name: Prepare container hashes from config set_fact: container_hash: "{'{{ item.source|basename|regex_replace('^hashed-','')|regex_replace('.json$','') }}': {{ item.content|b64decode|from_json }} }" diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index 8419eff19..8e6923bd0 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -38,6 +38,7 @@ - tripleo-ansible-centos-7-molecule-backup-and-restore - tripleo-ansible-centos-7-molecule-tripleo-packages - tripleo-ansible-centos-7-molecule-tripleo-hosts-entries + - tripleo-ansible-centos-7-molecule-tripleo-container-manage gate: jobs: - tripleo-ansible-centos-7-molecule-aide @@ -76,6 +77,7 @@ - tripleo-ansible-centos-7-molecule-backup-and-restore - tripleo-ansible-centos-7-molecule-tripleo-packages - tripleo-ansible-centos-7-molecule-tripleo-hosts-entries + - tripleo-ansible-centos-7-molecule-tripleo-container-manage name: tripleo-ansible-molecule-jobs - job: files: @@ -338,3 +340,10 @@ parent: tripleo-ansible-centos-7-base vars: tripleo_role_name: tripleo-hosts-entries +- job: + files: + - ^tripleo_ansible/roles/tripleo-container-manage/.* + name: tripleo-ansible-centos-7-molecule-tripleo-container-manage + parent: tripleo-ansible-centos-7-base + vars: + tripleo_role_name: tripleo-container-manage