2015-06-23 06:31:42 +00:00
|
|
|
# New tasks to spin up instance in https://fedorainfracloud.org
|
2012-10-30 22:12:48 +00:00
|
|
|
|
2015-05-13 23:12:42 +00:00
|
|
|
- name: spin UP VM using nova_compute
|
2016-02-02 21:24:45 +00:00
|
|
|
become: False
|
2015-05-13 23:12:42 +00:00
|
|
|
local_action:
|
|
|
|
security_groups: all-icmp-transient,web-80-anywhere-transient,web-443-anywhere-transient,ssh-anywhere-transient,default
|
2015-06-05 12:01:09 +00:00
|
|
|
# transient-net
|
2016-06-22 19:09:05 +00:00
|
|
|
nics:
|
2016-08-15 02:53:38 +00:00
|
|
|
- net-id: 96e0590b-e572-4340-9408-ce4d4e4f4536
|
2015-05-13 23:12:42 +00:00
|
|
|
name: "{{ name }}"
|
|
|
|
module: nova_compute
|
|
|
|
auth_url: "{{os_auth_url}}"
|
|
|
|
login_username: "admin"
|
|
|
|
login_password: "{{ADMIN_PASS}}"
|
|
|
|
login_tenant_name: transient
|
|
|
|
image_id: "{{ image|image_name_to_id('admin', ADMIN_PASS, 'transient', os_auth_url) }}"
|
|
|
|
wait_for: 300
|
|
|
|
flavor_id: "{{ instance_type|flavor_name_to_id('admin', ADMIN_PASS, 'transient', os_auth_url) }}"
|
|
|
|
key_name: fedora-admin-20130801
|
|
|
|
auto_floating_ip: true
|
|
|
|
user_data: "#cloud-config\ndisable_root: 0"
|
|
|
|
register: nova_result
|
2012-10-30 22:12:48 +00:00
|
|
|
|
2015-05-13 23:12:42 +00:00
|
|
|
- name: add it to the special group
|
2016-10-03 21:30:51 +00:00
|
|
|
local_action: add_host hostname="{{ nova_result.public_ip }}" groupname=tmp_just_created
|
2013-04-23 22:05:53 +00:00
|
|
|
|
2012-10-30 22:12:48 +00:00
|
|
|
- name: mail off about where it is
|
2016-08-08 19:36:31 +00:00
|
|
|
local_action: mail
|
|
|
|
to=sysadmin-main-members@fedoraproject.org
|
2015-05-13 23:18:07 +00:00
|
|
|
from=ansible-create@fedoraproject.org
|
2016-10-03 21:30:51 +00:00
|
|
|
subject="{{ nova_result.public_ip }}"
|
|
|
|
body="transient cloud instance created on {{ nova_result.public_ip }}
|
2015-05-13 23:18:07 +00:00
|
|
|
name = {{ name }}
|
2015-05-13 23:28:31 +00:00
|
|
|
root_auth_users = {{ root_auth_users }}
|
2015-05-13 23:18:07 +00:00
|
|
|
image = {{ image }}"
|
2012-10-30 22:12:48 +00:00
|
|
|
|
2015-05-13 23:12:42 +00:00
|
|
|
- name: wait for he host to be hot
|
2016-10-03 21:30:51 +00:00
|
|
|
local_action: wait_for host={{ nova_result.public_ip }} port=22 delay=1 timeout=600
|
2012-10-30 22:12:48 +00:00
|
|
|
|
2015-05-28 19:58:02 +00:00
|
|
|
- name: gather ssh host key from new instance
|
2016-10-03 21:30:51 +00:00
|
|
|
local_action: command ssh-keyscan -t rsa {{ nova_result.public_ip }}
|
2015-05-28 19:58:02 +00:00
|
|
|
ignore_errors: True
|
|
|
|
register: hostkey
|
|
|
|
|
|
|
|
- name: add new ssh host key (you still need to add it to official ssh_host_keys later)
|
2016-10-03 21:30:51 +00:00
|
|
|
local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}" host={{ nova_result.public_ip }} state=present
|
2015-05-28 19:58:02 +00:00
|
|
|
ignore_errors: True
|
|
|
|
with_items:
|
|
|
|
- /root/.ssh/known_hosts
|
|
|
|
- /etc/ssh/ssh_known_hosts
|
|
|
|
|
2015-05-13 23:12:42 +00:00
|
|
|
# SSH is up and running, however cloud-init still did not deployed ssh keypair
|
|
|
|
# we have to wait some time. 10 sec is usually enough, but not always.
|
|
|
|
- name: waiting for cloud-init
|
|
|
|
pause: seconds=30
|