From 430faad434cca2fd619cf1ec8733bffff63e04c5 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Thu, 24 Jun 2021 12:31:33 +0200 Subject: [PATCH 1/2] Make use of github actions --- .ansible-lint | 3 ++ .github/workflows/ci.yml | 81 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 20 +++++++++ .travis.yml | 81 ----------------------------------- .yamllint | 15 +++++++ README.md | 2 +- Vagrantfile | 33 ++++++-------- meta/main.yml | 5 +-- molecule/default/converge.yml | 9 ++++ molecule/default/molecule.yml | 19 ++++++++ molecule/default/prepare.yml | 9 ++++ molecule/default/verify.yml | 5 +++ tests/tasks/pre.yml | 5 +++ tests/test.yml | 11 +++-- tests/vagrant.yml | 11 +++-- tests/vars/main.yml | 7 +++ 16 files changed, 199 insertions(+), 117 deletions(-) create mode 100644 .ansible-lint create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml create mode 100644 .yamllint create mode 100644 molecule/default/converge.yml create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/prepare.yml create mode 100644 molecule/default/verify.yml create mode 100644 tests/tasks/pre.yml create mode 100644 tests/vars/main.yml diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..148ddda --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,3 @@ +--- +warn_list: + - '106' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..28658f5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,81 @@ +--- +name: CI +'on': + pull_request: + push: + branches: + - master + schedule: + - cron: '30 1 * * 3' + +jobs: + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies + run: pip install ansible-lint[community,yamllint] + + - name: Lint code + run: | + yamllint . + ansible-lint + + molecule: + name: Molecule + runs-on: ubuntu-latest + defaults: + run: + working-directory: "${{ github.repository }}" + needs: + - lint + strategy: + fail-fast: false + matrix: + include: + - distro: debian8 + ansible-version: '<2.10' + - distro: debian9 + - distro: debian10 + - distro: ubuntu1604 + ansible-version: '>=2.8, <2.9' + - distro: ubuntu1604 + ansible-version: '>=2.9, <2.10' + - distro: ubuntu1604 + ansible-version: '>=2.10, <2.11' + - distro: ubuntu1604 + - distro: ubuntu1804 + - distro: ubuntu2004 + + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + with: + path: "${{ github.repository }}" + + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install test dependencies + run: pip install 'ansible${{ matrix.ansible-version }}' molecule[docker] docker + + - name: Run Molecule tests + run: | + molecule test + env: + ANSIBLE_FORCE_COLOR: '1' + ANSIBLE_VERBOSITY: '2' + MOLECULE_DEBUG: '1' + MOLECULE_DISTRO: "${{ matrix.distro }}" + PY_COLORS: '1' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..2354e68 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +--- +name: Release +'on': + push: + tags: + - '*' + +jobs: + + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Check out the codebase + uses: actions/checkout@v2 + + - name: Publish to Galaxy + uses: robertdebock/galaxy-action@1.1.0 + with: + galaxy_api_key: ${{ secrets.GALAXY_API_KEY }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7b640b9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -sudo: required -dist: xenial - -language: python -python: - - "2.7" - - "3.5" - -env: - - ANSIBLE_VERSION=latest - - ANSIBLE_VERSION=2.10.2 - - ANSIBLE_VERSION=2.10.1 - - ANSIBLE_VERSION=2.10.0 - - ANSIBLE_VERSION=2.9.14 - - ANSIBLE_VERSION=2.9.13 - - ANSIBLE_VERSION=2.9.12 - - ANSIBLE_VERSION=2.9.11 - - ANSIBLE_VERSION=2.9.10 - - ANSIBLE_VERSION=2.9.9 - - ANSIBLE_VERSION=2.9.8 - - ANSIBLE_VERSION=2.9.7 - - ANSIBLE_VERSION=2.9.6 - - ANSIBLE_VERSION=2.9.5 - - ANSIBLE_VERSION=2.9.4 - - ANSIBLE_VERSION=2.9.3 - - ANSIBLE_VERSION=2.9.2 - - ANSIBLE_VERSION=2.9.1 - - ANSIBLE_VERSION=2.9.0 - - ANSIBLE_VERSION=2.8.16 - - ANSIBLE_VERSION=2.8.15 - - ANSIBLE_VERSION=2.8.14 - - ANSIBLE_VERSION=2.8.13 - - ANSIBLE_VERSION=2.8.12 - - ANSIBLE_VERSION=2.8.11 - - ANSIBLE_VERSION=2.8.10 - - ANSIBLE_VERSION=2.8.9 - - ANSIBLE_VERSION=2.8.8 - - ANSIBLE_VERSION=2.8.7 - - ANSIBLE_VERSION=2.8.6 - - ANSIBLE_VERSION=2.8.5 - - ANSIBLE_VERSION=2.8.4 - - ANSIBLE_VERSION=2.8.3 - - ANSIBLE_VERSION=2.8.2 - - ANSIBLE_VERSION=2.8.1 - - ANSIBLE_VERSION=2.8.0 - -branches: - only: - - master - -before_install: - - sudo apt-get update -qq - -install: - # Install Ansible. - - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi - - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible-lint; fi - -script: - # Check the role/playbook's syntax. - - ansible-playbook -i tests/inventory tests/test.yml --syntax-check - - # Run the role/playbook with ansible-playbook. - - ansible-playbook -i tests/inventory tests/test.yml -vvvv - - # Run the role/playbook again, checking to make sure it's idempotent. - - > - ansible-playbook -i tests/inventory tests/test.yml - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - - if [ "$ANSIBLE_VERSION" = "latest" ]; then ansible-lint tests/test.yml; fi - -notifications: - email: false - webhooks: https://galaxy.ansible.com/api/v1/notifications/ - slack: - rooms: - secure: "N8MhyAokJYitgxLSWHqO3mb7KhF7x3oa/yEAp7Z4ClXGp4hVEA2HpVDUPS+16HV51dTxL7bFLeOOuXH4kzLkDI8XskhVbViXGN76cHoNJe6+eKJMiyjddzApHalWmKMrLYQM3TKRZYkiEJWixMhZZL3buteSNMmVMmbv0y2rFd6fnDMTrypLiN+JkOcnfPPnUh0CSVxv4Rp5PRMVb78znkudsba0GqUWoAmF4rW9LefBk5anN5dX3D0w1jZLUqaVCGrpDqqqWBOQzusJy7E9l9HteaE7K8/clwUpGi8+GYlhZrpcJD6yJW7mcTmZPbSXh0Jxbp0WvH+WjiziDhPgP5Wba2Jfetb9tEla7hAHBKmn5sZ7tX3CJ+Lq5kl6h1zJBSn8OhBOfdIcAzLHlj5I0AAXvi9blp/x8Wg4ejfNOcSWw9d/NUdcBGLS1n0GhHv/CO6By4pit0m3ay10I+9Oj0+sTU1GOpAA9p0z91RMtAvRAhIjtt4x8jIgxw8qeOcgOZFdV5RuLewUqCcU0lrlFTsTMNABife4CjGzELpbSeMjBdHOLi1EEkOzfNuWrA4QQdbFS6+miifeMdEuF00ISk472p4h7Y0S/zPmR2fIs//4sPwgEkJ0XcoPCW4SVsSgRjZpLQpgBZuewazQ4iNmUUHE+MtrykvI26o5CYOLGTU=" diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..894450c --- /dev/null +++ b/.yamllint @@ -0,0 +1,15 @@ +--- +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable + +ignore: | + .tox/ diff --git a/README.md b/README.md index df21f4a..db762ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## sudoers -[![Build Status](https://travis-ci.org/Oefenweb/ansible-sudoers.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-sudoers) +[![CI](https://github.com/Oefenweb/ansible-sudoers/workflows/CI/badge.svg)](https://github.com/Oefenweb/ansible-sudoers/actions?query=workflow%3ACI) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-sudoers-blue.svg)](https://galaxy.ansible.com/Oefenweb/sudoers) Manage sudoers and sudoers.d in Debian-like systems. diff --git a/Vagrantfile b/Vagrantfile index 653c851..a0182a0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,40 +4,26 @@ role = File.basename(File.expand_path(File.dirname(__FILE__))) boxes = [ - { - :name => "ubuntu-1204", - :box => "bento/ubuntu-12.04", - :ip => '10.0.0.11', - :cpu => "50", - :ram => "256" - }, - { - :name => "ubuntu-1404", - :box => "bento/ubuntu-14.04", - :ip => '10.0.0.12', - :cpu => "50", - :ram => "256" - }, { :name => "ubuntu-1604", :box => "bento/ubuntu-16.04", - :ip => '10.0.0.13', + :ip => '10.0.0.12', :cpu => "50", :ram => "256" }, { :name => "ubuntu-1804", :box => "bento/ubuntu-18.04", - :ip => '10.0.0.14', + :ip => '10.0.0.13', :cpu => "50", :ram => "384" }, { - :name => "debian-7", - :box => "bento/debian-7", - :ip => '10.0.0.15', + :name => "ubuntu-2004", + :box => "bento/ubuntu-20.04", + :ip => '10.0.0.14', :cpu => "50", - :ram => "256" + :ram => "384" }, { :name => "debian-8", @@ -53,6 +39,13 @@ boxes = [ :cpu => "50", :ram => "256" }, + { + :name => "debian-10", + :box => "bento/debian-10", + :ip => '10.0.0.18', + :cpu => "50", + :ram => "256" + }, ] Vagrant.configure("2") do |config| diff --git a/meta/main.yml b/meta/main.yml index 53b0bd4..4fb9c74 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -11,15 +11,14 @@ galaxy_info: platforms: - name: Ubuntu versions: - - precise - - trusty - xenial - bionic + - focal - name: Debian versions: - - wheezy - jessie - stretch + - buster galaxy_tags: - system - monitoring diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..73043c4 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,9 @@ +--- +- name: Converge + hosts: all + become: true + pre_tasks: + - name: include vars + include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml" + roles: + - ../../../ diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..fbb7120 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,19 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1604}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: true + pre_build_image: true +provisioner: + name: ansible + playbooks: + prepare: prepare.yml + converge: converge.yml + verify: verify.yml diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..bb63e11 --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,9 @@ +--- +- name: Prepare + hosts: all + become: true + tasks: + - name: include vars + include_vars: "{{ playbook_dir }}/../../tests/vars/main.yml" + - name: include tasks + include: "{{ playbook_dir }}/../../tests/tasks/pre.yml" diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..44debad --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,5 @@ +--- +- name: Verify + hosts: all + become: true + tasks: [] diff --git a/tests/tasks/pre.yml b/tests/tasks/pre.yml new file mode 100644 index 0000000..0dd2a59 --- /dev/null +++ b/tests/tasks/pre.yml @@ -0,0 +1,5 @@ +# pre test file +--- +- name: create user (if needed) + user: + name: dummy diff --git a/tests/test.yml b/tests/test.yml index 449e3a9..d3837dc 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -3,11 +3,10 @@ - hosts: localhost connection: local become: true + pre_tasks: + - name: include vars + include_vars: "{{ playbook_dir }}/vars/main.yml" + - name: include tasks + include: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ - vars: - sudoers_sudoers_d_files: - travis: - privileges: - - name: travis - entry: 'ALL=NOPASSWD:ALL' diff --git a/tests/vagrant.yml b/tests/vagrant.yml index e1482aa..dce3560 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -3,11 +3,10 @@ - hosts: all remote_user: vagrant become: true + pre_tasks: + - name: include vars + include_vars: "{{ playbook_dir }}/vars/main.yml" + - name: include tasks + include: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ - vars: - sudoers_sudoers_d_files: - vagrant: - privileges: - - name: vagrant - entry: 'ALL=(ALL) NOPASSWD:ALL' diff --git a/tests/vars/main.yml b/tests/vars/main.yml new file mode 100644 index 0000000..f170d00 --- /dev/null +++ b/tests/vars/main.yml @@ -0,0 +1,7 @@ +# vars file +--- +sudoers_sudoers_d_files: + dummy: + privileges: + - name: dummy + entry: 'ALL=NOPASSWD:ALL' From 5bafeaa0af1e5dd05b6f3943f6fe3d5317e56b5d Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Thu, 24 Jun 2021 12:39:59 +0200 Subject: [PATCH 2/2] Cleanup --- defaults/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index e239980..9149fff 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,4 +5,3 @@ sudoers_sudoers: privileges: "{{ sudoers_sudoers_preset_privileges }}" sudoers_sudoers_d_files: {} -#sudoers_sudoers_d_directory_mode: '0750'