Has anyone been able to provision EC2 instances with multiple security groups associated with one instance?
When I do something like
- name: launch
local_action:
module: ec2
region: us-west-2
keypair: mykey
group_id: [sg-xx, sg-yy, sg-zz]
instance_type: t1.micro
image: ami-70f96e40
wait: yes
wait_timeout: 3500
count: 2
instance_tags: ‘{“Name”:“stuff”}’
register: ec2batch
But the final instance that gets created only has one security group associated with it.
I was using group_id because “group” did not seem to find my security group. When I did
- name: launch socialkit settings-scrape instances
local_action:
module: ec2
region: us-west-2
keypair: memelabs
group: [mygroup1, mygroup2, mygroup3]
instance_type: t1.micro
image: ami-70f96e40
wait: yes
wait_timeout: 3500
count: 2
instance_tags: ‘{“Name”:“stuff”}’
register: ec2batch
It would give me an error that unable to find security group by that name.
My env:
Ansible 1.2.1
Boto 2.9.9
Per the docs it’s “group”, not group_id.
I’ll defer the question of why it might not find your group to other EC2 experts.
group:
description:
- security group (or list of groups) to use with the instance
required: false
default: null
aliases: [ ‘groups’ ]
group_id:
version_added: “1.1”
description:
- security group id to use with the instance
required: false
default: null
aliases:
The “group_id” argument (for the sg### aws identifiier) only accepts a single ID as a string where the “group” argument (the human friendly name of the group) will take either a string or list.
It does seem inconstant, if we are allowing a list of items for the singular “group” we might as well for the “group_id” I think.
If it’s having trouble looking up your group by name it’s likely you have bigger problems, maybe check that you are using the correct region?
-John
There is a PR that I expect will soon be merged which fixes the list of groups or group id’s with the ec2 module. I would link to it but travelling and using the mobile right now