Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCP: DNS Managed Zones #35014

Merged
merged 1 commit into from Feb 6, 2018
Merged

GCP: DNS Managed Zones #35014

merged 1 commit into from Feb 6, 2018

Conversation

rambleraptor
Copy link
Contributor

SUMMARY

This adds support for creating managed zones on GCP, along with a test runner and future utilities for adding more GCP resources.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

gcp_dns_managed_zone

ANSIBLE VERSION
2.5
ADDITIONAL INFORMATION

This code was autogenerated using Magic Modules

@ansibot
Copy link
Contributor

ansibot commented Jan 17, 2018

@ansibot
Copy link
Contributor

ansibot commented Jan 17, 2018

@rambleraptor this PR contains more than one new module.

Please submit only one new module per pullrequest. For further explanation, please read grouped module documentation

click here for bot help

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 cloud feature_pull_request gce module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. new_module This PR includes a new module. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Jan 17, 2018
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Jan 17, 2018
@ryansb
Copy link
Contributor

ryansb commented Jan 17, 2018

Source of the code generator: https://github.com/GoogleCloudPlatform/magic-modules

@ryansb ryansb self-requested a review January 17, 2018 21:16
@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jan 17, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 18, 2018
@ansibot
Copy link
Contributor

ansibot commented Jan 18, 2018

The test ansible-test compile --python 2.6 [?] failed with the following error:

lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:192:20: SyntaxError: return {k: v for k, v in request.items() if v}

The test ansible-test sanity --test ansible-doc --python 2.6 [?] failed with the following error:

lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test import --python 2.6 [?] failed with the following error:

lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:192:20: SyntaxError: invalid syntax

The test ansible-test sanity --test validate-modules [?] failed with the following error:

lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:0:0: E312 No RETURN provided

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jan 18, 2018
# This file is automatically generated by ansible-codegen and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see these files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Changed the wording to point to our Github repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to point to our Github repo for the Code Generator.

state:
description:
- Whether the given object should exist in GCP
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could update the generator to not add required: false lines as that's the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. This was actually a typo.

