File tree Expand file tree Collapse file tree 5 files changed +14
-4
lines changed Expand file tree Collapse file tree 5 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ if [ -e $INVENTORY -a "$node_type" == node ]; then
2020 export ANSIBLE_ROLES_PATH=/usr/share/ansible/openshift-ansible/roles
2121 export ANSIBLE_HOST_KEY_CHECKING=False
2222
23- ansible-playbook -vvvv -e node=$node_name \
23+ ansible-playbook -vvvv -e node=$node_name -e node_id= $node_id \
2424 --inventory /var/lib/ansible/inventory \
2525 /var/lib/ansible/playbooks/scaledown.yml & >> /var/log/ansible-scaledown.$$ || true
2626fi
@@ -32,9 +32,11 @@ if [ -e $NODESFILE ]; then
3232 grep -v " $node_name " ${NODESFILE} .bkp > $NODESFILE || true
3333fi
3434
35- # unregister the node if registered with subscription-manager
35+ # unregister the node if
36+ # - node_id matches the one defined in deployment_bastion_node_cleanup
37+ # - registered with subscription-manager
3638[ -e $INVENTORY ] && ansible $node_name -m shell \
3739 -u $ssh_user --sudo -i $INVENTORY \
38- -a " subscription-manager unregister && subscription-manager clean" || true
40+ -a " test -d /var/lib/cloud/instances/ $node_id && echo " Cleanup node $node_id " >> /var/log/ansible-node-cleanup.log && subscription-manager unregister && subscription-manager clean" || true
3941
40- echo " Deleted node $node_name "
42+ echo " Deleted node $node_name with id $node_id "
Original file line number Diff line number Diff line change @@ -485,6 +485,7 @@ resources:
485485 properties :
486486 group : script
487487 inputs :
488+ - name : node_id
488489 - name : node_name
489490 - name : node_type
490491 - name : ssh_user
@@ -501,6 +502,7 @@ resources:
501502 properties :
502503 actions : ['DELETE']
503504 input_values :
505+ node_id : {get_resource: host}
504506 node_type : infra
505507 node_name :
506508 str_replace :
Original file line number Diff line number Diff line change @@ -395,6 +395,7 @@ resources:
395395 properties :
396396 group : script
397397 inputs :
398+ - name : node_id
398399 - name : node_name
399400 - name : node_type
400401 - name : ssh_user
@@ -411,6 +412,7 @@ resources:
411412 properties :
412413 actions : ['DELETE']
413414 input_values :
415+ node_id : {get_resource: host}
414416 node_type : loadbalancer
415417 node_name :
416418 str_replace :
Original file line number Diff line number Diff line change @@ -477,6 +477,7 @@ resources:
477477 properties :
478478 group : script
479479 inputs :
480+ - name : node_id
480481 - name : node_name
481482 - name : node_type
482483 - name : ssh_user
@@ -493,6 +494,7 @@ resources:
493494 properties :
494495 actions : ['DELETE']
495496 input_values :
497+ node_id : {get_resource: host}
496498 node_type : master
497499 node_name :
498500 str_replace :
Original file line number Diff line number Diff line change @@ -587,6 +587,7 @@ resources:
587587 properties :
588588 group : script
589589 inputs :
590+ - name : node_id
590591 - name : node_name
591592 - name : node_type
592593 - name : ssh_user
@@ -603,6 +604,7 @@ resources:
603604 properties :
604605 actions : ['DELETE']
605606 input_values :
607+ node_id : {get_resource: host}
606608 node_type : node
607609 node_name :
608610 str_replace :
You can’t perform that action at this time.
0 commit comments