diff --git a/lib/ansible/modules/storage/netapp/na_ontap_vserver_peer.py b/lib/ansible/modules/storage/netapp/na_ontap_vserver_peer.py index e50f23eec6..d1e57d5239 100644 --- a/lib/ansible/modules/storage/netapp/na_ontap_vserver_peer.py +++ b/lib/ansible/modules/storage/netapp/na_ontap_vserver_peer.py @@ -37,11 +37,11 @@ options: peer_cluster: description: - Specifies name of the peer Cluster. - - If peer Cluster is not given, it considers local Cluster. + - Required for creating the vserver peer relationship with a remote cluster dest_hostname: description: - Destination hostname or IP address. - - Required for creating the vserver peer relationship + - Required for creating the vserver peer relationship with a remote cluster dest_username: description: - Destination username. @@ -111,9 +111,6 @@ class NetAppONTAPVserverPeer(object): self.module = AnsibleModule( argument_spec=self.argument_spec, - required_if=[ - ('state', 'present', ['dest_hostname']) - ], supports_check_mode=True ) @@ -207,6 +204,8 @@ class NetAppONTAPVserverPeer(object): """ if self.parameters.get('applications') is None: self.module.fail_json(msg='applications parameter is missing') + if self.parameters.get('peer_cluster') is not None and self.parameters.get('dest_hostname') is None: + self.module.fail_json(msg='dest_hostname is required for peering a vserver in remote cluster') if self.parameters.get('peer_cluster') is None: self.parameters['peer_cluster'] = self.get_peer_cluster_name() vserver_peer_create = netapp_utils.zapi.NaElement.create_node_with_children( @@ -235,7 +234,9 @@ class NetAppONTAPVserverPeer(object): 'vserver-peer-accept', **{'peer-vserver': self.parameters['vserver'], 'vserver': self.parameters['peer_vserver']}) try: - self.dest_server.invoke_successfully(vserver_peer_accept, enable_tunneling=True) + # accept only if the peer relationship is on a remote cluster + if self.parameters.get('dest_hostname') is not None: + self.dest_server.invoke_successfully(vserver_peer_accept, enable_tunneling=True) except netapp_utils.zapi.NaApiError as error: self.module.fail_json(msg='Error accepting vserver peer %s: %s' % (self.parameters['peer_vserver'], to_native(error)),