diff --git a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py b/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py index 9da6a8f294..9965a31506 100644 --- a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py +++ b/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py @@ -32,9 +32,8 @@ DOCUMENTATION = ''' --- module: gcp_dns_managed_zone description: - - A zone is a subtree of the DNS namespace under one administrative - responsibility. A ManagedZone is a resource that represents a DNS zone - hosted by the Cloud DNS service. + - A zone is a subtree of the DNS namespace under one administrative responsibility. + A ManagedZone is a resource that represents a DNS zone hosted by the Cloud DNS service. short_description: Creates a GCP ManagedZone version_added: 2.5 author: Google Inc. (@googlecloudplatform) @@ -46,14 +45,12 @@ options: state: description: - Whether the given object should exist in GCP - required: true choices: ['present', 'absent'] default: 'present' description: description: - - A mutable string of at most 1024 characters associated with this - resource for the user's convenience. Has no effect on the managed - zone's function. + - A mutable string of at most 1024 characters associated with this resource for the + user's convenience. Has no effect on the managed zone's function. required: false dns_name: description: @@ -66,9 +63,9 @@ options: required: true name_server_set: description: - - Optionally specifies the NameServerSet for this ManagedZone. A - NameServerSet is a set of DNS name servers that all host the same - ManagedZones. Most users will leave this field unset. + - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is + a set of DNS name servers that all host the same ManagedZones. Most users will leave + this field unset. required: false extends_documentation_fragment: gcp ''' @@ -76,23 +73,20 @@ extends_documentation_fragment: gcp EXAMPLES = ''' - name: create a managed zone gcp_dns_managed_zone: - name: testObject + name: "test_object" dns_name: test.somewild2.example.com. - description: 'test zone' - project: testProject - auth_kind: service_account - service_account_file: /tmp/auth.pem - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite + description: test zone + project: "test_project" + auth_kind: "service_account" + service_account_file: "/tmp/auth.pem" state: present ''' RETURN = ''' description: description: - - A mutable string of at most 1024 characters associated with this - resource for the user's convenience. Has no effect on the managed - zone's function. + - A mutable string of at most 1024 characters associated with this resource for the + user's convenience. Has no effect on the managed zone's function. returned: success type: str dns_name: @@ -113,15 +107,15 @@ RETURN = ''' type: str name_servers: description: - - Delegate your managed_zone to these virtual name servers; defined - by the server. + - Delegate your managed_zone to these virtual name servers; defined by the server + . returned: success type: list name_server_set: description: - - Optionally specifies the NameServerSet for this ManagedZone. A - NameServerSet is a set of DNS name servers that all host the same - ManagedZones. Most users will leave this field unset. + - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is + a set of DNS name servers that all host the same ManagedZones. Most users will leave + this field unset. returned: success type: list creation_time: @@ -157,6 +151,9 @@ def main(): ) ) + if not module.params['scopes']: + module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite'] + state = module.params['state'] kind = 'dns#managedZone' diff --git a/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml b/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml index 6f2c5fe28b..e4ce07a36c 100644 --- a/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml +++ b/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml @@ -17,24 +17,20 @@ gcp_dns_managed_zone: name: "{{ resource_name }}" dns_name: test.somewild2.example.com. - description: 'test zone' + description: test zone project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite state: absent #---------------------------------------------------------- - name: create a managed zone gcp_dns_managed_zone: name: "{{ resource_name }}" dns_name: test.somewild2.example.com. - description: 'test zone' + description: test zone project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite state: present register: result - name: assert changed is true @@ -55,12 +51,10 @@ gcp_dns_managed_zone: name: "{{ resource_name }}" dns_name: test.somewild2.example.com. - description: 'test zone' + description: test zone project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite state: present register: result - name: assert changed is false @@ -73,12 +67,10 @@ gcp_dns_managed_zone: name: "{{ resource_name }}" dns_name: test.somewild2.example.com. - description: 'test zone' + description: test zone project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite state: absent register: result - name: assert changed is true @@ -101,12 +93,10 @@ gcp_dns_managed_zone: name: "{{ resource_name }}" dns_name: test.somewild2.example.com. - description: 'test zone' + description: test zone project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite state: absent register: result - name: assert changed is false