diff --git a/playbooks/groups/copr-backend.yml b/playbooks/groups/copr-backend.yml index 8a9a4c101f..9faefbfc51 100644 --- a/playbooks/groups/copr-backend.yml +++ b/playbooks/groups/copr-backend.yml @@ -10,7 +10,7 @@ - /srv/web/infra/ansible/vars/fedora-cloud.yml - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: gather facts setup: always_run: True diff --git a/playbooks/groups/copr-dist-git.yml b/playbooks/groups/copr-dist-git.yml index c94d272fa3..969450800e 100644 --- a/playbooks/groups/copr-dist-git.yml +++ b/playbooks/groups/copr-dist-git.yml @@ -12,7 +12,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: cloud basic setup hosts: copr-dist-git-stg:copr-dist-git diff --git a/playbooks/groups/copr-frontend.yml b/playbooks/groups/copr-frontend.yml index 865c4f65d4..009c2a4ba6 100644 --- a/playbooks/groups/copr-frontend.yml +++ b/playbooks/groups/copr-frontend.yml @@ -10,7 +10,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: cloud basic setup hosts: copr-front-stg diff --git a/playbooks/groups/copr-keygen.yml b/playbooks/groups/copr-keygen.yml index 145a86efbe..7df7eb2b0d 100644 --- a/playbooks/groups/copr-keygen.yml +++ b/playbooks/groups/copr-keygen.yml @@ -10,7 +10,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: cloud basic setup hosts: copr-keygen-stg:copr-keygen diff --git a/playbooks/groups/docs-dev.yml b/playbooks/groups/docs-dev.yml index 735c12b823..09c2bcfbf2 100644 --- a/playbooks/groups/docs-dev.yml +++ b/playbooks/groups/docs-dev.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: docs-dev diff --git a/playbooks/groups/jenkins-master.yml b/playbooks/groups/jenkins-master.yml index 765123feea..a88794f0ed 100644 --- a/playbooks/groups/jenkins-master.yml +++ b/playbooks/groups/jenkins-master.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: jenkins-master diff --git a/playbooks/groups/jenkins-slave.yml b/playbooks/groups/jenkins-slave.yml index 3844863eff..13d1d9acec 100644 --- a/playbooks/groups/jenkins-slave.yml +++ b/playbooks/groups/jenkins-slave.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: jenkins-slave diff --git a/playbooks/groups/twisted-buildbots.yml b/playbooks/groups/twisted-buildbots.yml index 53cf7078e5..1b34c37963 100644 --- a/playbooks/groups/twisted-buildbots.yml +++ b/playbooks/groups/twisted-buildbots.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: twisted-buildbots diff --git a/playbooks/hosts/artboard.fedorainfracloud.org.yml b/playbooks/hosts/artboard.fedorainfracloud.org.yml index 83b37ff67f..7b43076ffd 100644 --- a/playbooks/hosts/artboard.fedorainfracloud.org.yml +++ b/playbooks/hosts/artboard.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: artboard.fedorainfracloud.org diff --git a/playbooks/hosts/communityblog.fedorainfracloud.org.yml b/playbooks/hosts/communityblog.fedorainfracloud.org.yml index 74a6831d74..95683e2fcc 100644 --- a/playbooks/hosts/communityblog.fedorainfracloud.org.yml +++ b/playbooks/hosts/communityblog.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: communityblog.fedorainfracloud.org diff --git a/playbooks/hosts/darkserver-dev.fedorainfracloud.org.yml b/playbooks/hosts/darkserver-dev.fedorainfracloud.org.yml index cb1b22ca7b..6c0b3622a2 100644 --- a/playbooks/hosts/darkserver-dev.fedorainfracloud.org.yml +++ b/playbooks/hosts/darkserver-dev.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - include: "{{ tasks }}/growroot_cloud_el7.yml" - name: setup all the things diff --git a/playbooks/hosts/developer.fedorainfracloud.org.yml b/playbooks/hosts/developer.fedorainfracloud.org.yml index 83282f4687..532298fff3 100644 --- a/playbooks/hosts/developer.fedorainfracloud.org.yml +++ b/playbooks/hosts/developer.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: developer.fedorainfracloud.org diff --git a/playbooks/hosts/faitout.fedorainfracloud.org.yml b/playbooks/hosts/faitout.fedorainfracloud.org.yml index 2ad2ffc408..264966112a 100644 --- a/playbooks/hosts/faitout.fedorainfracloud.org.yml +++ b/playbooks/hosts/faitout.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: faitout.fedorainfracloud.org diff --git a/playbooks/hosts/fas2-dev.fedorainfracloud.org.yml b/playbooks/hosts/fas2-dev.fedorainfracloud.org.yml index 5663bba216..25c07d3f46 100644 --- a/playbooks/hosts/fas2-dev.fedorainfracloud.org.yml +++ b/playbooks/hosts/fas2-dev.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: fas2-dev.fedorainfracloud.org diff --git a/playbooks/hosts/fas3-dev.fedorainfracloud.org.yml b/playbooks/hosts/fas3-dev.fedorainfracloud.org.yml index b807d97f4f..45cb38bf3b 100644 --- a/playbooks/hosts/fas3-dev.fedorainfracloud.org.yml +++ b/playbooks/hosts/fas3-dev.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: fas3-dev.fedorainfracloud.org diff --git a/playbooks/hosts/grafana.cloud.fedoraproject.org.yml b/playbooks/hosts/grafana.cloud.fedoraproject.org.yml index 0fb499390d..34d6de8854 100644 --- a/playbooks/hosts/grafana.cloud.fedoraproject.org.yml +++ b/playbooks/hosts/grafana.cloud.fedoraproject.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: grafana.cloud.fedoraproject.org diff --git a/playbooks/hosts/insim.fedorainfracloud.org.yml b/playbooks/hosts/insim.fedorainfracloud.org.yml index 7c975bb358..2d1435a5fb 100644 --- a/playbooks/hosts/insim.fedorainfracloud.org.yml +++ b/playbooks/hosts/insim.fedorainfracloud.org.yml @@ -10,7 +10,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: insim.fedorainfracloud.org diff --git a/playbooks/hosts/java-deptools.fedorainfracloud.org b/playbooks/hosts/java-deptools.fedorainfracloud.org index c46f321f8f..c39e17cc8c 100644 --- a/playbooks/hosts/java-deptools.fedorainfracloud.org +++ b/playbooks/hosts/java-deptools.fedorainfracloud.org @@ -11,7 +11,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: java-deptools.fedorainfracloud.org diff --git a/playbooks/hosts/lists-dev.fedorainfracloud.org.yml b/playbooks/hosts/lists-dev.fedorainfracloud.org.yml index 79082f6be1..4cc320ab93 100644 --- a/playbooks/hosts/lists-dev.fedorainfracloud.org.yml +++ b/playbooks/hosts/lists-dev.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: lists-dev.fedorainfracloud.org diff --git a/playbooks/hosts/magazine.fedorainfracloud.org.yml b/playbooks/hosts/magazine.fedorainfracloud.org.yml index c62cce080e..dbc3bd8476 100644 --- a/playbooks/hosts/magazine.fedorainfracloud.org.yml +++ b/playbooks/hosts/magazine.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: magazine.fedorainfracloud.org diff --git a/playbooks/hosts/osbs-dev.fedorainfracloud.org.yml b/playbooks/hosts/osbs-dev.fedorainfracloud.org.yml index 4fda7d5d15..5c710ebb81 100644 --- a/playbooks/hosts/osbs-dev.fedorainfracloud.org.yml +++ b/playbooks/hosts/osbs-dev.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: osbs-dev.fedorainfracloud.org diff --git a/playbooks/hosts/pdc.fedorainfracloud.org.yml b/playbooks/hosts/pdc.fedorainfracloud.org.yml index e70f6a9ffe..2935f8ceb1 100644 --- a/playbooks/hosts/pdc.fedorainfracloud.org.yml +++ b/playbooks/hosts/pdc.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: Set up basics for our pdc node. hosts: pdc.fedorainfracloud.org diff --git a/playbooks/hosts/shumgrepper-dev.fedorainfracloud.org.yml b/playbooks/hosts/shumgrepper-dev.fedorainfracloud.org.yml index 9ca73fb916..d134088516 100644 --- a/playbooks/hosts/shumgrepper-dev.fedorainfracloud.org.yml +++ b/playbooks/hosts/shumgrepper-dev.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: shumgrepper-dev.fedorainfracloud.org diff --git a/playbooks/hosts/taiga.fedorainfracloud.org.yml b/playbooks/hosts/taiga.fedorainfracloud.org.yml index 2aaa8c7fe6..1e69587ca5 100644 --- a/playbooks/hosts/taiga.fedorainfracloud.org.yml +++ b/playbooks/hosts/taiga.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: taiga.fedorainfracloud.org diff --git a/playbooks/hosts/taigastg.fedorainfracloud.org.yml b/playbooks/hosts/taigastg.fedorainfracloud.org.yml index a4472747a7..35b2503233 100644 --- a/playbooks/hosts/taigastg.fedorainfracloud.org.yml +++ b/playbooks/hosts/taigastg.fedorainfracloud.org.yml @@ -9,7 +9,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: taigastg.fedorainfracloud.org diff --git a/playbooks/hosts/testdays.fedorainfracloud.org.yml b/playbooks/hosts/testdays.fedorainfracloud.org.yml index d108a79535..19edca2286 100644 --- a/playbooks/hosts/testdays.fedorainfracloud.org.yml +++ b/playbooks/hosts/testdays.fedorainfracloud.org.yml @@ -10,7 +10,7 @@ - /srv/private/ansible/files/openstack/passwords.yml tasks: - - include: "{{ tasks }}/persistent_cloud_new.yml" + - include: "{{ tasks }}/persistent_cloud.yml" - name: setup all the things hosts: testdays.fedorainfracloud.org diff --git a/tasks/persistent_cloud.yml b/tasks/persistent_cloud.yml index bbfeb0bd8f..9a74cd0abc 100644 --- a/tasks/persistent_cloud.yml +++ b/tasks/persistent_cloud.yml @@ -1,25 +1,104 @@ ---- +# New tasks to spin up instance in https://fedorainfracloud.org + - name: check it out - local_action: shell nc -d -z -w 5 {{ inventory_hostname }} 22 >>/dev/null + local_action: shell nc -w 5 {{ inventory_hostname }} 22 < /dev/null register: host_is_up ignore_errors: true -- name: spin it up - local_action: ec2 keypair={{ keypair }} image={{ image }} type={{ instance_type }} wait=true group={{ security_group }} ec2_access_key={{ persist_access_key }} ec2_secret_key={{ persist_secret_key }} ec2_url={{ os_ec2_url }} region={{ region }} - register: inst_res +- name: clean out old known_hosts (name based entries) + local_action: known_hosts path={{item}} host={{inventory_hostname}} state=absent + ignore_errors: True + with_items: + - /root/.ssh/known_hosts + - /etc/ssh/ssh_known_hosts when: host_is_up|failed -- name: assign it a special ip - local_action: shell euca-associate-address --config {{ persist_config }} -i {{ inst_res.instances[0].id }} {{ public_ip }} +- name: clean out old known_hosts (IP based entries) + local_action: known_hosts path={{item}} host={{ lookup('dig', inventory_hostname, wantlist=False) }} state=absent + ignore_errors: True + with_items: + - /root/.ssh/known_hosts + - /etc/ssh/ssh_known_hosts when: host_is_up|failed -- name: wait for the reassignation - local_action: wait_for host={{ public_ip }} port=22 delay=20 timeout=300 +- name: spin UP VM using nova_compute + 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 }}" + user_data: "#cloud-config\ndisable_root: 0" + floating_ips: + - "{{public_ip}}" + register: nova_result when: host_is_up|failed -# attach and mount volumes -- name: attach volumes to the system - local_action: shell euca-attach-volume --config {{ persist_config }} -i {{ inst_res.instances[0].id }} {{ item }} +# 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 - when: volumes is defined and host_is_up|failed + 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 + +- name: gather ssh host key from new instance + local_action: command ssh-keyscan -t rsa {{ inventory_hostname }} + ignore_errors: True + register: hostkey + when: host_is_up|failed + +- name: add new ssh host key (you still need to add it to official ssh_host_keys later) + local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}" host={{ inventory_hostname }} state=present + ignore_errors: True + with_items: + - /root/.ssh/known_hosts + - /etc/ssh/ssh_known_hosts + when: host_is_up|failed + +# 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 + when: host_is_up|failed + +# +# Next we try and gather facts. If the host doesn't have python2 this will fail. +# + +- name: gather facts + setup: + always_run: True + ignore_errors: True + register: facts + +# +# If that failed, then we use the raw module to install things +# + +- name: install python2 and dnf stuff + raw: dnf -y install python-dnf libselinux-python + when: facts|failed + +# TODO - somehow guess when keypair is finally deployed and return little bit earlier +## 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 +# diff --git a/tasks/persistent_cloud_new.yml b/tasks/persistent_cloud_new.yml deleted file mode 100644 index 9a74cd0abc..0000000000 --- a/tasks/persistent_cloud_new.yml +++ /dev/null @@ -1,104 +0,0 @@ -# New tasks to spin up instance in https://fedorainfracloud.org - -- name: check it out - local_action: shell nc -w 5 {{ inventory_hostname }} 22 < /dev/null - register: host_is_up - ignore_errors: true - -- name: clean out old known_hosts (name based entries) - local_action: known_hosts path={{item}} host={{inventory_hostname}} state=absent - ignore_errors: True - with_items: - - /root/.ssh/known_hosts - - /etc/ssh/ssh_known_hosts - when: host_is_up|failed - -- name: clean out old known_hosts (IP based entries) - local_action: known_hosts path={{item}} host={{ lookup('dig', inventory_hostname, wantlist=False) }} state=absent - ignore_errors: True - with_items: - - /root/.ssh/known_hosts - - /etc/ssh/ssh_known_hosts - when: host_is_up|failed - -- name: spin UP VM using nova_compute - 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 }}" - user_data: "#cloud-config\ndisable_root: 0" - 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 - -- name: gather ssh host key from new instance - local_action: command ssh-keyscan -t rsa {{ inventory_hostname }} - ignore_errors: True - register: hostkey - when: host_is_up|failed - -- name: add new ssh host key (you still need to add it to official ssh_host_keys later) - local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}" host={{ inventory_hostname }} state=present - ignore_errors: True - with_items: - - /root/.ssh/known_hosts - - /etc/ssh/ssh_known_hosts - when: host_is_up|failed - -# 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 - when: host_is_up|failed - -# -# Next we try and gather facts. If the host doesn't have python2 this will fail. -# - -- name: gather facts - setup: - always_run: True - ignore_errors: True - register: facts - -# -# If that failed, then we use the raw module to install things -# - -- name: install python2 and dnf stuff - raw: dnf -y install python-dnf libselinux-python - when: facts|failed - -# TODO - somehow guess when keypair is finally deployed and return little bit earlier -## 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 -#