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

Add an ec2_import_snapshot module #62630

Closed
wants to merge 1 commit into from

Conversation

bcl
Copy link

@bcl bcl commented Sep 19, 2019

This uses the boto3 import_snapshot function to import a disk image from
s3 as a snapshot.

SUMMARY

This is a wrapper around the boto3 import_snapshot function. It allows you to import a disk image from an S3 bucket as a snapshot, which can then be registered as an AMI.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.import_snapshot

It seemed to fit better as its own module instead of adding it to ec2_ami or one of the ec2_snapshot modules.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

ec2_import_snapshot

ADDITIONAL INFORMATION

@ansibot
Copy link
Contributor

ansibot commented Sep 19, 2019

@bcl, just so you are aware we have a dedicated Working Group for aws.
You can find other people interested in this in #ansible-aws 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 aws 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. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels Sep 19, 2019
@ansibot
Copy link
Contributor

ansibot commented Sep 19, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 9 errors:

lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: doc-missing-type: Argument 'description' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: doc-missing-type: Argument 'format' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: doc-missing-type: Argument 'kms_key_id' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: doc-missing-type: Argument 'role_name' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: doc-missing-type: Argument 's3_bucket' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: doc-missing-type: Argument 's3_key' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: doc-missing-type: Argument 'url' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: module-incorrect-version-added: version_added should be '2.10'. Currently '2.9'
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:0:0: parameter-type-not-in-doc: Argument 'wait_timeout' in argument_spec defines type as 'int' but documentation doesn't define type

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

lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py:135:1: E302: expected 2 blank lines, found 1

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. 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 Sep 19, 2019
Copy link
Contributor

@flowerysong flowerysong left a comment

Choose a reason for hiding this comment

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

I think ec2_snapshot_import might be a better name, to parallel ec2_snapshot_copy.

ec2_snapshot and ec2_snapshot_copy support setting tags on the created snapshot; it would be nice if this module had feature parity.

Since this is a new module it needs integration tests; see https://docs.ansible.com/ansible/devel/dev_guide/platforms/aws_guidelines.html#integration-tests-for-aws-modules

lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py Outdated Show resolved Hide resolved
lib/ansible/modules/cloud/amazon/ec2_import_snapshot.py Outdated Show resolved Hide resolved
@bcl
Copy link
Author

bcl commented Sep 20, 2019

I think ec2_snapshot_import might be a better name, to parallel ec2_snapshot_copy.

I wondered about that, either way is fine with me -- I was following the function name.

ec2_snapshot and ec2_snapshot_copy support setting tags on the created snapshot; it would be nice if this module had feature parity.

Looks like that's pretty easy to add.

Since this is a new module it needs integration tests; see https://docs.ansible.com/ansible/devel/dev_guide/platforms/aws_guidelines.html#integration-tests-for-aws-modules

This is a hard one, I think. In order to do that you need an ami file in a s3 bucket to import. I'm using this as part of https://weldr.io/lorax/lorax-composer.html so I can make my own images, but I have no idea how to do something like that with the ansible test infrastructure. So suggestions are welcome :)

@ansibot
Copy link
Contributor

ansibot commented Sep 23, 2019

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

lib/ansible/modules/cloud/amazon/ec2_snapshot_import.py:0:0: parameter-type-not-in-doc: Argument 'tags' in argument_spec defines type as 'dict' but documentation doesn't define type

click here for bot help

@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Sep 23, 2019
@ansibot
Copy link
Contributor

ansibot commented Sep 23, 2019

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

lib/ansible/modules/cloud/amazon/ec2_snapshot_import.py:0:0: invalid-documentation: DOCUMENTATION.options.tags.sample: extra keys not allowed @ data['options']['tags']['sample']. Got {'Name': 'Snapshot-Name'}

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Sep 23, 2019
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Sep 26, 2019
Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

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

Please add some integration tests.

[edit] Hmm, just seen the previous comments, ergh, not 100% sure how to test

if not url and not (s3_bucket and s3_key):
module.fail_json(msg='url or s3_bucket and s3key are required.')
if all([url, s3_bucket, s3_key]):
module.fail_json(msg='url or s3_bucket and s3key are required, not all 3.')
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests are made redundant by mutually_exclusive, required_one_of and required_together below.

This uses the boto3 import_snapshot function to import a disk image from
s3 as a snapshot. It also allows setting name:value tags on the new
snapshot.
@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 Oct 7, 2019
@ansibot ansibot added the stale_review Updates were made after the last review and the last review is more than 7 days old. label Oct 7, 2019
@ansibot
Copy link
Contributor

ansibot commented Jan 27, 2020

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jan 27, 2020
@ansibot
Copy link
Contributor

ansibot commented Mar 7, 2020

@BobBoldin @Constantin007 @Constantin07 @Deepakkothandan @Etherdaemon @Java1Guy @Madhura-CSI @MichaelBaydoun @Sodki @Zeekin @adq @aidan- @akazakov @alachaum @aljazkosir @amir343 @anryko @axc450 @bekelchik @brandond @captainkerk @carchi8py @chenl87 @defunctio @dennisconrad @dkhenry @fiunchinho @fivethreeo @flowerysong @garethr @gobins @gunzy83 @gurumaia @hsingh @hyperized @iiibrad @infectsoldier @j-carl @jarv @jimbydamonk @jmenga @joelthompson @jonhadfield @jonmer85 @jsdalton @jsmartin @kaczynskid @leedm777 @linuxdynasty @loia @lwade @markuman @matt-telstra @michaeljs1990 @miha-plesko @mikedlr @minichate @mjschultz @mmochan @mmoyle @mpechner @nand0p @naslanidis @nathanwebsterdotme @nerzhul @nickball @orthanc @ozbillwang @piontas @pjodouin @prasadkatti @psykotox @ptux @pwnall @raags @rafaeldriutti @rickmendes @roadmapper @rrey @ruimoreira @ryansydnor @sbj-ss @scicoin-project @scottanderson42 @sdubrul @shepdelacreme @silviud @slapula @stefanhorning @steynovich @tastychutney @tdekeyser @tgerla @timmahoney @tomislacker @tremble @tsiganenok @viper233 @waffie1 @whiter @willricardo @wilvk @wimnat @xlab-si @yaakov-github @zacblazic @zbal @zimbatm

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@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. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Mar 7, 2020
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_review Updates were made after the last review and the last review is more than 7 days old. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Mar 31, 2020
@ansibot ansibot added collection Related to Ansible Collections work collection:amazon.aws collection:community.aws needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md labels Apr 29, 2020
@ansibot
Copy link
Contributor

ansibot commented Aug 15, 2020

Thank you very much for your interest in Ansible. Ansible has migrated much of the content into separate repositories to allow for more rapid, independent development. We are closing this issue/PR because this content has been moved to one or more collection repositories.

For further information, please see:
https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md

@ansibot ansibot closed this Aug 15, 2020
@ansible ansible locked and limited conversation to collaborators Sep 12, 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 aws bot_closed cloud collection:community.aws collection Related to Ansible Collections work module This issue/PR relates to a module. needs_collection_redirect https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_contributor This PR is the first contribution by a new community member. new_module This PR includes a new module. new_plugin This PR includes a new plugin. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. 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.

None yet

4 participants