diff --git a/README-dnszone.md b/README-dnszone.md index 3f4827b9af4ee1d42f570cb316049df3659c86da..c5a7ab32b8d4b62d50873f46868c562ab2b4a9b0 100644 --- a/README-dnszone.md +++ b/README-dnszone.md @@ -152,6 +152,46 @@ Example playbook to remove a zone: ``` +Example playbook to create a zone for reverse DNS lookup, from an IP address: + +```yaml + +--- +- name: dnszone present + hosts: ipaserver + become: true + + tasks: + - name: Ensure zone for reverse DNS lookup is present. + ipadnszone: + ipaadmin_password: SomeADMINpassword + name_from_ip: 192.168.1.2 + state: present +``` + +Note that, on the previous example the zone created with `name_from_ip` might be "1.168.192.in-addr.arpa.", "168.192.in-addr.arpa.", or "192.in-addr.arpa.", depending on the DNS response the system get while querying for zones, and for this reason, when creating a zone using `name_from_ip`, the inferred zone name is returned to the controller, in the attribute `dnszone.name`. Since the zone inferred might not be what a user expects, `name_from_ip` can only be used with `state: present`. To have more control over the zone name, the prefix length for the IP address can be provided. + +Example playbook to create a zone for reverse DNS lookup, from an IP address, given the prefix length and displaying the resulting zone name: + +```yaml + +--- +- name: dnszone present + hosts: ipaserver + become: true + + tasks: + - name: Ensure zone for reverse DNS lookup is present. + ipadnszone: + ipaadmin_password: SomeADMINpassword + name_from_ip: 192.168.1.2/24 + state: present + register: result + - name: Display inferred zone name. + debug: + msg: "Zone name: {{ result.dnszone.name }}" +``` + Variables ========= @@ -164,7 +204,7 @@ Variable | Description | Required `ipaadmin_principal` | The admin principal is a string and defaults to `admin` | no `ipaadmin_password` | The admin password is a string and is required if there is no admin ticket available on the node | no `name` \| `zone_name` | The zone name string or list of strings. | no -`name_from_ip` | Derive zone name from reverse of IP (PTR). | no +`name_from_ip` | Derive zone name from reverse of IP (PTR). Can only be used with `state: present`. | no `forwarders` | The list of forwarders dicts. Each `forwarders` dict entry has:| no | `ip_address` - The IPv4 or IPv6 address of the DNS server. | yes | `port` - The custom port that should be used on this server. | no diff --git a/plugins/modules/ipadnszone.py b/plugins/modules/ipadnszone.py index 93eac07cd04cbf42363f2d39219a9ad8629e2170..ff6bfff03b369aec6e41d975e049047ddf479051 100644 --- a/plugins/modules/ipadnszone.py +++ b/plugins/modules/ipadnszone.py @@ -44,7 +44,9 @@ options: type: list alises: ["zone_name"] name_from_ip: - description: Derive zone name from reverse of IP (PTR). + description: | + Derive zone name from reverse of IP (PTR). + Can only be used with `state: present`. required: false type: str forwarders: