53 lines
1.8 KiB
YAML
53 lines
1.8 KiB
YAML
---
|
|
- name: Create configuration dir for {{ ddclient_namespace }}
|
|
file:
|
|
name: "/opt/{{ ddclient_namespace }}"
|
|
state: directory
|
|
|
|
- name: Copy ddclient configuration for {{ ddclient_namespace }}
|
|
copy:
|
|
dest: "/opt/{{ ddclient_namespace }}/ddclient.conf"
|
|
content: "{{ ddclient_conf }}"
|
|
notify: restart podman ddclient
|
|
|
|
- name: Copy Kvps.key for {{ ddclient_namespace }}
|
|
copy:
|
|
dest: "/opt/{{ ddclient_namespace }}/Kvps.key"
|
|
content: "{{ ddclient_tsig_public_key_base64 | b64decode }}"
|
|
notify: restart podman ddclient
|
|
|
|
- name: Copy Kvps.private for {{ ddclient_namespace }}
|
|
copy:
|
|
dest: "/opt/{{ ddclient_namespace }}/Kvps.private"
|
|
content: "{{ ddclient_tsig_private_key_base64 | b64decode }}"
|
|
notify: restart podman ddclient
|
|
|
|
- name: Start ddclient with podman for {{ ddclient_namespace }}
|
|
containers.podman.podman_container:
|
|
name: "{{ ddclient_container_name }}"
|
|
hostname: "{{ ddclient_container_name }}"
|
|
network: "{{ ddclient_network_mode }}"
|
|
image: "{{ ddclient_container_registry }}/{{ ddclient_image_name }}:{{ ddclient_image_tag }}"
|
|
state: present
|
|
volumes:
|
|
- "/opt/{{ ddclient_namespace }}/ddclient.conf:/config/ddclient.conf"
|
|
- "/opt/{{ ddclient_namespace }}/Kvps.key:/config/Kvps.key"
|
|
- "/opt/{{ ddclient_namespace }}/Kvps.private:/config/Kvps.private"
|
|
|
|
- name: Generate container systemd unit
|
|
shell: "podman generate systemd {{ ddclient_container_name }}"
|
|
register: ddclient_systemd_unit
|
|
changed_when: False
|
|
|
|
- name: Create ddclient systemd unit
|
|
copy:
|
|
dest: "/etc/systemd/system/{{ ddclient_systemd_unit_name }}"
|
|
content: "{{ ddclient_systemd_unit.stdout | regex_replace('^#.*', multiline=True) | trim }}"
|
|
|
|
- name: Enable ddclient systemd unit
|
|
ansible.builtin.systemd:
|
|
name: "{{ ddclient_systemd_unit_name }}"
|
|
enabled: yes
|
|
state: started
|
|
daemon_reload: yes
|