From 41e8226d0c03e06816626d78cecbc2aebf547691 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman <rjeffman@redhat.com> Date: Wed, 5 Aug 2020 15:14:43 -0300 Subject: [PATCH] Return the zone_name when adding a zone with name_from_ip. When adding a zone using the option name_from_ip, the user have little control over the final name of the zone, and if this name is to be used in further processing in a playbook it might lead to errors if the inferred name does not match what the user wanted to. By returning the actual inferred zone name, the name can be safely used for other tasks in the playbook. --- README-dnszone.md | 11 +++++++++++ playbooks/dnszone/dnszone-reverse-from-ip.yml | 7 ++++++- plugins/modules/ipadnszone.py | 8 ++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README-dnszone.md b/README-dnszone.md index 48b019a9..3f4827b9 100644 --- a/README-dnszone.md +++ b/README-dnszone.md @@ -190,6 +190,17 @@ Variable | Description | Required `skip_nameserver_check` | Force DNS zone creation even if nameserver is not resolvable | no +Return Values +============= + +ipadnszone +---------- + +Variable | Description | Returned When +-------- | ----------- | ------------- +`dnszone` | DNS Zone dict with zone name infered from `name_from_ip`. <br>Options: | If `state` is `present`, `name_from_ip` is used, and a zone was created. + | `name` - The name of the zone created, inferred from `name_from_ip`. | Always + Authors ======= diff --git a/playbooks/dnszone/dnszone-reverse-from-ip.yml b/playbooks/dnszone/dnszone-reverse-from-ip.yml index 56938721..218a3189 100644 --- a/playbooks/dnszone/dnszone-reverse-from-ip.yml +++ b/playbooks/dnszone/dnszone-reverse-from-ip.yml @@ -7,4 +7,9 @@ - name: Ensure zone exist, finding zone name from IP address. ipadnszone: ipaadmin_password: SomeADMINpassword - name_from_ip: 10.1.2.3 + name_from_ip: 10.1.2.3/24 + register: result + + - name: Zone name inferred from `name_from_ip` + debug: + msg: "Zone created: {{ result.dnszone.name }}" diff --git a/plugins/modules/ipadnszone.py b/plugins/modules/ipadnszone.py index 6a90fa2b..93eac07c 100644 --- a/plugins/modules/ipadnszone.py +++ b/plugins/modules/ipadnszone.py @@ -192,6 +192,14 @@ EXAMPLES = """ """ RETURN = """ +dnszone: + description: DNS Zone dict with zone name infered from `name_from_ip`. + returned: + If `state` is `present`, `name_from_ip` is used, and a zone was created. + options: + name: + description: The name of the zone created, inferred from `name_from_ip`. + returned: always """ from ipapython.dnsutil import DNSName # noqa: E402 -- GitLab