mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Added an integration test for the ec2_asg module
This commit is contained in:
parent
26aaa7bcdd
commit
73c1ccf53e
3 changed files with 47 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
||||||
#- { role: test_ec2_eip, tags: test_ec2_eip }
|
#- { role: test_ec2_eip, tags: test_ec2_eip }
|
||||||
#- { role: test_ec2_ami, tags: test_ec2_ami }
|
#- { role: test_ec2_ami, tags: test_ec2_ami }
|
||||||
#- { role: test_ec2, tags: test_ec2 }
|
#- { role: test_ec2, tags: test_ec2 }
|
||||||
|
- { role: test_ec2_asg, tags: test_ec2_asg }
|
||||||
|
|
||||||
# complex test for ec2_elb, split up over multiple plays
|
# complex test for ec2_elb, split up over multiple plays
|
||||||
# since there is a setup component as well as the test which
|
# since there is a setup component as well as the test which
|
||||||
|
|
|
@ -117,13 +117,22 @@ if __name__ == '__main__':
|
||||||
elb = boto.connect_elb(aws_access_key_id=opts.ec2_access_key,
|
elb = boto.connect_elb(aws_access_key_id=opts.ec2_access_key,
|
||||||
aws_secret_access_key=opts.ec2_secret_key)
|
aws_secret_access_key=opts.ec2_secret_key)
|
||||||
|
|
||||||
|
asg = boto.connect_autoscale(aws_access_key_id=opts.ec2_access_key,
|
||||||
|
aws_secret_access_key=opts.ec2_secret_key)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Delete matching keys
|
# Delete matching keys
|
||||||
delete_aws_resources(aws.get_all_key_pairs, 'name', opts)
|
delete_aws_resources(aws.get_all_key_pairs, 'name', opts)
|
||||||
|
|
||||||
# Delete matching groups
|
# Delete matching security groups
|
||||||
delete_aws_resources(aws.get_all_security_groups, 'name', opts)
|
delete_aws_resources(aws.get_all_security_groups, 'name', opts)
|
||||||
|
|
||||||
|
# Delete matching ASGs
|
||||||
|
delete_aws_resources(asg.get_all_groups, 'name', opts)
|
||||||
|
|
||||||
|
# Delete matching launch configs
|
||||||
|
delete_aws_resources(asg.get_all_launch_configurations, 'name', opts)
|
||||||
|
|
||||||
# Delete ELBs
|
# Delete ELBs
|
||||||
delete_aws_resources(elb.get_all_load_balancers, 'name', opts)
|
delete_aws_resources(elb.get_all_load_balancers, 'name', opts)
|
||||||
|
|
||||||
|
|
36
test/integration/roles/test_ec2_asg/tasks/main.yml
Normal file
36
test/integration/roles/test_ec2_asg/tasks/main.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
# tasks file for test_ec2_asg
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# create and kill an ASG
|
||||||
|
- name: lookup ami id
|
||||||
|
ec2_ami_search: distro=ubuntu region={{ ec2_region }} release=trusty
|
||||||
|
register: ubuntu_image
|
||||||
|
- name: ensure launch config exists
|
||||||
|
ec2_lc:
|
||||||
|
name: "{{ resource_prefix }}-lc"
|
||||||
|
ec2_access_key: "{{ ec2_access_key }}"
|
||||||
|
ec2_secret_key: "{{ ec2_secret_key }}"
|
||||||
|
region: "{{ ec2_region }}"
|
||||||
|
image_id: "{{ ubuntu_image.ami }}"
|
||||||
|
instance_type: t1.micro
|
||||||
|
- name: launch asg
|
||||||
|
ec2_asg:
|
||||||
|
name: "{{ resource_prefix }}-asg"
|
||||||
|
ec2_access_key: "{{ ec2_access_key }}"
|
||||||
|
ec2_secret_key: "{{ ec2_secret_key }}"
|
||||||
|
launch_config_name: "{{ resource_prefix }}-lc"
|
||||||
|
min_size: 1
|
||||||
|
max_size: 1
|
||||||
|
region: "{{ ec2_region }}"
|
||||||
|
state: present
|
||||||
|
- name: pause for a bit to make sure that the group can't be trivially deleted
|
||||||
|
pause: seconds=30
|
||||||
|
- name: kill asg
|
||||||
|
ec2_asg:
|
||||||
|
name: "{{ resource_prefix }}-asg"
|
||||||
|
ec2_access_key: "{{ ec2_access_key }}"
|
||||||
|
ec2_secret_key: "{{ ec2_secret_key }}"
|
||||||
|
region: "{{ ec2_region }}"
|
||||||
|
state: absent
|
||||||
|
async: 300
|
Loading…
Reference in a new issue