diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml new file mode 100644 index 0000000..4686936 --- /dev/null +++ b/.github/workflows/molecule.yml @@ -0,0 +1,37 @@ +--- +name: Ansible Molecule + +on: + push: + tags_ignore: + - '*' + pull_request: + +jobs: + lint: + runs-on: ubuntu-20.04 + steps: + - name: checkout + uses: actions/checkout@v2 + with: + path: "${{ github.repository }}" + - name: molecule + uses: robertdebock/molecule-action@2.6.8 + with: + command: lint + test: + needs: + - lint + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + steps: + - name: checkout + uses: actions/checkout@v2 + with: + path: "${{ github.repository }}" + - name: molecule + uses: robertdebock/molecule-action@2.6.8 + with: + image: ${{ matrix.config.image }} + tag: ${{ matrix.config.tag }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 09e0c7f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -sudo: required -language: python -services: - - docker - -before_install: - - sudo apt-get -qq update - -install: - - pip install -r requirements.txt - -script: - - tox - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/.yamllint b/.yamllint index f410695..2f6370c 100644 --- a/.yamllint +++ b/.yamllint @@ -1,48 +1,10 @@ --- - extends: default rules: - braces: - min-spaces-inside: 0 - max-spaces-inside: 1 - min-spaces-inside-empty: -1 - max-spaces-inside-empty: -1 - brackets: - min-spaces-inside: 0 - max-spaces-inside: 0 - min-spaces-inside-empty: -1 - max-spaces-inside-empty: -1 - colons: - max-spaces-before: 0 - max-spaces-after: 1 - commas: - max-spaces-before: 0 - min-spaces-after: 1 - max-spaces-after: 1 - comments: - level: warning - require-starting-space: false - min-spaces-from-content: 2 - comments-indentation: disable - document-end: disable - document-start: disable - empty-lines: - max: 2 - max-start: 0 - max-end: 0 - hyphens: - max-spaces-after: 1 - indentation: - spaces: consistent - indent-sequences: true - check-multi-line-strings: false - key-duplicates: enable - line-length: - max: 500 - allow-non-breakable-words: true - allow-non-breakable-inline-mappings: false - new-line-at-end-of-file: enable - new-lines: - type: unix - trailing-spaces: enable + truthy: + allowed-values: ['true', 'false', 'on'] + check-keys: true + +ignore: | + .tox/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..20747f0 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +# make a local environment and use molecule test + +../base: + python3 -m venv ../base +# (source ../base/bin/activate && python3 -m pip install --upgrade pip) + (source ../base/bin/activate && pip3 install -r requirements.txt) + (source ../base/bin/activate && mol test) + +clean: + rm -rf ../base diff --git a/defaults/main.yml b/defaults/main.yml index 4dc696c..78ec37e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,3 @@ +--- # Software collections offer latest versions of programming languages collections_enabled: true - -# When collections is enabled this is set for the major versions in tasks/main.yml -# base_git: rh-git218 diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 deleted file mode 100644 index 19692c2..0000000 --- a/molecule/default/Dockerfile.j2 +++ /dev/null @@ -1,14 +0,0 @@ -# Molecule managed - -{% 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 upgrade -y && 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 python2-dnf bash && dnf clean all; \ - elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ - elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \ - elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ - elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst deleted file mode 100644 index 3904805..0000000 --- a/molecule/default/INSTALL.rst +++ /dev/null @@ -1,26 +0,0 @@ -******* -Docker driver installation guide -******* - -Requirements -============ - -* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html) -* Docker Engine -* docker-py -* docker - -Install -======= - -Ansible < 2.6 - -.. code-block:: bash - - $ sudo pip install docker-py - -Ansible >= 2.6 - -.. code-block:: bash - - $ sudo pip install docker diff --git a/molecule/default/playbook.yml b/molecule/default/converge.yml similarity index 100% rename from molecule/default/playbook.yml rename to molecule/default/converge.yml diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index c4ac22c..24b829a 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -4,8 +4,10 @@ dependency: name: galaxy driver: name: docker -lint: - name: yamllint +lint: | + set -e + yamllint . + ansible-lint platforms: - name: base-git-centos7 image: milcom/centos7-systemd @@ -15,17 +17,5 @@ platforms: privileged: true provisioner: name: ansible - config_options: - defaults: - remote_tmp: /tmp - stdout_callback: yaml - playbooks: - converge: playbook.yml - lint: - name: ansible-lint -scenario: - name: default verifier: - name: goss - lint: - name: yamllint + name: ansible diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 421dbfa..73ca547 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -10,7 +10,9 @@ goss_version: v0.3.7 goss_arch: amd64 goss_dst: /usr/local/bin/goss + # yamllint disable-line rule:line-length goss_sha256sum: 357f5c7f2e7949b412bce44349cd32ab19eb3947255a8ac805f884cc2c326059 + # yamllint disable-line rule:line-length goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}" goss_test_directory: /tmp goss_format: tap @@ -29,17 +31,21 @@ copy: src: "{{ item }}" dest: "{{ goss_test_directory }}/{{ item | basename }}" + mode: 0644 with_fileglob: - "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_*.yml" - name: Register test files shell: "ls {{ goss_test_directory }}/test_*.yml" + changed_when: false register: test_files - name: Execute Goss tests environment: + # yamllint disable-line rule:line-length PATH: '/opt/rh/rh-git218/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' command: "{{ goss_dst }} -g {{ item }} validate -f {{ goss_format }}" + changed_when: false register: test_results with_items: "{{ test_files.stdout_lines }}" diff --git a/requirements.txt b/requirements.txt index 814d0e6..0a0489f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,10 @@ -#pyyaml>3.12 +# these python extensions are for testing tox -molecule==2.22 -docker +sh==1.12.14 +molecule +molecule-docker +yamllint +ansible-lint +docker==4.2.2 anyconfig>=0.10.0 # not directly required, pinned by Snyk to avoid a vulnerability + diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 7fabb52..0000000 --- a/tox.ini +++ /dev/null @@ -1,23 +0,0 @@ -[tox] -minversion = 1.8 -envlist = py{36,37}-ansible{28,29} - -skipsdist = true -skip_missing_interpreters = True - -[testenv] -# ansible only supports python3 in versions >= 2.5 -passenv = * -deps = - -rrequirements.txt - ansible28: ansible>=2.8,<2.9 - ansible29: ansible>=2.8,<2.10 -commands = - pip list - molecule dependency - molecule syntax - molecule lint - molecule create - molecule converge - molecule verify - molecule idempotence