Hi ansible squad! I've been using amazon.aws.ec2 (or community.aws.ec2_instance - ive been switching back and forth) to ensure there is an ec2 instance created for each {{ inventory_hostname }} by using tags. It doesn't seem to work.
Every time I run the playbook with the below play, it just creates a new ec2 instance? How can I make it more idempotent? If the instance already exists, dont create a new one? Preferably without other plays? - name: Ensure EC2 instance exists amazon.aws.ec2: aws_access_key: '{{ aws_access_key }}' aws_secret_key: '{{ aws_secret_key }}' region: '{{ aws_region }}' image: '{{ aws_ec2_ami }}' instance_type: '{{ aws_instance_type_web }}' vpc_subnet_id: '{{ aws_subnet_id }}' group: 'SG-{{ environment_designator }}' key_name: 'Keypair-{{ environment_designator }}' instance_tags: Mytag.MyEnvironment: "" Mytag.MyEnvironment.Environment: '{{ environment_designator }}' Mytag.MyEnvironment.Roles: web1 Mytag.MyEnvironment.Hostname: '{{ inventory_hostname }}' wait: yes assign_public_ip: no register: ec2_instances delegate_to: localhost -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d8aedb06-f63e-4ebc-8dd6-8134b72a1a07n%40googlegroups.com.