Skip to content

Commit

Permalink
fix #370: run deployment_bastion_node_cleanup only on the same server…
Browse files Browse the repository at this point in the history
… uuid.
  • Loading branch information
ioggstream committed Jul 11, 2017
1 parent 2c1b721 commit 825021d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fragments/bastion-node-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if [ -e $INVENTORY -a "$node_type" == node ]; then
export ANSIBLE_ROLES_PATH=/usr/share/ansible/openshift-ansible/roles
export ANSIBLE_HOST_KEY_CHECKING=False

ansible-playbook -vvvv -e node=$node_name \
ansible-playbook -vvvv -e node=$node_name -e node_id=$node_id \
--inventory /var/lib/ansible/inventory \
/var/lib/ansible/playbooks/scaledown.yml &>> /var/log/ansible-scaledown.$$ || true
fi
Expand All @@ -32,9 +32,11 @@ if [ -e $NODESFILE ]; then
grep -v "$node_name" ${NODESFILE}.bkp > $NODESFILE || true
fi

# unregister the node if registered with subscription-manager
# unregister the node if
# - node_id matches the one defined in deployment_bastion_node_cleanup
# - registered with subscription-manager
[ -e $INVENTORY ] && ansible $node_name -m shell \
-u $ssh_user --sudo -i $INVENTORY \
-a "subscription-manager unregister && subscription-manager clean" || true
-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

echo "Deleted node $node_name"
echo "Deleted node $node_name with id $node_id"
2 changes: 2 additions & 0 deletions infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ resources:
properties:
group: script
inputs:
- name: node_id
- name: node_name
- name: node_type
- name: ssh_user
Expand All @@ -501,6 +502,7 @@ resources:
properties:
actions: ['DELETE']
input_values:
node_id: {get_resource: host}
node_type: infra
node_name:
str_replace:
Expand Down
2 changes: 2 additions & 0 deletions loadbalancer_dedicated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ resources:
properties:
group: script
inputs:
- name: node_id
- name: node_name
- name: node_type
- name: ssh_user
Expand All @@ -411,6 +412,7 @@ resources:
properties:
actions: ['DELETE']
input_values:
node_id: {get_resource: host}
node_type: loadbalancer
node_name:
str_replace:
Expand Down
2 changes: 2 additions & 0 deletions master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ resources:
properties:
group: script
inputs:
- name: node_id
- name: node_name
- name: node_type
- name: ssh_user
Expand All @@ -493,6 +494,7 @@ resources:
properties:
actions: ['DELETE']
input_values:
node_id: {get_resource: host}
node_type: master
node_name:
str_replace:
Expand Down
2 changes: 2 additions & 0 deletions node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ resources:
properties:
group: script
inputs:
- name: node_id
- name: node_name
- name: node_type
- name: ssh_user
Expand All @@ -603,6 +604,7 @@ resources:
properties:
actions: ['DELETE']
input_values:
node_id: {get_resource: host}
node_type: node
node_name:
str_replace:
Expand Down

0 comments on commit 825021d

Please sign in to comment.