- name: check/create instance hosts: lockbox01.phx2.fedoraproject.org user: root gather_facts: False vars: - keypair: admin - image: emi-B8793915 - instance_type: c1.medium - security_group: default tasks: - name: spin it up local_action: ec2 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}\n instance id - ${inst_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=5 timeout=300 - name: provision instance hosts: tmp_just_created user: root gather_facts: True tasks: - name: update all action: command yum -y update tags: - packages - name: ntpdate install action: yum state=installed pkg=ntpdate tags: - packages - name: sync time - just once action: command /usr/sbin/ntpdate -s -b 66.187.233.4 - name: edit hostname to be instance name - prefix hostbase var if it exists action: shell hostname ${hostbase}`curl -s http://169.254.169.254/latest/meta-data/instance-id` tags: - config - name: put sysadmin-main in place for sshing in action: copy src=files/common/sysadmin-main dest=/root/.ssh/authorized_keys mode=600 backup=true tags: - config - name: add root keys for other allowed users action: authorized_key user=root key='$PIPE(scripts/auth_keys_from_fas.py ${root_auth_users})' only_if: is_set('${root_auth_users}') tags: - config # note - kinda should be a handler - but handlers need args - name: restorecon action: command restorecon -R /root/.ssh tags: - config - name: put /dev/vda2 up as /mnt action: mount name=/mnt src=/dev/vda2 fstype=ext3 passno=1 dump=1 state=mounted handlers: - include: handlers/restart_services.yml