community / community.general / 8.5.0 / test / fqdn_valid Validates fully-qualified domain names against RFC 1123 | "added in version" 8.1.0 of community.general" Authors: Vladimir Botka (@vbotka)community.general.fqdn_valid (8.5.0) — test
Install with ansible-galaxy collection install community.general:==8.5.0
collections: - name: community.general version: 8.5.0
This test validates Fully Qualified Domain Names (FQDNs) conforming to the Internet Engineering Task Force specification RFC 1123 and RFC 952.
The design intent is to validate that a string would be traditionally acceptable as a public Internet hostname to RFC-conforming software, which is a strict subset of the logic in modern web browsers like Mozilla Firefox and Chromium that determines whether make a DNS lookup.
Certificate Authorities like Let's Encrypt run a narrower set of string validation logic to determine validity for issuance. This test is not intended to achieve functional parity with CA issuance.
Single label names are allowed by default (O(min_labels=1)).
- name: Make sure that hostname is valid ansible.builtin.assert: that: hostname is community.general.fqdn_valid
- name: Make sure that hostname is at least 3 labels long (a.b.c) ansible.builtin.assert: that: hostname is community.general.fqdn_valid(min_labels=3)
- name: Make sure that hostname is at least 2 labels long (a.b). Allow '_' ansible.builtin.assert: that: hostname is community.general.fqdn_valid(min_labels=2, allow_underscores=True)
_input: description: Name of the host. required: true type: str min_labels: default: 1 description: Required minimum of labels, separated by period. required: false type: int allow_underscores: default: false description: Allow underscore characters. required: false type: bool
_value: description: Whether the name is valid. type: bool