From 91fcd6c104bfd09daef69847bd1b43310e7f0e2c Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 15 Jan 2020 23:14:36 +0100 Subject: [PATCH] try to test role - again --- .ansible-test.yml | 7 ++ requirements.txt => .requirements.txt | 0 .travis.yml | 94 +++++++++++++------------- molecule/default/Dockerfile.j2 | 35 ---------- molecule/default/INSTALL.rst | 22 ------ molecule/default/molecule.yml | 22 ------ molecule/default/playbook.yml | 5 -- molecule/default/tests/test_default.py | 12 ---- tox.ini | 6 +- 9 files changed, 57 insertions(+), 146 deletions(-) create mode 100644 .ansible-test.yml rename requirements.txt => .requirements.txt (100%) delete mode 100644 molecule/default/Dockerfile.j2 delete mode 100644 molecule/default/INSTALL.rst delete mode 100644 molecule/default/molecule.yml delete mode 100644 molecule/default/playbook.yml delete mode 100644 molecule/default/tests/test_default.py diff --git a/.ansible-test.yml b/.ansible-test.yml new file mode 100644 index 0000000..1e989a6 --- /dev/null +++ b/.ansible-test.yml @@ -0,0 +1,7 @@ +--- +- name: secure access to toolbox gateway + hosts: localhost + tags: + - default + roles: + - './' diff --git a/requirements.txt b/.requirements.txt similarity index 100% rename from requirements.txt rename to .requirements.txt diff --git a/.travis.yml b/.travis.yml index 56a5375..d53e6ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,54 +21,54 @@ install: - pip install tox-travis env: jobs: - - TOX_DISTRO=alpinelatest TOX_ANSIBLE=latest - - TOX_DISTRO=alpine310 TOX_ANSIBLE=latest - - TOX_DISTRO=alpine39 TOX_ANSIBLE=latest - - TOX_DISTRO=centoslatest TOX_ANSIBLE=latest - - TOX_DISTRO=centos8 TOX_ANSIBLE=latest - - TOX_DISTRO=centos7 TOX_ANSIBLE=latest - - TOX_DISTRO=clearlinuxlatest TOX_ANSIBLE=latest - - TOX_DISTRO=debianlatest TOX_ANSIBLE=latest - - TOX_DISTRO=debianstable TOX_ANSIBLE=latest +# - TOX_DISTRO=alpinelatest TOX_ANSIBLE=latest +# - TOX_DISTRO=alpine310 TOX_ANSIBLE=latest +# - TOX_DISTRO=alpine39 TOX_ANSIBLE=latest +# - TOX_DISTRO=centoslatest TOX_ANSIBLE=latest +# - TOX_DISTRO=centos8 TOX_ANSIBLE=latest +# - TOX_DISTRO=centos7 TOX_ANSIBLE=latest +# - TOX_DISTRO=clearlinuxlatest TOX_ANSIBLE=latest +# - TOX_DISTRO=debianlatest TOX_ANSIBLE=latest +# - TOX_DISTRO=debianstable TOX_ANSIBLE=latest - TOX_DISTRO=debian10 TOX_ANSIBLE=latest - - TOX_DISTRO=debian9 TOX_ANSIBLE=latest - - TOX_DISTRO=debian8 TOX_ANSIBLE=latest - - TOX_DISTRO=fedoralatest TOX_ANSIBLE=latest - - TOX_DISTRO=fedora31 TOX_ANSIBLE=latest - - TOX_DISTRO=fedora30 TOX_ANSIBLE=latest - - TOX_DISTRO=fedora29 TOX_ANSIBLE=latest - - TOX_DISTRO=fedora28 TOX_ANSIBLE=latest - - TOX_DISTRO=opensuselatest TOX_ANSIBLE=latest - - TOX_DISTRO=opensuse15 TOX_ANSIBLE=latest - - TOX_DISTRO=ubuntulatest TOX_ANSIBLE=latest - - TOX_DISTRO=ubuntu2004 TOX_ANSIBLE=latest - - TOX_DISTRO=ubuntu1904 TOX_ANSIBLE=latest - - TOX_DISTRO=ubuntu1804 TOX_ANSIBLE=latest - - TOX_DISTRO=ubuntu1604 TOX_ANSIBLE=latest - - TOX_DISTRO=alpinelatest TOX_ANSIBLE={29,28} - - TOX_DISTRO=alpine310 TOX_ANSIBLE={29,28} - - TOX_DISTRO=alpine39 TOX_ANSIBLE={29,28} - - TOX_DISTRO=centoslatest TOX_ANSIBLE={29,28} - - TOX_DISTRO=centos8 TOX_ANSIBLE={29,28} - - TOX_DISTRO=centos7 TOX_ANSIBLE={29,28} - - TOX_DISTRO=clearlinuxlatest TOX_ANSIBLE={29,28} - - TOX_DISTRO=debianlatest TOX_ANSIBLE={29,28} - - TOX_DISTRO=debianstable TOX_ANSIBLE={29,28} - - TOX_DISTRO=debian10 TOX_ANSIBLE={29,28} - - TOX_DISTRO=debian9 TOX_ANSIBLE={29,28} - - TOX_DISTRO=debian8 TOX_ANSIBLE={29,28} - - TOX_DISTRO=fedoralatest TOX_ANSIBLE={29,28} - - TOX_DISTRO=fedora31 TOX_ANSIBLE={29,28} - - TOX_DISTRO=fedora30 TOX_ANSIBLE={29,28} - - TOX_DISTRO=fedora29 TOX_ANSIBLE={29,28} - - TOX_DISTRO=fedora28 TOX_ANSIBLE={29,28} - - TOX_DISTRO=opensuselatest TOX_ANSIBLE={29,28} - - TOX_DISTRO=opensuse15 TOX_ANSIBLE={29,28} - - TOX_DISTRO=ubuntulatest TOX_ANSIBLE={29,28} - - TOX_DISTRO=ubuntu2004 TOX_ANSIBLE={29,28} - - TOX_DISTRO=ubuntu1904 TOX_ANSIBLE={29,28} - - TOX_DISTRO=ubuntu1804 TOX_ANSIBLE={29,28} - - TOX_DISTRO=ubuntu1604 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=debian9 TOX_ANSIBLE=latest +# - TOX_DISTRO=debian8 TOX_ANSIBLE=latest +# - TOX_DISTRO=fedoralatest TOX_ANSIBLE=latest +# - TOX_DISTRO=fedora31 TOX_ANSIBLE=latest +# - TOX_DISTRO=fedora30 TOX_ANSIBLE=latest +# - TOX_DISTRO=fedora29 TOX_ANSIBLE=latest +# - TOX_DISTRO=fedora28 TOX_ANSIBLE=latest +# - TOX_DISTRO=opensuselatest TOX_ANSIBLE=latest +# - TOX_DISTRO=opensuse15 TOX_ANSIBLE=latest +# - TOX_DISTRO=ubuntulatest TOX_ANSIBLE=latest +# - TOX_DISTRO=ubuntu2004 TOX_ANSIBLE=latest +# - TOX_DISTRO=ubuntu1904 TOX_ANSIBLE=latest +# - TOX_DISTRO=ubuntu1804 TOX_ANSIBLE=latest +# - TOX_DISTRO=ubuntu1604 TOX_ANSIBLE=latest +# - TOX_DISTRO=alpinelatest TOX_ANSIBLE={29,28} +# - TOX_DISTRO=alpine310 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=alpine39 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=centoslatest TOX_ANSIBLE={29,28} +# - TOX_DISTRO=centos8 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=centos7 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=clearlinuxlatest TOX_ANSIBLE={29,28} +# - TOX_DISTRO=debianlatest TOX_ANSIBLE={29,28} +# - TOX_DISTRO=debianstable TOX_ANSIBLE={29,28} +# - TOX_DISTRO=debian10 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=debian9 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=debian8 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=fedoralatest TOX_ANSIBLE={29,28} +# - TOX_DISTRO=fedora31 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=fedora30 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=fedora29 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=fedora28 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=opensuselatest TOX_ANSIBLE={29,28} +# - TOX_DISTRO=opensuse15 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=ubuntulatest TOX_ANSIBLE={29,28} +# - TOX_DISTRO=ubuntu2004 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=ubuntu1904 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=ubuntu1804 TOX_ANSIBLE={29,28} +# - TOX_DISTRO=ubuntu1604 TOX_ANSIBLE={29,28} script: - tox -e $(echo py${TRAVIS_PYTHON_VERSION} | tr -d .)-ansible${TOX_ANSIBLE}-${TOX_DISTRO} - | diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 deleted file mode 100644 index 4063a31..0000000 --- a/molecule/default/Dockerfile.j2 +++ /dev/null @@ -1,35 +0,0 @@ -# Molecule managed - -{% if item.registry is defined %} -FROM {{ item.registry.url }}/{{ item.image }} -{% else %} -FROM {{ item.image }} -{% endif %} - -{% if item.env is defined %} -{% for var, value in item.env.items() %} -{% if value %} -ENV {{ var }} {{ value }} -{% endif %} -{% endfor %} -{% endif %} - -RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates iproute2 init && apt-get clean; \ - elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml iproute2 systemd-sysvinit && 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 iproute2 && xbps-remove -O; \ - elif [ $(command -v swupd) ]; then swupd bundle-add python3-basic sudo iproute2; \ - elif [ $(command -v dnf) ] && cat /etc/os-release | grep -q '^NAME=Fedora' && \ - cat /etc/os-release | grep -q '^VERSION_ID=30'; then dnf makecache && dnf --assumeyes install python sudo python-devel python3-dnf bash iproute && dnf clean all; \ - elif [ $(command -v dnf) ] && cat /etc/os-release | grep -q '^NAME=Fedora'; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash iproute && dnf clean all; \ - elif [ $(command -v dnf) ] && cat /etc/os-release | grep -q '^NAME="CentOS Linux"' ; then dnf makecache && dnf --assumeyes install python36 sudo platform-python-devel python*-dnf bash iproute && dnf clean all && ln -s /usr/bin/python3 /usr/bin/python; \ - elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ - fi - -# Centos:8 + ansible 2.7 failed with error: "The module failed to execute correctly, you probably need to set the interpreter" -# Solution: ln -s /usr/bin/python3 /usr/bin/python - -# Fedora:30 deprecated python2-dnf -# Solution: explicitly use python3-dnf instead -# https://github.com/ansible/ansible/issues/54855 -# https://github.com/ansible/ansible/issues/59248 \ No newline at end of file diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst deleted file mode 100644 index 6a44bde..0000000 --- a/molecule/default/INSTALL.rst +++ /dev/null @@ -1,22 +0,0 @@ -******* -Docker driver installation guide -******* - -Requirements -============ - -* Docker Engine - -Install -======= - -Please refer to the `Virtual environment`_ documentation for installation best -practices. If not using a virtual environment, please consider passing the -widely recommended `'--user' flag`_ when invoking ``pip``. - -.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ -.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site - -.. code-block:: bash - - $ pip install 'molecule[docker]' diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml deleted file mode 100644 index 0b3c96f..0000000 --- a/molecule/default/molecule.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: docker -lint: - name: yamllint -platforms: - - name: instance-${TOX_ENVNAME} - image: ${MOLECULE_DISTRO:-'centos:7'} - command: /sbin/init - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: true -provisioner: - name: ansible - lint: - name: ansible-lint -verifier: - name: testinfra - lint: - name: flake8 diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml deleted file mode 100644 index 6e75643..0000000 --- a/molecule/default/playbook.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Converge - hosts: all - roles: - - role: ansible-role-example diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py deleted file mode 100644 index 25fea10..0000000 --- a/molecule/default/tests/test_default.py +++ /dev/null @@ -1,12 +0,0 @@ -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE'] -).get_hosts('all') - - -def test_hello_world_file(host): - f = host.file('/tmp/hello-world.txt') - assert f.exists diff --git a/tox.ini b/tox.ini index d17394b..0a21df8 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ skipsdist = true [base] passenv = * deps = - -rrequirements.txt + -r.requirements.txt ansible25: ansible==2.5 ansible26: ansible==2.6 ansible27: ansible==2.7 @@ -18,7 +18,7 @@ deps = ansible29: ansible==2.9 ansiblelatest: ansible commands = - molecule test + ansible-playbook .ansible-test.yml -i localhost setenv = TOX_ENVNAME={envname} MOLECULE_EPHEMERAL_DIRECTORY=/tmp/{envname} @@ -63,4 +63,4 @@ setenv = ubuntu1804: MOLECULE_DISTRO="ubuntu:18.04" ubuntu1604: MOLECULE_DISTRO="ubuntu:16.04" - {[base]setenv} \ No newline at end of file + {[base]setenv}