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..e8a0475 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,80 @@ +--- +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 + - 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 6851d1d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,84 +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 - - # Remove ca-certificates - - sudo apt-get remove --purge --yes ca-certificates - -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: "Qni7D2jFXODmAyUWJiBbP6wJuOwmMmdud+uB6KoFZ8aP5YRtAC9TL1kmWUfGZcg+kUlzyRzazGXCSLSG+V7ajqflAGdOjqeLCG9yigbdKUg88FOBtMVSwtflFTHkQt9XUO4cek/DXR6ujBAkXqN1r6laJ9ipY8AJanbi/1VvKvPCBdLaUFbM7pVeHfEl7qWsNOu8w2D4pGPKmBVQeDXxXf4O5RyCqcBVQ8h5YRLhK1e+N/2TrUHKLOT8hc3gTYE+TDQraiSvNSYWWvR8ZGV4jKB1L0Ua+sxEosQ1O7mtSAhUlpnrKtY5hqe54RUHtviC+JmDWkQxTtC4CS8Vixqy9LVGJALUbkQzZNYm+wFi/ampQMK18A3qtFf/so+MZ5RHBOuHWMc4xDNl8rx/McK1jdLCZIvZ7JSkmAINQ92ih/ekzrPoe5fT5XNDMw+O6jj5Bsqk/MZi4xr4+VhLsutfkGQ+zguLvFIqGXu0cKbmJvByaqV3dc5110I0w+4NZF0kfae+RLEFjKkqwLT7homIvSPRv9E0KmOAHOoSbekZXRGIo3kfHNzek8GenkogLjMdpTX814KWJXv4WKkwDAdbTm7JIyR9JIDmoxg0HlYqaGiU+WHeBnEhzgXCGmKDwb9OF5CLGurj2KOl4HOQHAtg+NNZZDttR5n1fxpLq5ftfKk=" 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 45a3564..7629684 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## ca-certificates -[![Build Status](https://travis-ci.org/Oefenweb/ansible-ca-certificates.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-ca-certificates) -[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-ca--certificates-blue.svg)](https://galaxy.ansible.com/Oefenweb/ansible-ca-certificates) +[![CI](https://github.com/Oefenweb/ansible-ca-certificates/workflows/CI/badge.svg)](https://github.com/Oefenweb/ansible-ca-certificates/actions?query=workflow%3ACI) +[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-ca--certificates-blue.svg)](https://galaxy.ansible.com/Oefenweb/ca_certificates) Manage ca-certificates in Debian-like systems. diff --git a/Vagrantfile b/Vagrantfile index 3517233..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", diff --git a/meta/main.yml b/meta/main.yml index f5ebb0d..97ef25a 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -2,7 +2,7 @@ --- galaxy_info: namespace: oefenweb - role_name: ca-certificates + role_name: ca_certificates author: Mischa ter Smitten company: Oefenweb.nl B.V. description: Manage ca-certificates in Debian-like systems @@ -11,13 +11,11 @@ galaxy_info: platforms: - name: Ubuntu versions: - - precise - - trusty - xenial - bionic + - focal - name: Debian versions: - - wheezy - jessie - stretch - buster diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..be762b2 --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,6 @@ +--- +- name: Converge + hosts: all + become: true + 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..9a6673d --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + become: true + tasks: [] 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/pre.yml b/tests/pre.yml deleted file mode 100644 index 3ba83a3..0000000 --- a/tests/pre.yml +++ /dev/null @@ -1,29 +0,0 @@ -# pre test file ---- -- name: pre | install dependencies - apt: - name: - - openssl - state: "{{ apt_install_state | default('latest') }}" - update_cache: true - cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" - -- name: pre | generate key - command: > - openssl genrsa -out {{ playbook_dir }}/../files/ca-oefenweb-nl.key 2048; - args: - creates: "{{ playbook_dir }}/../files/ca-oefenweb-nl.key" - become: false - -- name: pre | generate crt - shell: > - openssl req \ - -subj '/C=NL/ST=NH/L=Amsterdam/O=Oefenweb.nl B.V./OU=Systeembeheer/CN=oefenweb.nl/emailAddress=root@oefenweb.nl/' \ - -x509 -new -nodes \ - -key {{ playbook_dir }}/../files/ca-oefenweb-nl.key \ - -days 1 \ - -out {{ playbook_dir }}/../files/ca-oefenweb-nl.crt \ - ; - args: - creates: "{{ playbook_dir }}/../files/ca-oefenweb-nl.crt" - become: false diff --git a/tests/tasks/pre.yml b/tests/tasks/pre.yml new file mode 100644 index 0000000..701f7fa --- /dev/null +++ b/tests/tasks/pre.yml @@ -0,0 +1,32 @@ +# pre test file +--- +- name: install dependencies + apt: + name: + - openssl + state: "{{ apt_install_state | default('latest') }}" + update_cache: true + cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" + +- block: + + - name: generate key + command: > + openssl genrsa -out {{ ca_certificates_certificate_key_file }} 2048; + args: + creates: "{{ ca_certificates_certificate_key_file }}" + + - name: generate crt + shell: > + openssl req \ + -subj '/C=NL/ST=NH/L=Amsterdam/O=Oefenweb.nl B.V./OU=Systeembeheer/CN=oefenweb.nl/emailAddress=root@oefenweb.nl/' \ + -x509 -new -nodes \ + -key {{ ca_certificates_certificate_key_file }} \ + -days 1 \ + -out {{ ca_certificates_certificate_crt_file }} \ + ; + args: + creates: "{{ ca_certificates_certificate_crt_file }}" + + connection: local + become: false diff --git a/tests/test.yml b/tests/test.yml index 2c5781b..d3837dc 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -5,7 +5,8 @@ become: true pre_tasks: - name: include vars - include_vars: main.yml - - import_tasks: pre.yml + include_vars: "{{ playbook_dir }}/vars/main.yml" + - name: include tasks + include: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ diff --git a/tests/vagrant.yml b/tests/vagrant.yml index c64c0c1..dce3560 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -5,7 +5,8 @@ become: true pre_tasks: - name: include vars - include_vars: main.yml - - import_tasks: pre.yml + include_vars: "{{ playbook_dir }}/vars/main.yml" + - name: include tasks + include: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ diff --git a/tests/vars/main.yml b/tests/vars/main.yml index 2df2f57..c2fd962 100644 --- a/tests/vars/main.yml +++ b/tests/vars/main.yml @@ -1,5 +1,10 @@ # vars file --- ca_certificates_certificate_map: - - src: ca-oefenweb-nl.crt + - src: "{{ ca_certificates_certificate_crt_file | basename }}" dest: oefenweb/Oefenweb_nl-B_V.crt + +ca_certificates_certificate_directory: "{{ playbook_dir }}/../files" +ca_certificates_certificate_file: "{{ ca_certificates_certificate_directory }}/ca-oefenweb-nl" +ca_certificates_certificate_key_file: "{{ ca_certificates_certificate_file }}.key" +ca_certificates_certificate_crt_file: "{{ ca_certificates_certificate_file }}.crt"