mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-04-29 18:48:39 +02:00
35 lines
1.0 KiB
YAML
35 lines
1.0 KiB
YAML
---
|
|
- name: "Debug: all_domains"
|
|
debug:
|
|
var: all_domains
|
|
when: enable_debug
|
|
|
|
- name: Filter www-prefixed domains from all_domains
|
|
set_fact:
|
|
www_domains: "{{ all_domains | select('match', '^www\\.') | list }}"
|
|
|
|
- name: Build redirect mappings for www domains
|
|
set_fact:
|
|
domain_mappings: >-
|
|
{{ www_domains
|
|
| map('regex_replace', '^www\\.(.+)$', '{ source: \"www.\\1\", target: \"\\1\" }')
|
|
| map('from_yaml')
|
|
| list
|
|
}}
|
|
|
|
- name: Include nginx-redirect-domain role for www-to-bare redirects
|
|
include_role:
|
|
name: nginx-redirect-domain
|
|
vars:
|
|
domain_mappings: "{{ domain_mappings }}"
|
|
when: certbot_flavor == 'dedicated'
|
|
|
|
- name: Include DNS role to set redirects
|
|
include_role:
|
|
name: dns-records-cloudflare
|
|
vars:
|
|
cloudflare_api_token: "{{ certbot_dns_api_token }}"
|
|
cloudflare_domains: "{{ www_domains }}"
|
|
cloudflare_target_ip: "{{ networks.internet.ip4 }}"
|
|
cloudflare_proxied_false: false
|
|
when: dns_provider == 'cloudflare' |