You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.4 KiB
89 lines
2.4 KiB
2 years ago
|
- name: determine host architecture
|
||
|
include_tasks: tasks/get_host_arch.yml
|
||
|
|
||
|
|
||
|
- name: create acme-client directory
|
||
|
file:
|
||
|
path: "{{ item }}"
|
||
|
state: directory
|
||
|
mode: 0700
|
||
|
owner: "{{ caddy_user }}"
|
||
|
group: "{{ caddy_group }}"
|
||
|
loop:
|
||
|
- "{{ caddy_acmedns_client_bin_dir }}"
|
||
|
- "{{ caddy_acmedns_client_dir }}"
|
||
|
|
||
|
|
||
|
- name: get and extract latest acme-dns-client version
|
||
|
include_tasks: tasks/get_lastversion.yml
|
||
|
vars:
|
||
|
package:
|
||
|
name: acme-dns/acme-dns-client
|
||
|
location: github
|
||
|
assets: yes
|
||
|
asset_filter: "{{ 'linux_' ~ host_architecture ~ '.tar.gz$' }}"
|
||
|
file: "{{ (caddy_acmedns_client_bin_dir, 'last_acme_client_version') | path_join }}"
|
||
|
extract: "{{ caddy_acmedns_client_bin_dir }}"
|
||
|
user: "{{ caddy_user }}"
|
||
|
group: "{{ caddy_group }}"
|
||
|
|
||
|
|
||
|
- name: ensure acme-dns-client binary has executable bit set
|
||
|
file:
|
||
|
path: "{{ (caddy_acmedns_client_bin_dir, 'acme-dns-client') | path_join }}"
|
||
|
mode: "+x"
|
||
|
|
||
|
|
||
|
- block:
|
||
|
- name: remove unnecessary files
|
||
|
file:
|
||
|
path: "{{ (caddy_acmedns_client_bin_dir, item) | path_join }}"
|
||
|
state: absent
|
||
|
loop:
|
||
|
- LICENSE
|
||
|
- README.md
|
||
|
rescue:
|
||
|
- meta: noop
|
||
|
|
||
|
|
||
|
- name: clear acme-dns-client domain fact
|
||
|
set_fact:
|
||
|
acmedns_current_domains: "{{ [] }}"
|
||
|
|
||
|
|
||
|
- name: check if acme-dns-client config exists
|
||
|
stat:
|
||
|
path: "{{ caddy_acmedns_client_file }}"
|
||
|
get_checksum: no
|
||
|
get_attributes: no
|
||
|
get_mime: no
|
||
|
register: result
|
||
|
|
||
|
|
||
|
- block:
|
||
|
- name: get acme-dns-client config file
|
||
|
slurp:
|
||
|
path: "{{ caddy_acmedns_client_file }}"
|
||
|
register: file_content
|
||
|
|
||
|
- name: set acme-dns-client domain fact
|
||
|
set_fact:
|
||
|
acmedns_current_domains: "{{ file_content.content | b64decode | from_json | dict2items | map(attribute='key') | list }}"
|
||
|
|
||
|
when: result.stat.exists
|
||
|
no_log: yes
|
||
|
|
||
|
|
||
|
- name: show domain information
|
||
|
debug:
|
||
|
msg: |
|
||
|
acme-dns-client currently manages these FQDNs: {{ '(none)' if acmedns_current_domains | length == 0 else acmedns_current_domains | join(', ') }}
|
||
|
acme-dns-client does not yet manage these FQDNs: {{ caddy_domains | difference(acmedns_current_domains) | join(', ') }}
|
||
|
|
||
|
|
||
|
- name: register a record with acme-dns-client for each unmanaged domain
|
||
|
include_tasks: register_acme_domain.yml
|
||
|
vars:
|
||
|
domain: "{{ item }}"
|
||
|
loop: "{{ caddy_domains | difference(acmedns_current_domains) }}"
|