first cut of the playbook to create and provision any instance

This commit is contained in:
Seth Vidal 2012-10-30 22:12:48 +00:00
parent 81de1b7721
commit 70f0a522b0
2 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,33 @@
- name: check/create instance
hosts: lockbox01.phx2.fedoraproject.org
user: root
gather_facts: False
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- ${private}/vars.yml
vars:
- keypair: admin
- image: emi-B8793915
- instance_type: m1.large
- security_group: default
tasks:
- include: $tasks/transient_cloud.yml
- name: provision instance
hosts: tmp_just_created
user: root
gather_facts: True
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- ${private}/vars.yml
- ${vars}/${ansible_distribution}.yml
tasks:
- include: $tasks/cloud_setup_basic.yml
handlers:
- include: $handlers/restart_services.yml

15
tasks/transient_cloud.yml Normal file
View file

@ -0,0 +1,15 @@
---
- name: spin it up
local_action: ec2_create keypair=${keypair} image=${image} type=${instance_type} wait=true group=${security_group}
register: inst_res
- name: add it to the special group
local_action: add_host hostname=${inst_res.instances[0].public_ip} groupname=tmp_just_created
- name: mail off about where it is
local_action: mail to=sysadmin-main-members@fedoraproject.org from=ansible-create@fedoraproject.org subject=${inst_res.instances[0].public_ip} msg="cloud instance created on ${inst_res.instances[0].public_ip} instance id: ${instance_res.instances[0].id} "
- name: wait for the host to be hot
local_action: wait_for host=${inst_res.instances[0].public_ip} port=22 delay=20 timeout=300