rhtconsulting / rhc-ose

OpenShift Automation and Utilities by Red Hat Consulting
42 stars 34 forks source link

terminate playbook fails on instances with no floating ip. #206

Open etsauer opened 8 years ago

etsauer commented 8 years ago

When running the following: ansible-playbook ./repository/rhc-ose/rhc-ose-ansible/playbooks/openstack/terminate.yml -e 'env_id=casl-esauer-1467913665'

Some or all instances may not have floating IPs. In this case, parsing fails with the following:

TASK [Pause for confirmation on normal run.] ***********************************
[Pause for confirmation on normal run.]

 WARNING! About to delete the following 5 instances and attached volumes:

 [Instance IDs]: 'dece94cc-690a-4e3e-9ad0-c3d92f7c6e47, 899c2e60-c4d8-4197-9bd0-3a790b3c61e4, 8d272775-2a19-4ddf-a7c4-12db175b4b86, e531215f-8c6f-4bc1-b62b-4e78d004afc7, 587a6a5e-bd74-4fc5-b6e4-7db3a2193c72'

 [Instance Names]: 'casl-esauer-1467913665-master1, casl-esauer-1467913665-node1, casl-esauer-1467913665-node2, casl-esauer-1467913665-node3, casl-esauer-1467913665-node4'

 [Instance IPs]: '|, |, |, |, |'

 [Floating IP IDs]: ''

 [Attached Volumes]: '96dd0908-8fd9-4a69-9be8-23cba080874f'

 [Unique Images]: 'rhel-guest-image-7.2'

 Press ENTER to delete these or CTRL+c to cancel:
ok: [localhost]

TASK [Pause for confirmation on dry run.] **************************************
skipping: [localhost]

PLAY [instance_ips] ************************************************************

TASK [debug] *******************************************************************
skipping: [|]

TASK [Attempt to unregister from Subscription Manager] *************************
fatal: [|]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
    to retry, use: --limit @./repository/rhc-ose/rhc-ose-ansible/playbooks/openstack/terminate.retry

PLAY RECAP *********************************************************************
localhost                  : ok=13   changed=9    unreachable=0    failed=0   
|                          : ok=0    changed=0    unreachable=1    failed=0   

@vvaldez

vvaldez commented 8 years ago

This is fixed in the latest PR I'll be pushing

vvaldez commented 8 years ago

Sample output replicating this use case:

TASK [Pause for confirmation on normal run.] ***********************************
[Pause for confirmation on normal run.]

 WARNING! About to delete the following objects matching the environment ID '[[:alnum:]]{8}-[[:alnum:]]{4}-[[:alnum:]]{4}-[[:alnum:]]{4}-[[:alnum:]]{12}':
 4 instances, 0 IPs and 3 attached volumes:

 [Instance IDs]: '8f7d7570-e8ac-4855-b87d-d8968a8dfff7, 54215983-bb1e-4596-b55c-e46433cdd639, 795961f0-ffab-46fa-a401-5246ddd86118, fdf002dd-150b-4d64-8bcb-e493e6ab59e1'

 [Instance Names]: 'casl-vvaldez-1467922100-dns1, casl-vvaldez-1467922100-master1, casl-vvaldez-1467922100-node1, casl-vvaldez-1467922100-node2'

 [Instance IPs]: ''

 [Floating IP IDs]: ''

 [Attached Volumes]: '580b5d92-6cf2-40f1-9f36-d909ccd7a0f4, 6944fd53-b6c4-47e8-81e4-34e0bfb49f74, b7db4514-0718-4573-af5d-5b198d5e706c'

 [Unique Images]: 'rhel-guest-image-7.2'

 Press ENTER to delete these or CTRL+c to cancel:
ok: [localhost]

TASK [Pause for confirmation on dry run.] **************************************
skipping: [localhost]

PLAY [instance_ips] ************************************************************
skipping: no hosts matched