-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Autoscaling Groups Lifecycle Hooks module #22412
Conversation
The test
|
The test
The test
The test
|
@tsiganenok I restarted CI for this PR since the bot didn't pick up all the errors the first time. |
role_arn=dict(type='str'), | ||
notification_target_arn=dict(type='str'), | ||
notification_meta_data=dict(type='str'), | ||
heartbeat_timeout=dict(type='str'), |
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.
If this is set to type='int' this should avoid the later type conversion
The test
The test
The test
|
@Etherdaemon @Java1Guy @akazakov @alachaum @amir343 @bekelchik @bpennypacker @brandond @fiunchinho @j-carl @jarv @jmenga @joelthompson @jsdalton @linuxdynasty @loia @MichaelBaydoun @michaeljs1990 @minichate @mjschultz @mmochan @naslanidis @pjodouin @pwnall @RickMendes @rmorlok @ryansydnor @scottanderson42 @silviud @simplesteph @steynovich @tastychutney @tedder @timmahoney @TomBamford @whiter @willthames @wimnat @Zeekin 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 |
+1 |
+1 |
+1 very useful |
@tsiganenok this PR contains the following merge comits: Please rebase your branch to remove these commits. |
Hope this makes it into 2.4.0. Looks super useful. |
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 looks like a helpful module to have. Thanks for the time and effort you've spent on it!
module: ec2_asg_lifecycle_hook | ||
short_description: Create, delete or update AWS ASG Lifecycle Hooks. | ||
description: | ||
- Can create, delete or update Lifecycle Hooks for AWS Autoscaling Groups. |
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.
Can you add a more thorough description?
try: | ||
import boto3 | ||
import botocore | ||
HAS_BOTO3 = True |
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 import this from ansible.module_utils.ec2 instead of manually setting it here and in the except ImportError.
''' | ||
|
||
RETURN = ''' | ||
|
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.
Can you document what the returns look like?
I think this is fine since there isn't any helpful data returned by the boto3 calls. Maybe a facts module would be nice later.
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.
So I'm leaving it as is?
if changed: | ||
try: | ||
connection.put_lifecycle_hook(**lch_params) | ||
except Exception as e: |
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.
It would better to catch botocore.exceptions.ClientError instead of Exception.
if default_result: | ||
lch_params['DefaultResult'] = default_result | ||
|
||
existing_hook = connection.describe_lifecycle_hooks( |
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.
It would be good to have a try/except around this call.
lch_name = module.params.get('lifecycle_hook_name') | ||
asg_name = module.params.get('autoscaling_group_name') | ||
|
||
all_hooks = connection.describe_lifecycle_hooks( |
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.
It would be good to have a try/except around this call.
try: | ||
connection.delete_lifecycle_hook(**lch_params) | ||
changed = True | ||
except Exception as e: |
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.
Catch botocore.exceptions.ClientError instead of Exception here too.
connection = boto3_conn(module, conn_type='client', resource='autoscaling', region=region, endpoint=ec2_url, **aws_connect_params) | ||
if not connection: | ||
module.fail_json(msg="failed to connect to AWS for the given region: %s" % str(region)) | ||
except boto.exception.NoAuthHandlerFound as e: |
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 should be botocore.exceptions.NoCredentialsError.
@s-hertel Sorry for the time it took, but finally I fixed everything you asked. |
@ryansb Hi, is this going to be merged or do I need to fix / change anything? |
Merged, thanks for this @tsiganenok. This will indeed be very useful. |
Didn't spot the stale_ci, oops. Should have reran the tests. I'll push a new PR shortly for the fixes. |
#34379 added to fix some of the problems that would have occurred had tests been rerun. |
SUMMARY
New module which allows managing ASG Lifecycle hooks.
ISSUE TYPE
COMPONENT NAME
ec2_asg_lifecycle_hook
ANSIBLE VERSION
[root@localhost playbooks]# ansible --version
ansible 2.2.1.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
ADDITIONAL INFORMATION
There is no module allowing Lifecycle Hooks management for AWS Autoscaling Groups for now.
More about Lifecycle Hooks: http://docs.aws.amazon.com/autoscaling/latest/userguide/lifecycle-hooks.html
It uses boto3 and there is no separate documentation for hooks, but only in autoscaling section:
http://boto3.readthedocs.io/en/latest/reference/services/autoscaling.html