Skip to content
Snippets Groups Projects
Commit b463b7e7 authored by jurgenhaas's avatar jurgenhaas
Browse files

initial commit

parents
No related branches found
No related tags found
No related merge requests found
##
# Ansible playbook for managing an ec2 inventory
---
# file: ec2/inithost.yml
- name: "Create the new instance"
ec2:
instance_tags: '{"Name":"Ansible-Host-{{ host }}","AnsibleHost":"{{ host }}","AnsibleGroups":"{{ initgroups }}"}'
assign_public_ip: yes
group_id: "{{ ec2_group_id }}"
key_name: "{{ ec2_key_name }}"
image: "{{ ec2_ami_id }}"
instance_type: "{{ ec2_instance_type }}"
vpc_subnet_id: "{{ ec2_subnet_id }}"
region: "{{ ec2_region }}"
state: present
wait: yes
register: ec2
- name: "Waiting for the new instance(s) to get up and running"
ec2:
instance_ids: "{{ ec2.instance_ids }}"
instance_type: "{{ ec2_instance_type }}"
region: "{{ ec2_region }}"
state: running
wait: yes
- name: "Add new instance(s) to the inventory"
add_host:
hostname="{{ host }}"
static_ipv4="{{ item.public_ip }}"
groups="{{ initgroups }}"
with_items: ec2.instances
- name: "Waiting for SSH service becoming available"
wait_for:
host="{{ item.public_ip }}"
port=22
delay=10
timeout=120
state=present
with_items: ec2.instances
##
# Ansible playbook for managing an ec2 inventory
---
# file: ec2/removehost.yml
- name: "Terminate the instance"
ec2:
instance_ids: "{{ ec2_id }}"
instance_type: "{{ ec2_instance_type }}"
region: "{{ ec2_region }}"
state: absent
wait: yes
when: are_you_sure == "YES"
---
# file: roles/cloud/tasks/main.yml
- include: "{{ cloud|default('none') }}/{{ mode }}.yml"
##
# Dummy Ansible playbook
---
# file: none/inithost.yml
- name: "No cloud action required"
debug: msg="IGNORE inithost"
##
# Dummy Ansible playbook
---
# file: none/removehost.yml
- name: "No cloud action required"
debug: msg="IGNORE removehost"
when: are_you_sure == "YES"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment