Open paulogodinhoaq opened 2 years ago
Files identified in the description:
plugins/modules/ec2_instance.py
](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/ec2_instance.py)If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
cc @jillr @ryansb @s-hertel @tremble click here for bot help
I have confirmed that manually setting the vpc_subnet_id
is an workaround, but I believe the module should not imply default subnet when dealing with templates.
This works:
- name: Spawn Machine
amazon.aws.ec2_instance:
state: running
name: "[Spawned From Ansible] Test Micro Machine"
vpc_subnet_id: 'subnet-0c5a581319a69910a'
launch_template:
id: "lt-0c7678a944ceeac69"
version: 3
Cheers.
It looks like the "instance_type": "t2.micro"
is also being sent, even if the template has the instance type properly set. The workaround is to also send the matching instance_type
in the module usage.
Only way to currently use Launch Templates currently, specifying both vpc_subnet_id
and instace_type
- name: Spawn Machine
amazon.aws.ec2_instance:
state: running
name: "[Spawned From Ansible] Windows for Custom Unreal AMI Creation"
vpc_subnet_id: 'subnet-0c5a581319a69910a'
instance_type: 'c5.2xlarge'
launch_template:
id: "lt-03714509be6768d02"
version: 2
register: ec2spawnedmachines
Hi @paulogodinhoaq,
You're using a rather oudated copy of amazon.aws. May I ask you to update, just to validate the behaviour you describe is still the same.
Hi @paulogodinhoaq,
You're using a rather oudated copy of amazon.aws. May I ask you to update, just to validate the behaviour you describe is still the same.
Interesting, I had just recently installed ansible using pip
, I thought the "packages" would come with the latest version, what would be the correct way to update it?
Cheers
Hi @paulogodinhoaq, You're using a rather oudated copy of amazon.aws. May I ask you to update, just to validate the behaviour you describe is still the same.
Interesting, I had just recently installed ansible using
pip
, I thought the "packages" would come with the latest version, what would be the correct way to update it?Cheers
Hi @paulogodinhoaq
Try using ansible-galaxy collection install git+https://github.com/ansible-collections/amazon.aws.git
Summary
When launching an instance from a template, the module will try to use the default subnet instead of the one set inside the actual template, conflicting with the Security Group set inside the template and failing to instantiate the machine.
Task:
Run Command:
ansible-playbook setup_machine.yml --connection=local -vvv
The default subnet is used in the call as it is visible bellow, it should not send a subnet unless one is specified as the template already has one defined.
This Launch Template works without issue through the AWS CLI directly
Issue Type
Bug Report
Component Name
ec2_instance
Ansible Version
Collection Versions
AWS SDK versions
Configuration
OS / Environment
Ubuntu 22.04 LTS on WSL - Windows 10 x86_64
Steps to Reproduce
Task:
Run Command:
ansible-playbook setup_machine.yml --connection=local -vvv
Expected Results
Machine is created
Actual Results
It is for some reason it is sending the default subnet
"subnet-id": "subnet-008c094dfe760bda4"
inside the request which conflicts with the Security Group set in the template, failing to create the machine.