felixfontein.acme._substitute_dns filter – [INTERNAL] Adjust DNS name according to a CNAME substitution map

Note

This filter plugin is part of the felixfontein.acme collection (version 0.8.1).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install felixfontein.acme.

To use it in a playbook, specify: felixfontein.acme._substitute_dns.

New in felixfontein.acme 0.6.0

Synopsis

  • This is an internal tool and must only be used from roles in this collection! If you use it from outside this collection, be warned that its behavior can change and it can be removed at any time, even in bugfix releases!

Input

This describes the input of the filter, the value before | felixfontein.acme._substitute_dns.

Parameter

Comments

Input

string / required

A DNS name.

Keyword parameters

This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | felixfontein.acme._substitute_dns(key1=value1, key2=value2, ...)

Parameter

Comments

substitution_map

dictionary / required

A map mapping DNS names to other DNS names.

You can use a single wildcard * as the first component of a DNS name.

Trailing dots are ignored.

Examples

- name: Simple replace
  ansible.builtin.set_fact:
    name: "{{ 'www.example.com' | felixfontein.acme._substitute_dns({'www.example.com': 'www.com.example.org'}) }}"
    # Result is 'www.com.example.org'

- name: Replace with wildcard
  ansible.builtin.set_fact:
    name: "{{ 'foo.example.com' | felixfontein.acme._substitute_dns({'*.example.com': '*.com.example.org'}) }}"
    # Result is '*.com.example.org'

- name: Replace (not) with wildcard
  ansible.builtin.set_fact:
    name: "{{ 'www.foo.example.com' | felixfontein.acme._substitute_dns({'*.example.com': '*.com.example.org'}) }}"
    # Result is 'www.foo.example.com' (the wildcard does not match because there is more than one component)

Return Value

Key

Description

Return value

string

The transformed input.

Returned: success

Authors

  • Felix Fontein (@felixfontein)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.