Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
etsauer opened this issue Jul 7, 2016 · 2 comments
Open

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

etsauer opened this issue Jul 7, 2016 · 2 comments

Comments

@etsauer
Copy link
Contributor

etsauer commented Jul 7, 2016

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
Copy link
Contributor

vvaldez commented Jul 7, 2016

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

@vvaldez
Copy link
Contributor

vvaldez commented Jul 7, 2016

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

vvaldez added a commit to vvaldez/rhc-ose that referenced this issue Jul 7, 2016
* Fixes Issue rhtconsulting#206
* Add check for valid item when attempting to delete objects
* Add debug on all variables when using dry_run
* Changed default ansible_ssh_user to cloud-user in line with standard cloud guest image
* Add count for ips and volumes to display since these may not always be the same as instance count
* Enhance displayed warning/note message to include new counts
* It is possible for an instance to not have a floating IP for whatever reason (such as manually deallocating or releasing the IP), in this case SSH will not work to the instance so it will not be included in the host group to attempt subscription manager unregister, but will still be deleted
* It is possible that an instance will have a volume created but not attached. In this case as a precautionary measure I am excluding these unattached volumes from the deletion in case this was intentionally detached to preserve data. We can further discuss if this should be a parameter to override instead or if we need to change this behavior.
* Excluded instances in ERROR state as they will most likely not delete. We can discuss if this should be parameterized instead.
* Added prompt variable defaulted to true but can be set to false
* Added unregister variable defaulted to true but can be set to false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants