Hi guys,
I need to set up some ec2 instances for my project and I am in the process of doing proof of concept.
My playbook creates an aws ec2 instance and I am using an already created security group that includes ssh however for some reason it is failing to open the port 22.
launch_east_cost_ec2.yml:
- name: Launch new EC2 instance
hosts: localhost
connection: local
gather_facts: false
vars:
pem: keyname
reg: us-east-1
tasks:
- name: create ec2 instance with default values
ec2:
instance_type: t2.micro
image: ami-xxxxxxxxxxx
region: “{{ reg }}”
keypair: “{{ pem }}”
aws_access_key: xx
aws_secret_key: xxxxxxxxxxx - name: add ssh to ec2
ec2_group:
name: setup_ssh_connection
description: a setup ssh connection for ec2
vpc_id: vpc-xxxx
region: “{{ reg }}”
rules: - proto: tcp
ports: - 22
cidr_ip: 0.0.0.0/0
group_id: xxxxx - name: wait for rsystem to become reachable
wait_for_connection:
timeout: 3600 → i changed to few different values but no luck.
Output:
TASK [add ssh to ec2] ************************************************************************************************************************************************************************
[WARNING]: Ran out of time waiting for sg-xxxxx IpPermissions. Current: set([Rule(port_range=(22, 22), protocol=u’tcp’, target=(‘2345423355’, ‘sg-xxxxxxxxxx’, None),
target_type=‘group’, description=None), Rule(port_range=(22, 22), protocol=u’tcp’, target=‘0.0.0.0/0’, target_type=‘ipv4’, description=None)]), Desired: [Rule(port_range=(22, 22),
protocol=u’tcp’, target=‘sg-xxxxxxxxxx’, target_type=‘group’, description=None), Rule(port_range=(22, 22), protocol=u’tcp’, target=‘0.0.0.0/0’, target_type=‘ipv4’, description=None)]
changed: [localhost]
TASK [wait fo rsystem to become reachable] ***************************************************************************************************************************************************
[WARNING]: Reset is not implemented for this connection
ok: [localhost]
PLAY RECAP ***********************************************************************************************************************************************************************************
localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Please advise what is missing.
Thank you in advance.
Sanjay