Skip to content

Instantly share code, notes, and snippets.

@nleiva
Created June 30, 2021 21:16
Show Gist options
  • Save nleiva/08af163a6e87d0b29251c731cdd2a0a7 to your computer and use it in GitHub Desktop.
Save nleiva/08af163a6e87d0b29251c731cdd2a0a7 to your computer and use it in GitHub Desktop.
- name: Add instance(s) to my_instances group
ansible.builtin.add_host:
name: "{{ item.tags.Name }}"
ansible_host: "{{ item.public_ip_address }}"
ansible_user: "{{ ec2_username }}"
private_ip: "{{ item.private_ip_address }}"
instance_name: "{{ ec2_resource_prefix }}"
ansible_ssh_private_key_file: "{{ playbook_dir }}/{{ ec2_resource_prefix }}-private.pem"
instance_ssh: "{{ ssh_info }}"
groups:
- my_instances
with_items: "{{ ansible_node_facts.instances }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment