mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add update_dns option for ipa_host module (#30646)
Fix adds update_dns option for ipa_host module.This option will update DNS records of the host which is managed by FreeIPA DNS server. Fixes: #30627 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
c86b945a7c
commit
320e915a27
1 changed files with 20 additions and 3 deletions
|
@ -65,6 +65,12 @@ options:
|
||||||
description: State to ensure
|
description: State to ensure
|
||||||
default: present
|
default: present
|
||||||
choices: ["present", "absent", "disabled"]
|
choices: ["present", "absent", "disabled"]
|
||||||
|
update_dns:
|
||||||
|
description:
|
||||||
|
- If set C("True") with state as C("absent"), then removes DNS records of the host managed by FreeIPA DNS.
|
||||||
|
- This option has no effect for states other than "absent".
|
||||||
|
default: false
|
||||||
|
version_added: "2.5"
|
||||||
extends_documentation_fragment: ipa.documentation
|
extends_documentation_fragment: ipa.documentation
|
||||||
version_added: "2.3"
|
version_added: "2.3"
|
||||||
'''
|
'''
|
||||||
|
@ -109,6 +115,15 @@ EXAMPLES = '''
|
||||||
ipa_host: ipa.example.com
|
ipa_host: ipa.example.com
|
||||||
ipa_user: admin
|
ipa_user: admin
|
||||||
ipa_pass: topsecret
|
ipa_pass: topsecret
|
||||||
|
|
||||||
|
# Ensure host and its DNS record is absent
|
||||||
|
- ipa_host:
|
||||||
|
name: host01.example.com
|
||||||
|
state: absent
|
||||||
|
ipa_host: ipa.example.com
|
||||||
|
ipa_user: admin
|
||||||
|
ipa_pass: topsecret
|
||||||
|
update_dns: True
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
|
@ -142,8 +157,8 @@ class HostIPAClient(IPAClient):
|
||||||
def host_mod(self, name, host):
|
def host_mod(self, name, host):
|
||||||
return self._post_json(method='host_mod', name=name, item=host)
|
return self._post_json(method='host_mod', name=name, item=host)
|
||||||
|
|
||||||
def host_del(self, name):
|
def host_del(self, name, update_dns):
|
||||||
return self._post_json(method='host_del', name=name)
|
return self._post_json(method='host_del', name=name, item={'updatedns': update_dns})
|
||||||
|
|
||||||
def host_disable(self, name):
|
def host_disable(self, name):
|
||||||
return self._post_json(method='host_disable', name=name)
|
return self._post_json(method='host_disable', name=name)
|
||||||
|
@ -211,8 +226,9 @@ def ensure(module, client):
|
||||||
else:
|
else:
|
||||||
if ipa_host:
|
if ipa_host:
|
||||||
changed = True
|
changed = True
|
||||||
|
update_dns = module.params.get('update_dns', False)
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
client.host_del(name=name)
|
client.host_del(name=name, update_dns=update_dns)
|
||||||
|
|
||||||
return changed, client.host_find(name=name)
|
return changed, client.host_find(name=name)
|
||||||
|
|
||||||
|
@ -228,6 +244,7 @@ def main():
|
||||||
ns_os_version=dict(type='str', aliases=['nsosversion']),
|
ns_os_version=dict(type='str', aliases=['nsosversion']),
|
||||||
user_certificate=dict(type='list', aliases=['usercertificate']),
|
user_certificate=dict(type='list', aliases=['usercertificate']),
|
||||||
mac_address=dict(type='list', aliases=['macaddress']),
|
mac_address=dict(type='list', aliases=['macaddress']),
|
||||||
|
update_dns=dict(type='bool'),
|
||||||
state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']))
|
state=dict(type='str', default='present', choices=['present', 'absent', 'enabled', 'disabled']))
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=argument_spec,
|
module = AnsibleModule(argument_spec=argument_spec,
|
||||||
|
|
Loading…
Reference in a new issue