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
GCP: DNS Managed Zones #35014
Conversation
@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 |
Source of the code generator: https://github.com/GoogleCloudPlatform/magic-modules |
68e8fd1
to
a00fd86
Compare
The test
The test
The test
The test
|
# 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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']], |
There was a problem hiding this comment.
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.`
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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']),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C(GCP_SERVICE_ACCOUNT_FILE)
http://docs.ansible.com/ansible/latest/dev_guide/developing_modules_documenting.html#formatting-options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
# All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without modification, | ||
# are permitted provided that the following conditions are met: |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
The test
|
@gundalow unfortunately the google-auth library has a requirement on urllib3/requests, so using ansible's I think because of that dep, we should leave |
We'll just need to add Accepting EDIT: Actually thinking through it, since the |
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
|
(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. |
Anybody else have any notes on this? |
Woot, green checkmarks! Do you need anything more from me? |
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
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
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
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
COMPONENT NAME
gcp_dns_managed_zone
ANSIBLE VERSION
ADDITIONAL INFORMATION
This code was autogenerated using Magic Modules