community.dns.get_registrable_domain filter – Returns the registrable domain name of a DNS name

Note

This filter plugin is part of the community.dns collection (version 2.8.3).

You might already have this collection installed if you are using the ansible package. 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 community.dns.

To use it in a playbook, specify: community.dns.get_registrable_domain.

New in community.dns 0.1.0

Synopsis

  • Returns the registrable domain name of a DNS name.

Input

This describes the input of the filter, the value before | community.dns.get_registrable_domain.

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 | community.dns.get_registrable_domain(key1=value1, key2=value2, ...)

Parameter

Comments

icann_only

boolean

This controls whether only entries from the ICANN section of the Public Suffix List are used, or also entries from the Private section. For example, .co.uk is in the ICANN section, but github.io is in the Private section.

Choices:

  • false ← (default)

  • true

keep_unknown_suffix

boolean

This treats unknown TLDs as valid public suffixes. So for example the public suffix of example.tlddoesnotexist is .tlddoesnotexist if this is true, and hence the registrable domain of www.example.tlddoesnotexist is example.tlddoesnotexist. If set to false, the registrable domain of www.example.tlddoesnotexist is tlddoesnotexist.

This option corresponds to whether the global wildcard rule * in the Public Suffix List is used or not.

Choices:

  • false

  • true ← (default)

normalize_result

boolean

This controls whether the result is reconstructed from the normalized name used during lookup. During normalization, ulabels are converted to alabels, and every label is converted to lowercase. For example, the ulabel ëçãmplê is converted to xn--mpl-llatwb (puny-code), and Example.COM is converted to example.com.

Choices:

  • false ← (default)

  • true

only_if_registerable

boolean

This controls the behavior in case there is no label in front of the public suffix. This is the case if the DNS name itself is a public suffix.

If set to false, in this case the public suffix is treated as a registrable domain.

If set to true (default), the registrable domain of a public suffix is interpreted as an empty string.

Choices:

  • false

  • true ← (default)

Examples

- name: Extract the registrable domain from a DNS name
  ansible.builtin.set_fact:
    public_suffix: "{{ 'www.ansible.co.uk' | community.dns.get_registrable_domain }}"
    # Should result in 'ansible.co.uk'

Return Value

Key

Description

Return value

string

The registrable domain.

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.