Note
This test plugin is part of the community.general collection (version 10.7.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.general. You need further requirements to be able to use this test plugin, see Requirements for details.
To use it in a playbook, specify: community.general.fqdn_valid.
New in community.general 8.1.0
min_labels=1).The below requirements are needed on the local controller node that executes this test.
This describes the input of the test, the value before is community.general.fqdn_valid or is not community.general.fqdn_valid.
Parameter | Comments |
|---|---|
Input string / required | Name of the host. |
This describes keyword parameters of the test. These are the values key1=value1, key2=value2 and so on in the following examples: input is community.general.fqdn_valid(key1=value1, key2=value2, ...) and input is not community.general.fqdn_valid(key1=value1, key2=value2, ...)
Parameter | Comments |
|---|---|
allow_underscores boolean | Allow underscore characters. Choices:
|
min_labels integer | Required minimum of labels, separated by period. Default: |
- 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)
Key | Description |
|---|---|
Return value boolean | Whether the name is valid. Returned: success |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/fqdn_valid_test.html