From 5693b494a5f0a77fcc7aad7208b76923b1ad691a Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 20 Mar 2021 17:59:44 +0100 Subject: [PATCH 1/4] update metadata --- readme.md => README.md | 0 defaults/main.yml | 4 +++- meta/main.yml | 19 +++++++++++++++++ tasks/main.yml | 10 +++------ tasks/versioncheck.yml | 46 ++++++++++++++++++++++++++++++++++++++++++ vars/main.yml | 4 ++++ 6 files changed, 75 insertions(+), 8 deletions(-) rename readme.md => README.md (100%) create mode 100644 meta/main.yml create mode 100644 tasks/versioncheck.yml create mode 100644 vars/main.yml diff --git a/readme.md b/README.md similarity index 100% rename from readme.md rename to README.md diff --git a/defaults/main.yml b/defaults/main.yml index 6016495..91e6aa6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,5 @@ --- - acme_notification_email: 'root@example.org' + +# should we do a version check? (recomended) +submodules_versioncheck: false diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..a01c393 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,19 @@ +--- +galaxy_info: + role_name: acmetool + author: do1jlr + description: Install acmetool and get it working together with the do1jlr.nginx role. + license: "MIT" + min_ansible_version: 2.8 + github_branch: main + platforms: + - name: Debian + versions: all + - name: Ubuntu + versions: all + galaxy_tags: + - acmetool + - acmetool + - letsencrypt + - web +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml index 4730b3d..b210303 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,6 @@ --- +- ansible.builtin.include_tasks: versioncheck.yml + when: submodules_versioncheck|bool - name: Install acmetool ansible.builtin.package: @@ -8,7 +10,6 @@ - installation - acmetool - # Todo: Reconsider best practice #- name: Remove acmetool snippet for nginx from package installation # ansible.builtin.file: @@ -19,7 +20,6 @@ # - configuration # - acmetool - - name: Create directory for acmetool response file ansible.builtin.file: name: '/var/lib/acme/conf' @@ -31,7 +31,6 @@ - installation - acmetool - - name: Copy acmetool response file ansible.builtin.template: src: 'files/response-file.yml.j2' @@ -42,10 +41,9 @@ tags: - configuration - acmetool - # Todo: with_first_found? + # Todo: with_first_found? # consider usage of loop: - - name: Perform acmetool quickstart ansible.builtin.command: acmetool quickstart --expert args: @@ -55,7 +53,6 @@ - operation - acmetool - - name: Copy hook to enable acmetool to restart services ansible.builtin.copy: src: 'files/restart' @@ -67,7 +64,6 @@ - configuration - acmetool - - name: Reload systemd and enable acmetool timer unit ansible.builtin.systemd: name: 'acmetool.timer' diff --git a/tasks/versioncheck.yml b/tasks/versioncheck.yml new file mode 100644 index 0000000..dca3e47 --- /dev/null +++ b/tasks/versioncheck.yml @@ -0,0 +1,46 @@ +--- +- name: Create directory for versionscheck + become: true + ansible.builtin.file: + path: '/etc/.ansible-version' + state: directory + mode: 0755 + when: submodules_versioncheck|bool + +- name: check playbook version + become: true + ansible.builtin.slurp: + src: "/etc/.ansible-version/{{ playbook_version_path }}" + register: playbook_version + when: submodules_versioncheck|bool + ignore_errors: true + failed_when: false + +- name: Print remote role version + ansible.builtin.debug: + msg: "Remote role version: {{ playbook_version.content | default('Y3VycmVudGx5IG5vdCBkZXBsb3llZAo=') | b64decode | string }}" + when: submodules_versioncheck|bool + +- name: Print locale role version + ansible.builtin.debug: + msg: "Local role version: '{{ playbook_version_number|string }}'." + when: submodules_versioncheck|bool + +- name: Check if your version is outdated + ansible.builtin.fail: + msg: "Your ansible module has the version '{{ playbook_version_number }}' and is outdated. You need to update it!" + when: + - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck|bool + +- name: check if '/etc/ansible-version/' is empty + ansible.builtin.find: + paths: '/etc/ansible-version/' + register: filesFound + +- name: write new version to remote disk + become: true + ansible.builtin.copy: + content: "{{ playbook_version_number }}" + dest: "/etc/.ansible-version/{{ playbook_version_path }}" + mode: '0644' + when: submodules_versioncheck|bool diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..65032cc --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,4 @@ +--- +# versionscheck +playbook_version_number: 23 # should be a integer +playbook_version_path: 'do1jlr.role-acmetool.version' From b59697a8c5316800a8b75c0a69965eae9dd313ad Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 20 Mar 2021 18:24:09 +0100 Subject: [PATCH 2/4] Update README and add some icons --- .github/FUNDING.yml | 4 + .github/galaxy.svg | 89 ++++++++++++++++++ .github/license.svg | 217 ++++++++++++++++++++++++++++++++++++++++++++ README.md | 12 ++- 4 files changed, 318 insertions(+), 4 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/galaxy.svg create mode 100644 .github/license.svg diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..67818dd --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +--- + +github: [do1jlr] +liberapay: L3D diff --git a/.github/galaxy.svg b/.github/galaxy.svg new file mode 100644 index 0000000..5647908 --- /dev/null +++ b/.github/galaxy.svg @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.github/license.svg b/.github/license.svg new file mode 100644 index 0000000..4ab6d9a --- /dev/null +++ b/.github/license.svg @@ -0,0 +1,217 @@ + + + + + + image/svg+xml + + + + + + 3D <l3d@c3woc.de> + + + + + MIT License + + + + + + + + + + + + + + + + + + + + + + + + + + + MIT + MIT + + + license + license + + diff --git a/README.md b/README.md index e036f2e..0da4cab 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,19 @@ -Acmetool LE client +[![Ansible Galaxy](https://raw.githubusercontent.com/roles-ansible/ansible_role_acmetool/main/.github/galaxy.svg?sanitize=true)](https://galaxy.ansible.com/do1jlr/acmetool) [![MIT License](https://raw.githubusercontent.com/roles-ansible/ansible_role_acmetool/main/.github/license.svg?sanitize=true)](https://github.com/roles-ansible/ansible_role_acmetool/blob/main/LICENSE) + + Acmetool LE client ================== Install and configure the `acmetool` LE client. -Variables ---------- + Variables +----------- -* `acme_notification_email` (Default `root@example.org`): +* ``acme_notification_email:`` (Default: ``root@example.org``): LE account email. The default needs to be changed! +* ``submodules_versioncheck:`` (Default: ``false``): + Enable basic versionscheck. *(``true`` is recomended)* References ---------- From d6f358292630f21ea8e5609cb65827db068e2efa Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 20 Mar 2021 18:25:46 +0100 Subject: [PATCH 3/4] add some basic github actions --- .github/workflows/ansible-linting-check.yml | 28 +++++++++++++++++++++ .github/workflows/galaxy.yml | 20 +++++++++++++++ .github/workflows/yamllint.yaml | 24 ++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .github/workflows/ansible-linting-check.yml create mode 100644 .github/workflows/galaxy.yml create mode 100644 .github/workflows/yamllint.yaml diff --git a/.github/workflows/ansible-linting-check.yml b/.github/workflows/ansible-linting-check.yml new file mode 100644 index 0000000..b74a2a2 --- /dev/null +++ b/.github/workflows/ansible-linting-check.yml @@ -0,0 +1,28 @@ +--- +name: Ansible Lint check + +# yamllint disable-line rule:truthy +on: + push: + branches: '*' + pull_request: + branches: '*' + schedule: + - cron: '42 6 * 2,4,6,8,10,12 *' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Lint Ansible Playbook + uses: ansible/ansible-lint-action@master + with: + targets: "." + # [required] + # Paths to ansible files (i.e., playbooks, tasks, handlers etc..) + args: "" + # [optional] diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml new file mode 100644 index 0000000..b5dc0ec --- /dev/null +++ b/.github/workflows/galaxy.yml @@ -0,0 +1,20 @@ +--- +name: Galaxy release + +# yamllint disable-line rule:truthy +on: + push: + branches: ['main'] + release: + types: ['created'] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: galaxy + uses: robertdebock/galaxy-action@1.1.0 + with: + galaxy_api_key: ${{ secrets.galaxy_api_key }} diff --git a/.github/workflows/yamllint.yaml b/.github/workflows/yamllint.yaml new file mode 100644 index 0000000..d474e8b --- /dev/null +++ b/.github/workflows/yamllint.yaml @@ -0,0 +1,24 @@ +--- +name: 'Yamllint GitHub Actions' + +# yamllint disable-line rule:truthy +on: + push: + branches: '*' + pull_request: + branches: '*' + schedule: + - cron: '23 6 * 3,6,9,12 *' + +jobs: + yamllint: + name: 'Yamllint' + runs-on: ubuntu-latest + steps: + - name: 'Checkout' + uses: actions/checkout@master + - name: 'Yamllint' + uses: karancode/yamllint-github-action@master + with: + yamllint_file_or_dir: '.' + yamllint_config_filepath: './.yamllint' From d56af65fc1d5b79386ad0b92e8560c0768de1834 Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 20 Mar 2021 18:28:29 +0100 Subject: [PATCH 4/4] repair linting --- .gitignore | 1 + .yamllint | 8 ++++++++ tasks/main.yml | 17 ++++------------- 3 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 .yamllint diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..16d3c4d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.cache diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..c8bbc93 --- /dev/null +++ b/.yamllint @@ -0,0 +1,8 @@ +--- +extends: default + +rules: + # 160 chars should be enough, but don't fail if a line is longer + line-length: + max: 160 + level: warning diff --git a/tasks/main.yml b/tasks/main.yml index b210303..b439519 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,6 @@ --- -- ansible.builtin.include_tasks: versioncheck.yml +- name: Perform optional versionscheck + ansible.builtin.include_tasks: versioncheck.yml when: submodules_versioncheck|bool - name: Install acmetool @@ -10,16 +11,6 @@ - installation - acmetool -# Todo: Reconsider best practice -#- name: Remove acmetool snippet for nginx from package installation -# ansible.builtin.file: -# path: '/etc/nginx/snippets/acmetool.conf' -# state: absent -# tags: -# - installation -# - configuration -# - acmetool - - name: Create directory for acmetool response file ansible.builtin.file: name: '/var/lib/acme/conf' @@ -67,8 +58,8 @@ - name: Reload systemd and enable acmetool timer unit ansible.builtin.systemd: name: 'acmetool.timer' - daemon_reload: yes - enabled: yes + daemon_reload: true + enabled: true state: started tags: - operation