mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Implmented dev mode für cloudflare
This commit is contained in:
35
roles/srv-proxy-6-6-domain/tasks/01_cloudflare.yml
Normal file
35
roles/srv-proxy-6-6-domain/tasks/01_cloudflare.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
- name: "Ensure Cloudflare Zone ID is known for {{ domain }}"
|
||||
vars:
|
||||
cf_api_url: "https://api.cloudflare.com/client/v4/zones"
|
||||
ansible.builtin.uri:
|
||||
url: "{{ cf_api_url }}?name={{ domain | to_primary_domain }}"
|
||||
method: GET
|
||||
headers:
|
||||
Authorization: "Bearer {{ certbot_dns_api_token }}"
|
||||
Content-Type: "application/json"
|
||||
return_content: yes
|
||||
register: cf_zone_lookup_dev
|
||||
when:
|
||||
- cf_zone_id is not defined
|
||||
|
||||
- name: "Set fact cf_zone_id (if not already set)"
|
||||
set_fact:
|
||||
cf_zone_id: "{{ cf_zone_lookup_dev.json.result[0].id }}"
|
||||
when:
|
||||
- cf_zone_id is not defined
|
||||
- cf_zone_lookup_dev.json.result | length > 0
|
||||
|
||||
- name: "Fail if no Cloudflare zone found for {{ domain | to_primary_domain }}"
|
||||
ansible.builtin.fail:
|
||||
msg: "No Cloudflare zone found for {{ domain | to_primary_domain }} — aborting!"
|
||||
when:
|
||||
- cf_zone_id is not defined
|
||||
- cf_zone_lookup_dev.json.result | length == 0
|
||||
|
||||
- name: activate cloudflare cache development mode
|
||||
include_tasks: "cloudflare/02_enable_cf_dev_mode.yml"
|
||||
when: (INFINITO_ENVIRONMENT | lower) == 'development'
|
||||
|
||||
- name: purge cloudflare domain cache
|
||||
include_tasks: "cloudflare/01_cleanup.yml"
|
||||
when: mode_cleanup | bool
|
Reference in New Issue
Block a user