mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Allow DNS bypass for add/remove of host records with nios_host_record (#42934)
* fixes issue 42420 * fixes issue 42420 * fix shippable docs error * shippable fix and test case add * shippable fix and test case add * shippable fix and test case add * shippable fix * removing extra assert * shippable fix
This commit is contained in:
parent
e2cac8cc93
commit
01fb7ea150
3 changed files with 113 additions and 11 deletions
|
@ -327,6 +327,10 @@ class WapiModule(WapiBase):
|
||||||
update = True
|
update = True
|
||||||
return ib_obj, update, new_name
|
return ib_obj, update, new_name
|
||||||
if (ib_obj_type == NIOS_HOST_RECORD):
|
if (ib_obj_type == NIOS_HOST_RECORD):
|
||||||
|
# to check only by name if dns bypassing is set
|
||||||
|
if not obj_filter['configure_for_dns']:
|
||||||
|
test_obj_filter = dict([('name', name)])
|
||||||
|
else:
|
||||||
test_obj_filter = dict([('name', name), ('view', obj_filter['view'])])
|
test_obj_filter = dict([('name', name), ('view', obj_filter['view'])])
|
||||||
else:
|
else:
|
||||||
test_obj_filter = dict([('name', name)])
|
test_obj_filter = dict([('name', name)])
|
||||||
|
|
|
@ -39,6 +39,16 @@ options:
|
||||||
default: default
|
default: default
|
||||||
aliases:
|
aliases:
|
||||||
- dns_view
|
- dns_view
|
||||||
|
configure_for_dns:
|
||||||
|
version_added: "2.7"
|
||||||
|
description:
|
||||||
|
- Sets the DNS to particular parent. If user needs to bypass DNS
|
||||||
|
user can make the value to false.
|
||||||
|
type: bool
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
aliases:
|
||||||
|
- dns
|
||||||
ipv4addrs:
|
ipv4addrs:
|
||||||
description:
|
description:
|
||||||
- Configures the IPv4 addresses for this host record. This argument
|
- Configures the IPv4 addresses for this host record. This argument
|
||||||
|
@ -52,9 +62,20 @@ options:
|
||||||
required: true
|
required: true
|
||||||
aliases:
|
aliases:
|
||||||
- address
|
- address
|
||||||
|
configure_for_dhcp:
|
||||||
|
description:
|
||||||
|
- Configure the host_record over DHCP instead of DNS, if user
|
||||||
|
changes it to true, user need to mention MAC address to configure
|
||||||
|
required: false
|
||||||
|
aliases:
|
||||||
|
- dhcp
|
||||||
mac:
|
mac:
|
||||||
description:
|
description:
|
||||||
- Configures the hardware MAC address for the host record
|
- Configures the hardware MAC address for the host record. If user makes
|
||||||
|
DHCP to true, user need to mention MAC address.
|
||||||
|
required: false
|
||||||
|
aliases:
|
||||||
|
- mac
|
||||||
ipv6addrs:
|
ipv6addrs:
|
||||||
description:
|
description:
|
||||||
- Configures the IPv6 addresses for the host record. This argument
|
- Configures the IPv6 addresses for the host record. This argument
|
||||||
|
@ -68,6 +89,13 @@ options:
|
||||||
required: true
|
required: true
|
||||||
aliases:
|
aliases:
|
||||||
- address
|
- address
|
||||||
|
configure_for_dhcp:
|
||||||
|
description:
|
||||||
|
- Configure the host_record over DHCP instead of DNS, if user
|
||||||
|
changes it to true, user need to mention MAC address to configure
|
||||||
|
required: false
|
||||||
|
aliases:
|
||||||
|
- dhcp
|
||||||
aliases:
|
aliases:
|
||||||
version_added: "2.6"
|
version_added: "2.6"
|
||||||
description:
|
description:
|
||||||
|
@ -145,6 +173,31 @@ EXAMPLES = '''
|
||||||
username: admin
|
username: admin
|
||||||
password: admin
|
password: admin
|
||||||
connection: local
|
connection: local
|
||||||
|
- name: create an ipv4 host record bypassing DNS
|
||||||
|
nios_host_record:
|
||||||
|
name: new_host
|
||||||
|
ipv4:
|
||||||
|
- address: 192.168.10.1
|
||||||
|
dns: false
|
||||||
|
state: present
|
||||||
|
provider:
|
||||||
|
host: "{{ inventory_hostname_short }}"
|
||||||
|
username: admin
|
||||||
|
password: admin
|
||||||
|
connection: local
|
||||||
|
- name: create an ipv4 host record over DHCP
|
||||||
|
nios_host_record:
|
||||||
|
name: host.ansible.com
|
||||||
|
ipv4:
|
||||||
|
- address: 192.168.10.1
|
||||||
|
dhcp: true
|
||||||
|
mac: 00-80-C8-E3-4C-BD
|
||||||
|
state: present
|
||||||
|
provider:
|
||||||
|
host: "{{ inventory_hostname_short }}"
|
||||||
|
username: admin
|
||||||
|
password: admin
|
||||||
|
connection: local
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = ''' # '''
|
RETURN = ''' # '''
|
||||||
|
@ -174,11 +227,11 @@ def ipaddr(module, key, filtered_keys=None):
|
||||||
|
|
||||||
|
|
||||||
def ipv4addrs(module):
|
def ipv4addrs(module):
|
||||||
return ipaddr(module, 'ipv4addrs', filtered_keys=['address'])
|
return ipaddr(module, 'ipv4addrs', filtered_keys=['address', 'dhcp'])
|
||||||
|
|
||||||
|
|
||||||
def ipv6addrs(module):
|
def ipv6addrs(module):
|
||||||
return ipaddr(module, 'ipv6addrs', filtered_keys=['address'])
|
return ipaddr(module, 'ipv6addrs', filtered_keys=['address', 'dhcp'])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -186,11 +239,14 @@ def main():
|
||||||
'''
|
'''
|
||||||
ipv4addr_spec = dict(
|
ipv4addr_spec = dict(
|
||||||
ipv4addr=dict(required=True, aliases=['address'], ib_req=True),
|
ipv4addr=dict(required=True, aliases=['address'], ib_req=True),
|
||||||
mac=dict()
|
configure_for_dhcp=dict(type='bool', required=False, aliases=['dhcp'], ib_req=True),
|
||||||
|
mac=dict(required=False, aliases=['mac'], ib_req=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
ipv6addr_spec = dict(
|
ipv6addr_spec = dict(
|
||||||
ipv6addr=dict(required=True, aliases=['address'], ib_req=True)
|
ipv6addr=dict(required=True, aliases=['address'], ib_req=True),
|
||||||
|
configure_for_dhcp=dict(type='bool', required=False, aliases=['configure_for_dhcp'], ib_req=True),
|
||||||
|
mac=dict(required=False, aliases=['mac'], ib_req=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
ib_spec = dict(
|
ib_spec = dict(
|
||||||
|
@ -199,6 +255,7 @@ def main():
|
||||||
|
|
||||||
ipv4addrs=dict(type='list', aliases=['ipv4'], elements='dict', options=ipv4addr_spec, transform=ipv4addrs),
|
ipv4addrs=dict(type='list', aliases=['ipv4'], elements='dict', options=ipv4addr_spec, transform=ipv4addrs),
|
||||||
ipv6addrs=dict(type='list', aliases=['ipv6'], elements='dict', options=ipv6addr_spec, transform=ipv6addrs),
|
ipv6addrs=dict(type='list', aliases=['ipv6'], elements='dict', options=ipv6addr_spec, transform=ipv6addrs),
|
||||||
|
configure_for_dns=dict(type='bool', default=True, required=False, aliases=['dns'], ib_req=True),
|
||||||
aliases=dict(type='list'),
|
aliases=dict(type='list'),
|
||||||
|
|
||||||
ttl=dict(type='int'),
|
ttl=dict(type='int'),
|
||||||
|
|
|
@ -36,11 +36,6 @@
|
||||||
provider: "{{ nios_provider }}"
|
provider: "{{ nios_provider }}"
|
||||||
register: ipv4_create2
|
register: ipv4_create2
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "ipv4_create1.changed"
|
|
||||||
- "not ipv4_create2.changed"
|
|
||||||
|
|
||||||
- name: add a comment to an existing host record
|
- name: add a comment to an existing host record
|
||||||
nios_host_record:
|
nios_host_record:
|
||||||
name: host.ansible.com
|
name: host.ansible.com
|
||||||
|
@ -75,6 +70,48 @@
|
||||||
provider: "{{ nios_provider }}"
|
provider: "{{ nios_provider }}"
|
||||||
register: ipv4_delete2
|
register: ipv4_delete2
|
||||||
|
|
||||||
|
- name: create an ipv4 host record bypassing DNS
|
||||||
|
nios_host_record:
|
||||||
|
name: host
|
||||||
|
ipv4:
|
||||||
|
- address: 192.168.10.1
|
||||||
|
dns: false
|
||||||
|
state: present
|
||||||
|
provider: "{{ nios_provider }}"
|
||||||
|
register: ipv4_create3
|
||||||
|
|
||||||
|
- name: recreate an ipv4 host record bypassing DNS
|
||||||
|
nios_host_record:
|
||||||
|
name: host
|
||||||
|
ipv4:
|
||||||
|
- address: 192.168.10.1
|
||||||
|
dns: false
|
||||||
|
state: present
|
||||||
|
provider: "{{ nios_provider }}"
|
||||||
|
register: ipv4_create4
|
||||||
|
|
||||||
|
- name: create an ipv4 host record via DHCP and MAC
|
||||||
|
nios_host_record:
|
||||||
|
name: host
|
||||||
|
ipv4:
|
||||||
|
- address: 192.168.10.1
|
||||||
|
dhcp: true
|
||||||
|
mac: 00-80-C8-E3-4C-BD
|
||||||
|
state: present
|
||||||
|
provider: "{{ nios_provider }}"
|
||||||
|
register: ipv4_create5
|
||||||
|
|
||||||
|
- name: recreate an ipv4 host record via DHCP and MAC
|
||||||
|
nios_host_record:
|
||||||
|
name: host
|
||||||
|
ipv4:
|
||||||
|
- address: 192.168.10.1
|
||||||
|
dhcp: true
|
||||||
|
mac: 00-80-C8-E3-4C-BD
|
||||||
|
state: present
|
||||||
|
provider: "{{ nios_provider }}"
|
||||||
|
register: ipv4_create6
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "ipv4_create1.changed"
|
- "ipv4_create1.changed"
|
||||||
|
@ -83,3 +120,7 @@
|
||||||
- "not ipv4_update2.changed"
|
- "not ipv4_update2.changed"
|
||||||
- "ipv4_delete1.changed"
|
- "ipv4_delete1.changed"
|
||||||
- "not ipv4_delete2.changed"
|
- "not ipv4_delete2.changed"
|
||||||
|
- "ipv4_create3.changed"
|
||||||
|
- "not ipv4_create4.changed"
|
||||||
|
- "ipv4_create5.changed"
|
||||||
|
- "not ipv4_create6.changed"
|
||||||
|
|
Loading…
Reference in a new issue