class ModuleDocFragment(object):
# GCP doc fragment.
DOCUMENTATION = '''
options:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than defining these options in every modules argspec the should be defined once in module_utils/gcp_utils.py

http://docs.ansible.com/ansible/devel/dev_guide/developing_modules_in_groups.html#your-first-pull-request

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be necessary since the code is autogenerated by Magic Modules (the code generator)?

Magic Modules acts as the central repository for this information and has all of these options in one central file. Magic Modules could act as the source of truth instead of a module_utils/ file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with moving shared documentation out of a fragment - the use of doc fragments also serves to keep docs consistent across modules, and in large part we treat generated modules the same way we treat regular ones. This means that the same attention should be paid to code/doc sharing via mod_utils and doc fragments and so forth.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, please split this into docs fragment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. The documentation is currently in a document fragment. I'll consolidate the shared module argspec in module_utils/gcp_utils.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change is made. Documentation uses fragments and module argspec is now centralized in module_utils/gcp_utils.py

service_account_file=dict(type='path'),
scopes=dict(required=True, type='list')
),
mutually_exclusive=[['service_account_email', 'service_account_file']],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding this to the documentation fragments for both options, e.g.
The I(service_account_email) and I(service_account_file) options are mutually exclusive.`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

self.module.params['service_account_email'] = os.getenv('GCP_SERVICE_ACCOUNT_EMAIL')

if not self.module.params['service_account_file']:
self.module.params['service_account_file'] = os.getenv('GCP_SERVICE_ACCOUNT_FILE')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be put in the argspec, e.g.
required=False, fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_FILE']),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

required: true
notes:
- For authentication, you can set service_account_file using the
GCP_SERVICE_ACCOUNT_FILE env variable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ansible ansible deleted a comment from ansibot Jan 19, 2018
@ansible ansible deleted a comment from ansibot Jan 19, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 19, 2018
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the full license header in here for your needs? We currently recommend using the following instead:

# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I've made the change.

@ansibot
Copy link
Contributor

ansibot commented Jan 31, 2018

The test ansible-test sanity --test pylint [?] failed with the following errors:

lib/ansible/module_utils/gcp_utils.py:87:12: undefined-variable Undefined variable 'module'
lib/ansible/module_utils/gcp_utils.py:91:26: ansible-format-automatic-specification Format string contains automatic field numbering specification

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jan 31, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 31, 2018
@ryansb
Copy link
Contributor

ryansb commented Jan 31, 2018

@gundalow unfortunately the google-auth library has a requirement on urllib3/requests, so using ansible's urls.py would not remove the dependency without also having to rewrite the google-auth library.

I think because of that dep, we should leave requests in for the GCP modules since they will require it either way.

@sivel
Copy link
Member

sivel commented Jan 31, 2018

We'll just need to add E203 to the ignores for these files that require it to test/sanity/validate-modules/ignore.txt`

Accepting requests overrides was always said to be done on a case by case basis, and this is one of the allowed reasons.

EDIT: Actually thinking through it, since the requests error is for new module submissions (in PR phase) I don't think adding to ignore.txt will work. Since after merge, it's no longer a new module and will pass, causing a CI failure. We'll likely just have to ignore that failure in CI during PR.

@ansibot
Copy link
Contributor

ansibot commented Jan 31, 2018

The test ansible-test sanity --test compile --python 2.6 [?] failed with the following error:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: 'User-Agent': "Google-Ansible-MM-%s" %s self.product

The test ansible-test sanity --test compile --python 3.5 [?] failed with the following error:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: 'User-Agent': "Google-Ansible-MM-%s" %s self.product

The test ansible-test sanity --test compile --python 3.6 [?] failed with the following error:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: 'User-Agent': "Google-Ansible-MM-%s" %s self.product

The test ansible-test sanity --test compile --python 3.7 [?] failed with the following error:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: 'User-Agent': "Google-Ansible-MM-%s" %s self.product

The test ansible-test sanity --test compile --python 2.7 [?] failed with the following error:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: 'User-Agent': "Google-Ansible-MM-%s" %s self.product

The test ansible-test sanity --test import --python 2.6 [?] failed with the following errors:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: invalid syntax
lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:114:0: SyntaxError: invalid syntax (gcp_utils.py, line 91)

The test ansible-test sanity --test import --python 2.7 [?] failed with the following errors:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: invalid syntax
lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:114:0: SyntaxError: invalid syntax (gcp_utils.py, line 91)

The test ansible-test sanity --test import --python 3.5 [?] failed with the following errors:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: invalid syntax
lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:114:0: SyntaxError: invalid syntax (gcp_utils.py, line 91)

The test ansible-test sanity --test import --python 3.6 [?] failed with the following errors:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: invalid syntax
lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:114:0: SyntaxError: invalid syntax (gcp_utils.py, line 91)

The test ansible-test sanity --test import --python 3.7 [?] failed with the following errors:

lib/ansible/module_utils/gcp_utils.py:91:56: SyntaxError: invalid syntax
lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:114:0: SyntaxError: invalid syntax (gcp_utils.py, line 91)

The test ansible-test sanity --test pep8 [?] failed with the following error:

lib/ansible/module_utils/gcp_utils.py:91:51: E225 missing whitespace around operator

The test ansible-test sanity --test validate-modules [?] failed with the following error:

lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py:0:0: E321 Exception attempting to import module for argument_spec introspection, 'invalid syntax (gcp_utils.py, line 91)'

The test ansible-test sanity --test pylint [?] failed with the following error:

lib/ansible/module_utils/gcp_utils.py:91:0: syntax-error invalid syntax (<string>, line 91)

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jan 31, 2018
@rambleraptor
Copy link
Contributor Author

(Sorry about these Shippable issues. My dev machine seems to be having some issues with Ansible-test and so I'm relying on Shippable far too much. I'll get that fixed for future PRs.)

Just a thought on the requests exception handling: it looks like module_utils can accept requests imports without error. I can do exception handling on gcp_utils and have gcp_utils throw a different exception (GCPRequestException or something). Each module can import GCPRequestException without any issue.

@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 31, 2018
@rambleraptor
Copy link
Contributor Author

Anybody else have any notes on this?

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Feb 5, 2018
@rambleraptor
Copy link
Contributor Author

Woot, green checkmarks! Do you need anything more from me?

@ryansb ryansb merged commit 9706abf into ansible:devel Feb 6, 2018
nelsonjr pushed a commit to nelsonjr/magic-modules that referenced this pull request Feb 9, 2018
PR: ansible/ansible#35014

* Changing wording on autogenerated notice (and adding to rest of files)
* Making code Python 2.6 compliant (no list comprehensions)
* Adding documentation
* Moving authentication env variable processing
* Making YAML changes now that I know which YAML tests to run

Change-Id: I11c9ec1e8662049cd578650860ef67e167cf376d
nat-henderson pushed a commit to GoogleCloudPlatform/magic-modules that referenced this pull request Feb 9, 2018
PR: ansible/ansible#35014

* Changing wording on autogenerated notice (and adding to rest of files)
* Making code Python 2.6 compliant (no list comprehensions)
* Adding documentation
* Moving authentication env variable processing
* Making YAML changes now that I know which YAML tests to run

Change-Id: I11c9ec1e8662049cd578650860ef67e167cf376d
nelsonjr pushed a commit to GoogleCloudPlatform/magic-modules that referenced this pull request Feb 14, 2018
PR: ansible/ansible#35014

* Changing wording on autogenerated notice (and adding to rest of files)
* Making code Python 2.6 compliant (no list comprehensions)
* Adding documentation
* Moving authentication env variable processing
* Making YAML changes now that I know which YAML tests to run

Change-Id: I11c9ec1e8662049cd578650860ef67e167cf376d
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 5, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 cloud core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. gce module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. new_module This PR includes a new module. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants