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

Added ability to specify plan information for images that require it. #65335

Merged
merged 12 commits into from Dec 18, 2019

Conversation

seanw122
Copy link
Contributor

@seanw122 seanw122 commented Nov 27, 2019

SUMMARY

Added ability to specify billing plan information for images that require it. Images like CIS hardened images on Azure marketplace require plan field to be populated.
Fixes #65268

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

azure_rm_virtualmachinescaleset

ADDITIONAL INFORMATION

Tests were done locally that:

  1. generated the VM scale set with CIS image
  2. generated VM scale set with standard Ubuntu image to prove nothing broke
  3. as expected, failed to generate a scale set when specifying plan for image that does not require it
  4. as expected, failed to generate a scale set when specifying image without required plan

The module azure_rm_virtualmachinescaleset handles plan information. Based on how plan and accept_terms was used I copied:

  1. over documentation
  2. over parameter definition
  3. over code blocks for validating plan parameter
  4. over code for accepting terms
    and
    added an example in the examples section.

@ansibot
Copy link
Contributor

ansibot commented Nov 27, 2019

@ansibot
Copy link
Contributor

ansibot commented Nov 27, 2019

@seanw122, just so you are aware we have a dedicated Working Group for azure.
You can find other people interested in this in #ansible-azure on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 azure bug This issue/PR relates to a bug. cloud community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. labels Nov 27, 2019
# Before creating VM accept terms of plan if `accept_terms` is True
if self.accept_terms is True:
if not self.plan or not all([self.plan.get('name'), self.plan.get('product'), self.plan.get('publisher')]):
self.fail("parameter error: plan must be specified and include name, product, and publisher")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use required_if to make sure that plan must be specified if accept_terms is True.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this needs to be the other way around. If a plan is specified then accept_terms must be True. I left it in for now until I learn the syntax for required_if.

Copy link
Contributor

Choose a reason for hiding this comment

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

Your logic from the code above is: if accept_terms is True, plan must be specified. (That can also be modelled by required_if.) If you want the logic the other way around, you have to change your code (and you can't use required_if AFAIK).

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Nov 27, 2019
@Fred-sun
Copy link
Contributor

review_need

@ansibot
Copy link
Contributor

ansibot commented Nov 28, 2019

@seanw122 this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@ansibot ansibot added merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Nov 28, 2019
@ansibot ansibot removed merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html labels Nov 28, 2019
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Nov 28, 2019
@ansibot
Copy link
Contributor

ansibot commented Nov 28, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py:518:111: trailing-whitespace: Trailing whitespace

The test ansible-test sanity --test pep8 [explain] failed with 3 errors:

lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py:518:34: E128: continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py:518:112: W291: trailing whitespace
lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py:519:34: E126: continuation line over-indented for hanging indent

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Nov 28, 2019
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Nov 29, 2019
@ansibot
Copy link
Contributor

ansibot commented Nov 29, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_virtualmachinescaleset.py:518:17: E128: continuation line under-indented for visual indent

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Nov 29, 2019
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Nov 29, 2019
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Nov 29, 2019
@seanw122
Copy link
Contributor Author

In fairness, this is a feature change and not a bug. I don't know how to remove bug tag.

@felixfontein
Copy link
Contributor

@seanw122 you can simply edit the PR message and change Bugfix Pull Request to Feature Pull Request. ansibot should then update the labels accordingly.

@ansibot ansibot added the feature This issue/PR relates to a feature request. label Nov 29, 2019
@seanw122
Copy link
Contributor Author

Hmm. Well it added Feature but did not remove Bug. I don't know if the bot will let me execute notabug.

@felixfontein felixfontein removed the bug This issue/PR relates to a bug. label Nov 29, 2019
@seanw122
Copy link
Contributor Author

Thanks @felixfontein !

@anshulbehl
Copy link
Contributor

@gavinfish Can you review this and I think this should also be contributed to the collection as well.

@Fred-sun
Copy link
Contributor

Fred-sun commented Dec 5, 2019

ready_for_review

@haiyuazhang
Copy link
Contributor

@seanw122
I just checked the azure doc, seems that "the accept term" is an one-shot endeavor, so IMO, maybe we can remove that part from this PR. Besides , if full automation is the ultimate goal, should we move the accept term logic to azure_rm_image?

I'll invite one of the committer to review your PR, and handle it as soon as possible. Thanks for contributing to ansible azure module.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Dec 11, 2019
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Dec 11, 2019
@seanw122
Copy link
Contributor Author

@haiyuazhang I removed the property and related code for accepting terms.

@zikalino zikalino merged commit dfd998b into ansible:devel Dec 18, 2019
@ansible ansible locked and limited conversation to collaborators Jan 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 azure cloud community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. has_issue module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azure_rm_virtualmachinescaleset fails when using image that requires plan information
7 participants