1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_acmetool.git synced 2024-08-16 12:29:49 +02:00

improve acmetool

This commit is contained in:
L3D 2021-07-16 01:19:30 +02:00
parent b29d4abc86
commit a613fc7f8a
Signed by: l3d
GPG key ID: CD08445BFF4313D1
8 changed files with 83 additions and 63 deletions

View file

@ -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
------------

24
tasks/configure.yml Normal file
View file

@ -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'

10
tasks/hook.yml Normal file
View file

@ -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'

6
tasks/install.yml Normal file
View file

@ -0,0 +1,6 @@
---
- name: Install acmetool
become: true
ansible.builtin.package:
name: 'acmetool'
state: present

View file

@ -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

8
tasks/timer.yml Normal file
View file

@ -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

View file

@ -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'