Commit graph

92 commits

Author SHA1 Message Date
Christopher Kotfila
2632aa630f Unpack AWS reservations while waiting to terminate (#4012)
Previously calculation of the number of instances that have been
terminated assumed all instances were in the first reservation returned
by AWS.  If this is not the case the calculated number of instances
terminated never reaches the number of instances and the module always
times out. By unpacking the instances we get an accurate number and the
module correctly exits.
2016-09-13 15:07:14 -04:00
Ryan Brown
ae6992bf8c Handle EC2 instances with multiple network interfaces (#4766)
Currently instances with multiple ENI's can't be started or stopped
because sourceDestCheck is a per-interface attribute, but we use the
boto global access to it (which only works when there's a single ENI).

This patch handles multiple ENI's and applies the sourcedestcheck across
all interfaces the same way.

Fixes #3234
2016-09-12 18:26:13 -04:00
Ryan Brown
819fe45864 Fix failure when powering on/off EC2 instances by tag only. (#4767)
If you apply `wait=yes` and use `instance_tags` as your filter for
stopping/starting EC2 instances, this stack trace happens:

```
An exception occurred during task execution. The full traceback is:                                                                          │~
Traceback (most recent call last):                                                                                                           │~
  File "/tmp/ryansb/ansible_FwE8VR/ansible_module_ec2.py", line 1540, in <module>                                                            │~
    main()                                                                                                                                   │~
  File "/tmp/ryansb/ansible_FwE8VR/ansible_module_ec2.py", line 1514, in main                                                                │~
    (changed, instance_dict_array, new_instance_ids) = startstop_instances(module, ec2, instance_ids, state, instance_tags)                  │~
  File "/tmp/ryansb/ansible_FwE8VR/ansible_module_ec2.py", line 1343, in startstop_instances                                                 │~
    if len(matched_instances) < len(instance_ids):                                                                                           │~
TypeError: object of type 'NoneType' has no len()                                                                                            │~
                                                                                                                                             │~
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "ec2"}, "module_stderr": "Traceb│~
ack (most recent call last):\n  File \"/tmp/ryansb/ansible_FwE8VR/ansible_module_ec2.py\", line 1540, in <module>\n    main()\n  File \"/tmp/│~
ryansb/ansible_FwE8VR/ansible_module_ec2.py\", line 1514, in main\n    (changed, instance_dict_array, new_instance_ids) = startstop_instances│~
(module, ec2, instance_ids, state, instance_tags)\n  File \"/tmp/ryansb/ansible_FwE8VR/ansible_module_ec2.py\", line 1343, in startstop_insta│~
nces\n    if len(matched_instances) < len(instance_ids):\nTypeError: object of type 'NoneType' has no len()\n", "module_stdout": "", "msg": "│~
MODULE FAILURE", "parsed": false}
```

That's because the `instance_ids` variable is None if not supplied
in the task. That means the instances that result from the instance_tags
query aren't going to be included in the wait loop. To fix this, a list
needs to be kept of instances with matching tags and that list needs to
be added to `instance_ids` before the wait loop.
2016-09-09 19:38:05 -04:00
Abhijit Menon-Sen
55d51b3946 Fix spot instance creation by ignoring instance_initiated_shutdown_behavior (#4741)
Before this, all spot instance requests would fail because the code
_always_ called module.fail_json when the parameter was set (which it
always was, because the module parameter's default was set to 'stop').

As the comment said, this parameter doesn't make sense for spot
instances at all, so the error message was also misleading.
2016-09-08 12:33:36 -04:00
Florian Dambrine
aac55fcc62 Fix ec2 module source_dest_check when running on non VPC instances (EC2 Classic) (#3243) 2016-09-08 12:25:17 +02:00
Ilja Bauer
acb7d873f8 Replaced use of bare variables with full variable syntax (#4149) 2016-08-27 17:11:42 +02:00
Richard Adams
c8ca1a6211 Add parameter to ec2 module to control instance shutdown behavior (stop|terminate) 2016-08-24 13:34:48 -04:00
Ryan Brown
4845c96b00 Remove double-assignment of EC2 parameters (#4081)
The `source_dest_check` and `termination_protection` variables are being
assigned twice in ec2.py, likely due to an incorrect merge somewhere
along the line.
2016-06-30 09:47:06 -04:00
codemeup @ Work
5b1ab46265 Fixing error exception handling for python. Does not need to be compatible with Python2.4 b/c boto is Python 2.6 and above. (#3839) 2016-06-02 11:20:04 -07:00
hyperized
507d083d08 Added restart functionality to ec2.py 2016-05-04 09:12:02 +02:00
Toshio Kuratomi
1c4da434c7 Merge pull request #2421 from willthames/ec2_fix_vpc_security_token
Use connect_to_aws where possible
2016-03-04 11:06:22 -08:00
Daniel Petty
e256ae0683 replaced sudo with become 2016-02-18 16:18:59 -07:00
jjshoe
b0cbae51b5 Less engrish 2016-02-08 19:03:35 -06:00
Michael Baydoun
98c16a4f1f Update ec2.py
Documentation is not clear that tag used in count_tags must be an existing instance_tag
2016-02-08 19:14:19 -05:00
techraf
2016d3d822 Fixed typo in example playbook 2016-01-19 20:45:50 +09:00
Brian Coca
15dcabe012 Merge pull request #2541 from joshuaeke/patch-1
Update ec2.py remove state tag
2015-12-05 10:12:55 -05:00
Arthur Clement
bfcdb05597 Example of single instance with ssd gp2 root volume creation 2015-12-03 22:48:13 +01:00
joshuaeke
ab420300ef Update ec2.py remove state tag
'exact_count' and 'state' are mutually exclusive options they should not be in the following examples:
- # Enforce that 5 running instances named "database" with a "dbtype" of "postgres" example and 
- # Enforce that 5 instances with a tag "foo" are running
2015-11-24 18:48:59 +00:00
Toshio Kuratomi
8ae30f1822 Minor simplification of code 2015-11-23 16:23:41 -08:00
Toshio Kuratomi
5617cd57cf Merge pull request #2512 from erewh0n/ec2-require-all-groups
Fail ec2 module when group names cannot resolve to IDs
2015-11-23 16:20:31 -08:00
Brian Coca
6bd8020f65 corrected version_added, removed empty alias 2015-11-24 09:32:46 -08:00
Brian Coca
b789db7b9d Merge pull request #2211 from kai11/feature/spot_launch_group
Added launch group support for ec2 module
2015-11-23 09:31:33 -08:00
Keith Hassen
39ef6a1a80 Fail if any group name is not resolved to an ID. 2015-11-22 22:07:47 -05:00
Will Thames
0dd58e9326 Use connect_to_aws where possible
`connect_to_aws` fixes a bug with security tokens in AWS.
Modules should use that rather than calling
`boto.x.connect_to_region`
2015-11-06 19:05:01 +10:00
Brian Coca
3aee4b9469 Merge pull request #2326 from jibsheet/devel
Mark this as a string so it is rendered in the docs
2015-11-03 13:10:15 -05:00
Brian Coca
59b87836d1 Merge pull request #2222 from pgilad/patch-1
Add state=running on some ec2 examples
2015-11-02 19:12:25 -05:00
Kevin Falcone
735eefb2ca Mark this as a string so it is rendered in the docs
When this was treated as a boolean, sphinx was leaving the Default
column on http://docs.ansible.com/ansible/ec2_module.html blank,
implying it would use AWS's default.  In reality, it passes False, which
overrides the defaults at AWS (it's possible to boot an instance which
AWS claims will always have EBS optimization without it because of this
silently passed False).
2015-10-21 16:43:50 -04:00
Brian Coca
f1fc76d732 Merge pull request #2214 from fperks/fix-ec2-error-on-instance-status-change
Fix error on ec2 status change
2015-10-12 18:38:10 -04:00
Abhijit Menon-Sen
ebd8b12e15 Add missing variable initializations
Without this, «ec2: state=stopped instance_ids=…» would fail with a
traceback like this:

    if inst.get_attribute('sourceDestCheck')['sourceDestCheck'] != source_dest_check:
NameError: global name 'source_dest_check' is not defined
2015-10-11 07:25:56 +05:30
fperks
7fd3262c3c Fix error on ec2 status change
Both `source_dest_check` and `termination_protection` variables are not
available within the scope of the startstopec2 instance method. This just
pulls them from module.params.
2015-10-07 13:43:57 -04:00
Gilad Peleg
5f914e854b Add state=running on some ec2 examples
`state=running` was missing in some of the ec2 module examples
2015-10-07 14:49:05 +03:00
Kai Webber
d0b30dd86d Added launch group support for ec2 module 2015-10-06 20:26:10 +03:00
Gerard Lynch
1857263b63 allow use of volume_type in volumes dict 2015-09-28 17:02:46 +01:00
Brian Coca
c4140cc6db Merge pull request #2021 from h3biomed/enis_at_launch
ec2: allow ENIs to be specified at instance launch
2015-09-08 12:45:05 -04:00
Yanchek99
7104096c7c Fixed typo for instance_tags documentation 2015-09-08 09:16:53 -07:00
Bret Martin
27e9318ffe Use general-purpose parameter mutual exclusion code for network_interfaces 2015-09-06 14:00:35 -04:00
Bret Martin
44f3618dd3 Add alias network_interface and accept a string for a single ENI 2015-09-06 13:53:28 -04:00
Bret Martin
5db3f14e94 Add network_interfaces example 2015-09-06 13:18:20 -04:00
Bret Martin
a20a78a50c Remove aliases specification from documentation since there are none 2015-09-06 13:03:04 -04:00
Bret Martin
eaa45dcbd9 Add network_interfaces parameter to ec2 module to support launch-time ENIs 2015-09-04 19:44:35 -04:00
Benno Joy
66288d48a2 Merge pull request #1703 from haad/ec2_start_stop_by_tag
Rebase start/stop by instance tag
2015-08-27 14:46:54 +05:30
James Cammarata
85ddb1b902 Fixing region requirement regarding euca clusters
Fixes ansible/ansible#11023
2015-08-22 12:32:40 -04:00
HAMSIK Adam
dfac073343 Rebase start/stop instance pull code 2015-08-18 14:32:48 +02:00
Brian Coca
481f300836 clarified error messages to actually give back ansible module option instead of internal boto field name 2015-07-24 23:32:41 -04:00
Jens Carl
fd0fc5131c Fix missing alias "groups". 2015-07-24 22:06:56 +00:00
vanga
164043bd6d Throw error if encryption is set while passing a snapshot id 2015-07-09 20:42:54 +05:30
Juho-Mikko Pellinen
b4911a47d1 Change the default flag value to None to prevent AWS complaining: "Instance creation failed => InvalidBlockDeviceMapping: the encrypted flag cannot be specified since device /dev/sda1 has a snapshot specified." 2015-07-07 16:31:47 +03:00
James Cammarata
65c63b3afa Updating version_added for new spot_type param in ec2 module
Also made sure 'choices' were set on the module param, to catch errors
in user's playbooks, etc.
2015-06-24 14:43:04 -04:00
Jay Taylor
dbed8cee3b Added support for spot request type specification (to support persistent spot requests). 2015-06-24 08:23:52 -07:00
Toshio Kuratomi
a1538b490e Fix documentation 2015-06-23 08:57:06 -07:00