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'