ansible-nas/roles/cloudflare_ddns/tasks/main.yml

39 lines
1.3 KiB
YAML
Raw Normal View History

2021-01-20 10:58:11 +00:00
---
- name: Start Cloudflare DDNS
2022-08-28 17:45:41 +00:00
block:
- name: Check for deprecated API key
fail:
msg: "Using a Cloudflare global API key is no longer supported. Please unset cloudflare_api_key and set cloudflare_token"
when: cloudflare_api_key is defined
2021-01-20 10:58:11 +00:00
- name: Create cloudflare Dynamic DNS Directories
file:
path: "{{ cloudflare_data_directory }}"
state: directory
2021-01-20 10:58:11 +00:00
- name: Template Cloudflare Dynamic DNS config.yml with scoped token
template:
src: config.yml
dest: "{{ cloudflare_data_directory }}/config.yml"
register: template_files_result
2021-01-20 10:58:11 +00:00
- name: Cloudflare Dynamic DNS Container
docker_container:
name: "{{ cloudflare_container_name }}"
image: joshava/cloudflare-ddns:latest
pull: true
volumes:
- "{{ cloudflare_data_directory }}/config.yml:/app/config.yaml"
restart_policy: unless-stopped
memory: "{{ cloudflare_memory }}"
recreate: "{{ template_files_result is changed }}"
2022-08-28 17:45:41 +00:00
when: cloudflare_ddns_enabled is true
- name: Stop Cloudflare DDNS
block:
- name: Stop Cloudflare DDNS
docker_container:
name: "{{ cloudflare_container_name }}"
state: absent
when: cloudflare_ddns_enabled is false