diff --git a/README.md b/README.md index b7665d50..17bd1c58 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,15 @@ Modules - `nios_network_view` – Configure Infoblox NIOS network views -- `nios_nsgroup` – Configure Infoblox DNS Nameserver Groups +- `nios_nsgroup` – Configure Infoblox DNS Nameserver Authoritative Groups + +- `nios_nsgroup_delegation` – Configure Infoblox DNS Nameserver Delegation Groups + +- `nios_nsgroup_forwardingmember` – Configure Infoblox DNS Nameserver Forwarding Member Groups + +- `nios_nsgroup_forwardstubserver` – Configure Infoblox DNS Nameserver Forward/Stub Server Groups + +- `nios_nsgroup_stubmember` – Configure Infoblox DNS Nameserver Stub Member Groups - `nios_ptr_record` – Configure Infoblox NIOS PTR records diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 3a586193..a45928cc 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -71,6 +71,10 @@ NIOS_DTC_SERVER = 'dtc:server' NIOS_DTC_POOL = 'dtc:pool' NIOS_DTC_LBDN = 'dtc:lbdn' +NIOS_NSGROUP_FORWARDSTUBSERVER = 'nsgroup:forwardstubserver' +NIOS_NSGROUP_FORWARDINGMEMBER = 'nsgroup:forwardingmember' +NIOS_NSGROUP_DELEGATION = 'nsgroup:delegation' +NIOS_NSGROUP_STUBMEMBER = 'nsgroup:stubmember' NIOS_DTC_MONITOR_HTTP = 'dtc:monitor:http' NIOS_DTC_MONITOR_ICMP = 'dtc:monitor:icmp' NIOS_DTC_MONITOR_PDP = 'dtc:monitor:pdp' diff --git a/plugins/modules/nios_nsgroup.py b/plugins/modules/nios_nsgroup.py index 948fe238..91e5d6d4 100644 --- a/plugins/modules/nios_nsgroup.py +++ b/plugins/modules/nios_nsgroup.py @@ -11,14 +11,14 @@ DOCUMENTATION = ''' --- module: nios_nsgroup -short_description: Configure InfoBlox DNS Nameserver Groups +short_description: Configure InfoBlox DNS Nameserver Authoritative Groups version_added: "1.0.0" extends_documentation_fragment: infoblox.nios_modules.nios author: - Erich Birngruber (@ebirn) - Sumit Jaiswal (@sjaiswal) description: - - Adds and/or removes nameserver groups form Infoblox NIOS servers. + - Adds and/or removes nameserver groups of type "Authoritative" form Infoblox NIOS servers. This module manages NIOS C(nsgroup) objects using the Infoblox. WAPI interface over REST. requirements: - infoblox_client diff --git a/plugins/modules/nios_nsgroup_delegation.py b/plugins/modules/nios_nsgroup_delegation.py new file mode 100644 index 00000000..6eec00d1 --- /dev/null +++ b/plugins/modules/nios_nsgroup_delegation.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# Copyright © 2020 Infoblox Inc +# -*- coding: utf-8 -*- +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_nsgroup_delegation +short_description: Configure InfoBlox DNS Nameserver Delegation Groups +extends_documentation_fragment: infoblox.nios_modules.nios +author: + - Mauricio Teixeira (@badnetmask) +description: + - Adds and/or removes nameserver groups of type "Delegation" form Infoblox NIOS servers. + This module manages NIOS C(nsgroup:delegation) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + delegate_to: + description: + - Specifies the list of name servers to be used + required: true + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the server + required: true + type: str + address: + description: + - Provide the IP address of the server + required: true + type: str + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + required: false + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + required: false + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: create infoblox nameserver delegation group + infoblox.nios_modules.nios_nsgroup_delegation: + name: my-delegation-group + comment: "this is a delegation nameserver group" + delegate_to: + - name: first + address: 192.168.0.10 + - name: second + address: 192.168.0.20 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_NSGROUP_DELEGATION +from ..module_utils.api import normalize_ib_spec + + +def main(): + '''entrypoint for module execution.''' + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + delegate_to_spec = dict( + name=dict(required=True), + address=dict(required=True) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + delegate_to=dict(type='list', elements='dict', required=True, options=delegate_to_spec), + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_NSGROUP_DELEGATION, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_nsgroup_forwardingmember.py b/plugins/modules/nios_nsgroup_forwardingmember.py new file mode 100644 index 00000000..f1fb3507 --- /dev/null +++ b/plugins/modules/nios_nsgroup_forwardingmember.py @@ -0,0 +1,175 @@ +#!/usr/bin/python +# Copyright © 2020 Infoblox Inc +# -*- coding: utf-8 -*- +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_nsgroup_forwardingmember +short_description: Configure InfoBlox DNS Nameserver Forward/Stub Server Groups +extends_documentation_fragment: infoblox.nios_modules.nios +author: + - Mauricio Teixeira (@badnetmask) +description: + - Adds and/or removes nameserver groups of type "Forwarding Member" from Infoblox NIOS servers. + This module manages NIOS C(nsgroup:forwardstubserver) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + forwarding_servers: + description: + - Specifies the list of forwarding member servers to be used + required: true + type: list + elements: dict + suboptions: + name: + description: + - The name of the forwarding grid member in FQDN format + required: true + type: str + forwarders_only: + description: + - Determines if the appliance sends queries to forwarders only, and not to other internal or Internet root servers. + required: false + type: bool + default: false + use_override_forwarders: + description: + - When using c(forward_to) option, and this is set to C(True), only the defined custom forwarders will be used (no recurse to root nameservers). + required: false + type: bool + default: false + forward_to: + description: + - The information for the remote name server to which you want the Infoblox appliance to forward queries for a specified domain name. + required: false + type: list + default: [] + elements: dict + suboptions: + name: + description: + - Provide the name of the server + required: true + type: str + address: + description: + - Provide the IP address of the server + required: true + type: str + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + required: false + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + required: false + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: create infoblox nameserver forwarding member group + infoblox.nios_modules.nios_nsgroup_forwardingmember: + name: my-forwardingmember-group + comment: "this is a forwarding member nameserver group" + forwarding_servers: + - name: member.localdomain + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local + +- name: create infoblox nameserver forwarding member group with external forwarders + infoblox.nios_modules.nios_nsgroup_forwardingmember: + name: my-forwardingmember-group + comment: "this is a forwarding member nameserver group with external forwarders" + forwarding_servers: + - name: member.localdomain + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_NSGROUP_FORWARDINGMEMBER +from ..module_utils.api import normalize_ib_spec + + +def main(): + '''entrypoint for module execution.''' + + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + forward_to_spec = dict( + name=dict(required=True), + address=dict(required=True), + ) + + forwarding_servers_spec = dict( + name=dict(required=True), + forwarders_only=dict(type='bool', default=False), + forward_to=dict(type='list', elements='dict', options=forward_to_spec, default=[], required=False), + use_override_forwarders=dict(type='bool', default=False), + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + forwarding_servers=dict(type='list', elements='dict', required=True, options=forwarding_servers_spec), + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_NSGROUP_FORWARDINGMEMBER, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_nsgroup_forwardstubserver.py b/plugins/modules/nios_nsgroup_forwardstubserver.py new file mode 100644 index 00000000..e7d2b033 --- /dev/null +++ b/plugins/modules/nios_nsgroup_forwardstubserver.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# Copyright © 2020 Infoblox Inc +# -*- coding: utf-8 -*- +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_nsgroup_forwardstubserver +short_description: Configure InfoBlox DNS Nameserver Forwarding Member Groups +extends_documentation_fragment: infoblox.nios_modules.nios +author: + - Mauricio Teixeira (@badnetmask) +description: + - Adds and/or removes nameserver groups of type "Forward/Stub Server" form Infoblox NIOS servers. + This module manages NIOS C(nsgroup:forwardstubserver) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + external_servers: + description: + - Specifies the list of name servers to be used + required: true + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the server + required: true + type: str + address: + description: + - Provide the IP address of the server + required: true + type: str + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + required: false + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + required: false + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: create infoblox nameserver forward/stub group + infoblox.nios_modules.nios_nsgroup_forwardstubserver: + name: my-forwardstub-group + comment: "this is a forward/stub nameserver group" + nameservers: + - name: first + address: 192.168.0.10 + - name: second + address: 192.168.0.20 + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_NSGROUP_FORWARDSTUBSERVER +from ..module_utils.api import normalize_ib_spec + + +def main(): + '''entrypoint for module execution.''' + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + external_servers_spec = dict( + name=dict(required=True), + address=dict(required=True) + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + external_servers=dict(type='list', elements='dict', required=True, options=external_servers_spec), + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_NSGROUP_FORWARDSTUBSERVER, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/plugins/modules/nios_nsgroup_stubmember.py b/plugins/modules/nios_nsgroup_stubmember.py new file mode 100644 index 00000000..d10fbf50 --- /dev/null +++ b/plugins/modules/nios_nsgroup_stubmember.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +# Copyright © 2020 Infoblox Inc +# -*- coding: utf-8 -*- +# Copyright (c) 2018-2019 Red Hat, Inc. +# Copyright (c) 2020 Infoblox, Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = ''' +--- +module: nios_nsgroup_stubmember +short_description: Configure InfoBlox DNS Nameserver Stub Member Groups +extends_documentation_fragment: infoblox.nios_modules.nios +author: + - Mauricio Teixeira (@badnetmask) +description: + - Adds and/or removes nameserver groups of type "Stub Member" form Infoblox NIOS servers. + This module manages NIOS C(nsgroup:stubmember) objects using the Infoblox. WAPI interface over REST. +requirements: + - infoblox_client +options: + name: + description: + - Specifies the name of the NIOS nameserver group to be managed. + required: true + type: str + stub_members: + description: + - Specifies the list of members to be used + required: true + type: list + elements: dict + suboptions: + name: + description: + - Provide the name of the member + required: true + type: str + extattrs: + description: + - Allows for the configuration of Extensible Attributes on the + instance of the object. This argument accepts a set of key / value + pairs for configuration. + required: false + type: dict + comment: + description: + - Configures a text string comment to be associated with the instance + of this object. The provided text string will be configured on the + object instance. + required: false + type: str + state: + description: + - Configures the intended state of the instance of the object on + the NIOS server. When this value is set to C(present), the object + is configured on the device and when this value is set to C(absent) + the value is removed (if necessary) from the device. + choices: [present, absent] + default: present + type: str +''' + +EXAMPLES = ''' +- name: create infoblox nameserver stub member group + infoblox.nios_modules.nios_nsgroup_stubmember: + name: my-stubmember-group + comment: "this is a stub member nameserver group" + stub_members: + - name: member.localdomain + state: present + provider: + host: "{{ inventory_hostname_short }}" + username: admin + password: admin + connection: local +''' + +RETURN = ''' # ''' + +from ansible.module_utils.basic import AnsibleModule +from ..module_utils.api import WapiModule +from ..module_utils.api import NIOS_NSGROUP_STUBMEMBER +from ..module_utils.api import normalize_ib_spec + + +def main(): + '''entrypoint for module execution.''' + argument_spec = dict( + provider=dict(required=True), + state=dict(default='present', choices=['present', 'absent']), + ) + + stub_members_spec = dict( + name=dict(required=True), + ) + + ib_spec = dict( + name=dict(required=True, ib_req=True), + stub_members=dict(type='list', elements='dict', required=True, options=stub_members_spec), + extattrs=dict(type='dict'), + comment=dict(), + ) + + argument_spec.update(normalize_ib_spec(ib_spec)) + argument_spec.update(WapiModule.provider_spec) + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + wapi = WapiModule(module) + result = wapi.run(NIOS_NSGROUP_STUBMEMBER, ib_spec) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/tests/integration/targets/nios_nsgroup_delegation/aliases b/tests/integration/targets/nios_nsgroup_delegation/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml b/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml b/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml new file mode 100644 index 00000000..0dd08be4 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: nios_nsgroup_delegation_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml b/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml new file mode 100644 index 00000000..aad5ae76 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_delegation/tasks/nios_nsgroup_delegation_idempotence.yml @@ -0,0 +1,83 @@ +- name: cleanup nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: absent + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + +- name: configure a nsgroup delegation on the system + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: present + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_create1 + +- name: configure another nsgroup delegation on the system + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: present + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_create2 + +- name: update the comment and ext attributes for an existing nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_update1 + +- name: update again the comment and ext attributes for an existing nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_update2 + +- name: remove the nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: absent + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_delete1 + +- name: remove again the nsgroup delegation + nios_nsgroup_delegation: + name: ansible-nsgroup_delegation + state: absent + provider: "{{ nios_provider }}" + delegate_to: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_delegation_delete2 + +- assert: + that: + - "nsgroup_delegation_create1.changed" + - "not nsgroup_delegation_create2.changed" + - "nsgroup_delegation_update1.changed" + - "not nsgroup_delegation_update2.changed" + - "nsgroup_delegation_delete1.changed" + - "not nsgroup_delegation_delete2.changed" diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/aliases b/tests/integration/targets/nios_nsgroup_forwardingmember/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml b/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml new file mode 100644 index 00000000..32ed6486 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: nios_nsgroup_forwardingmember_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml new file mode 100644 index 00000000..743b1cd9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardingmember/tasks/nios_nsgroup_forwardingmember_idempotence.yml @@ -0,0 +1,104 @@ +- name: cleanup nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: absent + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + +- name: configure a nsgroup forwardingmember on the system + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: present + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_create1 + +- name: configure another nsgroup forwardingmember on the system + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: present + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_create2 + +- name: update the comment and ext attributes for an existing nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_update1 + +- name: update again the comment and ext attributes for an existing nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_update2 + +- name: remove the nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: absent + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_delete1 + +- name: remove again the nsgroup forwardingmember + nios_nsgroup_forwardingmember: + name: ansible-nsgroup_forwardingmember + state: absent + provider: "{{ nios_provider }}" + forwarding_servers: + - name: ns1 + use_override_forwarders: true + forward_to: + - name: ns1 + address: 192.168.10.1 + register: nsgroup_forwardingmember_delete2 + +- assert: + that: + - "nsgroup_forwardingmember_create1.changed" + - "not nsgroup_forwardingmember_create2.changed" + - "nsgroup_forwardingmember_update1.changed" + - "not nsgroup_forwardingmember_update2.changed" + - "nsgroup_forwardingmember_delete1.changed" + - "not nsgroup_forwardingmember_delete2.changed" diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/aliases b/tests/integration/targets/nios_nsgroup_forwardstubserver/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml b/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml new file mode 100644 index 00000000..e356aa50 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: nios_nsgroup_forwardstubserver_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml new file mode 100644 index 00000000..915c1186 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_forwardstubserver/tasks/nios_nsgroup_forwardstubserver_idempotence.yml @@ -0,0 +1,83 @@ +- name: cleanup nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: absent + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + +- name: configure a nsgroup forwardstubserver on the system + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: present + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_create1 + +- name: configure another nsgroup forwardstubserver on the system + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: present + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_create2 + +- name: update the comment and ext attributes for an existing nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_update1 + +- name: update again the comment and ext attributes for an existing nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_update2 + +- name: remove the nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: absent + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_delete1 + +- name: remove again the nsgroup forwardstubserver + nios_nsgroup_forwardstubserver: + name: ansible-nsgroup_forwardstubserver + state: absent + provider: "{{ nios_provider }}" + external_servers: + - name: ns1 + address: 192.168.0.1 + register: nsgroup_forwardstubserver_delete2 + +- assert: + that: + - "nsgroup_forwardstubserver_create1.changed" + - "not nsgroup_forwardstubserver_create2.changed" + - "nsgroup_forwardstubserver_update1.changed" + - "not nsgroup_forwardstubserver_update2.changed" + - "nsgroup_forwardstubserver_delete1.changed" + - "not nsgroup_forwardstubserver_delete2.changed" diff --git a/tests/integration/targets/nios_nsgroup_stubmember/aliases b/tests/integration/targets/nios_nsgroup_stubmember/aliases new file mode 100644 index 00000000..b3138dc7 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/aliases @@ -0,0 +1,3 @@ +shippable/cloud/group1 +cloud/nios +destructive diff --git a/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml b/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml new file mode 100644 index 00000000..ebf6ffc9 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml b/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml new file mode 100644 index 00000000..9472935b --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nios_tests \ No newline at end of file diff --git a/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml b/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml new file mode 100644 index 00000000..e0cbb36f --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/tasks/main.yml @@ -0,0 +1 @@ +- include_tasks: nios_nsgroup_stubmember_idempotence.yml diff --git a/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml b/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml new file mode 100644 index 00000000..b7f97108 --- /dev/null +++ b/tests/integration/targets/nios_nsgroup_stubmember/tasks/nios_nsgroup_stubmember_idempotence.yml @@ -0,0 +1,76 @@ +- name: cleanup nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: absent + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + +- name: configure a nsgroup stubmember on the system + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: present + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_create1 + +- name: configure another nsgroup stubmember on the system + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: present + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_create2 + +- name: update the comment and ext attributes for an existing nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_update1 + +- name: update again the comment and ext attributes for an existing nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + comment: this is an example comment + extattrs: + Site: west-dc + state: present + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_update2 + +- name: remove the nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: absent + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_delete1 + +- name: remove again the nsgroup stubmember + nios_nsgroup_stubmember: + name: ansible-nsgroup_stubmember + state: absent + provider: "{{ nios_provider }}" + stub_members: + - name: ns1 + register: nsgroup_stubmember_delete2 + +- assert: + that: + - "nsgroup_stubmember_create1.changed" + - "not nsgroup_stubmember_create2.changed" + - "nsgroup_stubmember_update1.changed" + - "not nsgroup_stubmember_update2.changed" + - "nsgroup_stubmember_delete1.changed" + - "not nsgroup_stubmember_delete2.changed" diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py index ba8455bf..802cf61e 100644 --- a/tests/unit/compat/mock.py +++ b/tests/unit/compat/mock.py @@ -64,8 +64,7 @@ def _iterate_read_data(read_data): # newline that our naive format() added data_as_list[-1] = data_as_list[-1][:-1] - for line in data_as_list: - yield line + yield from data_as_list def mock_open(mock=None, read_data=''): """ @@ -91,8 +90,7 @@ def _readline_side_effect(): if handle.readline.return_value is not None: while True: yield handle.readline.return_value - for line in _data: - yield line + yield from _data global file_spec if file_spec is None: