mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-14 14:26:04 +02:00
Refactor web-opt-rdr-www:
- Split Cloudflare edge redirect into _01 and _02 task files - Wrap Cloudflare routines in a conditional block on DNS_PROVIDER - Preserve origin vs edge flavor handling Conversation: https://chatgpt.com/share/68c3609b-5624-800f-b5fa-69def6032dca
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
- name: Include Cloudflare redirect rule to enforce www → apex
|
||||||
|
include_tasks: _02_cloudflare_redirect_rule.yml
|
||||||
|
vars:
|
||||||
|
domain: "{{ item | regex_replace('^www\\.', '') }}"
|
||||||
|
www_fqdn: "{{ item }}"
|
||||||
|
apex_url: "{{ WEB_PROTOCOL }}://{{ item | regex_replace('^www\\.', '') }}"
|
||||||
|
loop: "{{ REDIRECT_WWW_DOMAINS }}"
|
@@ -13,6 +13,9 @@
|
|||||||
redirect_domain_mappings: "{{ REDIRECT_WWW_DOMAINS | map('regex_replace', '^www\\.(.+)$', '{ source: \"www.\\1\", target: \"\\1\" }') | map('from_yaml') | list }}"
|
redirect_domain_mappings: "{{ REDIRECT_WWW_DOMAINS | map('regex_replace', '^www\\.(.+)$', '{ source: \"www.\\1\", target: \"\\1\" }') | map('from_yaml') | list }}"
|
||||||
when: REDIRECT_WWW_FLAVOR == 'origin'
|
when: REDIRECT_WWW_FLAVOR == 'origin'
|
||||||
|
|
||||||
|
- name: Cloudflare WWW Routines
|
||||||
|
when: DNS_PROVIDER == 'cloudflare'
|
||||||
|
block:
|
||||||
- name: Include DNS role to set redirects
|
- name: Include DNS role to set redirects
|
||||||
include_role:
|
include_role:
|
||||||
name: sys-dns-cloudflare-records
|
name: sys-dns-cloudflare-records
|
||||||
@@ -31,17 +34,8 @@
|
|||||||
}{{ "," if not loop.last else "" }}
|
}{{ "," if not loop.last else "" }}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
]
|
]
|
||||||
when:
|
when: REDIRECT_WWW_FLAVOR == 'origin'
|
||||||
- DNS_PROVIDER == 'cloudflare'
|
|
||||||
- REDIRECT_WWW_FLAVOR == 'origin'
|
|
||||||
|
|
||||||
- name: Include Cloudflare redirect rule to enforce www → apex
|
- name: Include Cloudflare edge redirect
|
||||||
include_tasks: cloudflare_redirect_rule.yml
|
include_tasks: _01_cloudflare_edge_redirect.yml
|
||||||
vars:
|
|
||||||
domain: "{{ item | regex_replace('^www\\.', '') }}"
|
|
||||||
www_fqdn: "{{ item }}"
|
|
||||||
apex_url: "{{ WEB_PROTOCOL }}://{{ item | regex_replace('^www\\.', '') }}"
|
|
||||||
loop: "{{ REDIRECT_WWW_DOMAINS }}"
|
|
||||||
when: REDIRECT_WWW_FLAVOR == 'edge'
|
when: REDIRECT_WWW_FLAVOR == 'edge'
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user