diff --git a/README.md b/README.md index 86591dc..21ae7a3 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,22 @@ Install and configure the `acmetool` LE client. * ``submodules_versioncheck:`` (Default: ``false``): Enable basic versionscheck. *(``true`` is recomended)* + + Files +------- +* We search the ``response-file.yml.j2`` using the [first_found_loopup](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/first_found_lookup.html) with the following config: +```yaml + files: + - "response-file.{{ inventory_hostname }}.yml.j2" + - 'response-file.yml.j2' + paths: + - 'templates/acmetool' + - "templates/{{ inventory_hostname }}" + - 'files/acmetool' + - "files/{{ inventory_hostname }}" + - 'templates' +``` + References ------------ diff --git a/tasks/configure.yml b/tasks/configure.yml new file mode 100644 index 0000000..09b855b --- /dev/null +++ b/tasks/configure.yml @@ -0,0 +1,24 @@ +--- +- name: Create directory for acmetool response file + become: true + ansible.builtin.file: + name: '/var/lib/acme/conf' + state: directory + owner: root + group: root + mode: 'u=rwx,g=rx,o=rx' + +- name: Copy acmetool response file + become: true + ansible.builtin.template: + src: "{{ lookup('first_found', acmetool__response_file ) }}" + dest: '/var/lib/acme/conf/responses' + owner: root + group: root + mode: 'u=rw,g=r,o=r' + +- name: Perform acmetool quickstart + become: true + ansible.builtin.command: acmetool quickstart --expert + args: + creates: '/var/lib/acme/conf/target' diff --git a/tasks/hook.yml b/tasks/hook.yml new file mode 100644 index 0000000..8f84a16 --- /dev/null +++ b/tasks/hook.yml @@ -0,0 +1,10 @@ +--- +- name: Copy hook to enable acmetool to restart services + become: true + ansible.builtin.copy: + src: 'files/restart' + dest: '/etc/acme/hooks/' + owner: root + group: root + mode: 'u=rx,g=rx,o=rx' + diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..ea3f030 --- /dev/null +++ b/tasks/install.yml @@ -0,0 +1,6 @@ +--- +- name: Install acmetool + become: true + ansible.builtin.package: + name: 'acmetool' + state: present diff --git a/tasks/main.yml b/tasks/main.yml index 90b50c2..55b650a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,70 +3,15 @@ ansible.builtin.include_tasks: versioncheck.yml when: submodules_versioncheck|bool -- name: Install acmetool - become: true - ansible.builtin.package: - name: 'acmetool' - state: present - tags: - - installation - - acmetool +- name: install acmetool + ansible.builtin.include_tasks: install.yml -- name: Create directory for acmetool response file - become: true - ansible.builtin.file: - name: '/var/lib/acme/conf' - state: directory - owner: root - group: root - mode: 'u=rwx,g=rx,o=rx' - tags: - - installation - - acmetool - -- name: Copy acmetool response file - become: true - ansible.builtin.template: - src: 'files/response-file.yml.j2' - dest: '/var/lib/acme/conf/responses' - owner: root - group: root - mode: 'u=rw,g=r,o=r' - tags: - - configuration - - acmetool - # Todo: with_first_found? - # consider usage of loop: - -- name: Perform acmetool quickstart - become: true - ansible.builtin.command: acmetool quickstart --expert - args: - creates: '/var/lib/acme/conf/target' - tags: - - configuration - - operation - - acmetool +- name: configure acmetool + ansible.builtin.include_tasks: configure.yml - name: Copy hook to enable acmetool to restart services - become: true - ansible.builtin.copy: - src: 'files/restart' - dest: '/etc/acme/hooks/' - owner: root - group: root - mode: 'u=rx,g=rx,o=rx' - tags: - - configuration - - acmetool + ansible.builtin.include_tasks: hook.yml - name: Reload systemd and enable acmetool timer unit - become: true - ansible.builtin.systemd: - name: 'acmetool.timer' - daemon_reload: true - enabled: true - state: started - tags: - - operation - - acmetool + ansible.builtin.include_tasks: timer.yml + diff --git a/tasks/timer.yml b/tasks/timer.yml new file mode 100644 index 0000000..95a2b15 --- /dev/null +++ b/tasks/timer.yml @@ -0,0 +1,8 @@ +--- +- name: Reload systemd and enable acmetool timer unit + become: true + ansible.builtin.systemd: + name: 'acmetool.timer' + daemon_reload: true + enabled: true + state: started diff --git a/files/response-file.yml.j2 b/templates/response-file.yml.j2 similarity index 100% rename from files/response-file.yml.j2 rename to templates/response-file.yml.j2 diff --git a/vars/main.yml b/vars/main.yml index 73deca1..060cdee 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,4 +1,15 @@ --- +acmetool__response_file: + files: + - "response-file.{{ inventory_hostname }}.yml.j2" + - 'response-file.yml.j2' + paths: + - 'templates/acmetool' + - "templates/{{ inventory_hostname }}" + - 'files/acmetool' + - "files/{{ inventory_hostname }}" + - 'templates' + # versionscheck -playbook_version_number: 25 # should be a integer +playbook_version_number: 26 # should be a integer playbook_version_path: 'do1jlr.role-acmetool.version'