mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-03-20 12:07:34 +08:00
59 lines
2.7 KiB
YAML
59 lines
2.7 KiB
YAML
# New tasks to spin up instance in https://fed-cloud09.cloud.fedoraproject.org
|
|
# DON'T USE FOR PRODUCTION !
|
|
|
|
- name: check it out
|
|
local_action: shell nc -d -z -w 5 {{ inventory_hostname }} 22 >>/dev/null
|
|
register: host_is_up
|
|
ignore_errors: true
|
|
|
|
- name: spin UP VM using nova_compute
|
|
#delegate_to: 127.0.0.1
|
|
sudo: False
|
|
local_action:
|
|
module: nova_compute
|
|
auth_url: "{{os_auth_url}}"
|
|
login_username: "admin"
|
|
login_password: "{{ADMIN_PASS}}"
|
|
login_tenant_name: "{{inventory_tenant}}"
|
|
name: "{{inventory_instance_name}}"
|
|
image_id: "{{ image|image_name_to_id('admin', ADMIN_PASS, inventory_tenant, os_auth_url) }}"
|
|
wait_for: 300
|
|
flavor_id: "{{ instance_type|flavor_name_to_id('admin', ADMIN_PASS, inventory_tenant, os_auth_url) }}"
|
|
security_groups: "{{security_group}}"
|
|
key_name: "{{ keypair }}"
|
|
nics: "{{ cloud_networks }}"
|
|
# floating_ip_pools: "{{ floating_ip_pools }}"
|
|
floating_ips:
|
|
- "{{public_ip}}"
|
|
register: nova_result
|
|
when: host_is_up|failed
|
|
|
|
# instance can be both id and name, volume must be id
|
|
# volume must be id
|
|
- local_action: shell nova --os-auth-url="{{os_auth_url}}" --os-username="admin" --os-password="{{ADMIN_PASS}}" --os-tenant-name={{inventory_tenant}} volume-list | grep ' {{item.volume_id}} ' | grep 'available' && nova --os-auth-url="{{os_auth_url}}" --os-username="admin" --os-password="{{ADMIN_PASS}}" --os-tenant-name={{inventory_tenant}} volume-attach "{{inventory_instance_name}}" "{{item.volume_id}}" "{{item.device}}"
|
|
with_items: volumes
|
|
ignore_errors: yes
|
|
when: volumes is defined
|
|
|
|
- name: wait for he host to be hot
|
|
local_action: wait_for host={{ public_ip }} port=22 delay=1 timeout=600
|
|
when: host_is_up|failed
|
|
|
|
# Check is failing on the lockbox, something with ssh identity available for ssh invocation through the shell module,
|
|
# see: http://fpaste.org/206551/
|
|
- name: waiting for cloud-init
|
|
pause: seconds=30
|
|
when: host_is_up|failed
|
|
|
|
## We need to specify user, here we trying with fedora or root
|
|
#- name: wait until ssh is available
|
|
# # local_action: shell false; until [ "$?" -eq "0" ]; do sleep 2; ssh -o PasswordAuthentication=no fedora@{{ public_ip }} 'echo foobar' || ssh -o PasswordAuthentication=no root@{{ public_ip }} 'echo foobar'; done
|
|
# # local_action: shell false; until [ "$?" -eq "0" ]; do sleep 2; ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no fedora@{{ public_ip }} 'echo foobar'; done
|
|
# local_action: shell whoami && ssh -vvvv -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no fedora@{{ public_ip }} 'echo foobar'
|
|
# # async: 20
|
|
# # poll: 5
|
|
# ignore_errors: True
|
|
|
|
|
|
|