Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_publicipaddress Add the reverse_fqdn #1660

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions plugins/modules/azure_rm_publicipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
type: str
aliases:
- domain_name_label
reverse_fqdn:
description:
- The reverse FQDN.
- A user-visible, fully qualified domain name that resolves to this public IP address.
- If the reverseFqdn is specified, then a PTR DNS record is created pointing from the IP address in the in-addr.arpa domain to the reverse FQDN.
type: str
name:
description:
- Name of the Public IP.
Expand Down Expand Up @@ -152,7 +158,7 @@
sample: {
"domain_name_label": "ansible-b57dc95985712e45eb8b9c2e",
"fqdn": "ansible-b57dc95985712e45eb8b9c2e.eastus.cloudapp.azure.com",
"reverse_fqdn": null
"reverse_fqdn": "ansible-b57dc95985712e45eb8b9c2f.eastus.cloudapp.azure.com"
}
etag:
description:
Expand Down Expand Up @@ -284,6 +290,7 @@ def __init__(self):
version=dict(type='str', default='ipv4', choices=['ipv4', 'ipv6']),
allocation_method=dict(type='str', default='dynamic', choices=['Dynamic', 'Static', 'dynamic', 'static']),
domain_name=dict(type='str', aliases=['domain_name_label']),
reverse_fqdn=dict(type='str'),
sku=dict(type='str', choices=['Basic', 'Standard', 'basic', 'standard']),
ip_tags=dict(type='list', elements='dict', options=ip_tag_spec),
idle_timeout=dict(type='int'),
Expand All @@ -298,6 +305,7 @@ def __init__(self):
self.zones = None
self.allocation_method = None
self.domain_name = None
self.reverse_fqdn = None
self.sku = None
self.version = None
self.ip_tags = None
Expand Down Expand Up @@ -343,6 +351,12 @@ def exec_module(self, **kwargs):
changed = True
results['dns_settings']['domain_name_label'] = self.domain_name

if self.reverse_fqdn is not None and self.reverse_fqdn != results['dns_settings'].get('reverse_fqdn'):
changed = True
self.log('CHANGED: reverse_fqdn')
else:
self.reverse_fqdn = results['dns_settings'].get('reverse_fqdn')

if self.allocation_method.lower() != results['public_ip_allocation_method'].lower():
self.log("CHANGED: allocation_method")
changed = True
Expand Down Expand Up @@ -408,9 +422,10 @@ def exec_module(self, **kwargs):
pip.ip_tags = [self.network_models.IpTag(ip_tag_type=x['type'], tag=x['value']) for x in self.ip_tags]
if self.tags:
pip.tags = self.tags
if self.domain_name:
if self.domain_name or self.reverse_fqdn:
pip.dns_settings = self.network_models.PublicIPAddressDnsSettings(
domain_name_label=self.domain_name
domain_name_label=self.domain_name,
reverse_fqdn=self.reverse_fqdn
)
else:
self.log("Update Public IP {0}".format(self.name))
Expand All @@ -421,9 +436,10 @@ def exec_module(self, **kwargs):
tags=results['tags'],
zones=results['zones']
)
if self.domain_name:
if self.domain_name or self.reverse_fqdn:
pip.dns_settings = self.network_models.PublicIPAddressDnsSettings(
domain_name_label=self.domain_name
domain_name_label=self.domain_name,
reverse_fqdn=self.reverse_fqdn
)
self.results['state'] = self.create_or_update_pip(pip)
elif self.state == 'absent':
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/azure_rm_publicipaddress_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
sample: {
"domain_name_label": "ansible-b57dc95985712e45eb8b9c2e",
"fqdn": "ansible-b57dc95985712e45eb8b9c2e.eastus.cloudapp.azure.com",
"reverse_fqdn": null
"reverse_fqdn": "ansible-b57dc95985712e45eb8b9c2f.eastus.cloudapp.azure.com"
}
ip_tags:
description:
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/targets/azure_rm_publicipaddress/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@
name: "pip{{ rpfx }}"
state: absent

- name: Create the first public ip
azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
name: "pip{{ rpfx }}-first"
allocation_method: Static
domain_name: "{{ domain_name }}-first"
register: output

- name: Create public ip
azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
name: "pip{{ rpfx }}"
allocation_method: Static
domain_name: "{{ domain_name }}"
reverse_fqdn: "{{ output.state.dns_settings.fqdn }}"
tags:
testing: testing
delete: on-exit
Expand Down Expand Up @@ -131,6 +140,12 @@
name: "pip{{ rpfx }}-02"
state: absent

- name: Remove the first public ip
azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
name: "pip{{ rpfx }}-first"
state: absent

- name: Remove public ip
azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
Expand Down