Last active
June 14, 2018 12:33
-
-
Save sathlan/4bd80c3e8a397426a3ff8cfbc0347ab1 to your computer and use it in GitHub Desktop.
Enable user to avoid update on certain node.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Create compute-host-to-exclude.txt | |
# one ip of compute nodes to be excluded from the update by line For | |
# instance this give the list of all compute node minus one. those | |
# will be disable, letting only one computed being updated. | |
# openstack server list -f json | \ | |
# jq -r 'map(select(.Name |contains("compute")))[0:-1] | .[].Networks' \ | |
# | awk -F= '{print $2}' > compute-host-to-exclude.txt | |
# Please adjust to your own need, this is just an example. | |
# 2. Run the following on the undercloud. | |
cat > disable-update-on-node.sh <<'EOF' | |
fake_agents_dir=/root/fake-agents-dir | |
mkdir -p $fake_agents_dir | |
for agent in script puppet hiera apply-config; do | |
cat > ${fake_agents_dir}/$agent <<EOS | |
#!/bin/bash | |
echo "Fake $agent being called" >> /tmp/fake.log | |
cat <<'EOJSON' | |
{ | |
"deploy_stdout": "Fake $agent run to skip update", | |
"deploy_stderr": "", | |
"deploy_status_code": 0 | |
} | |
EOJSON | |
exit 0 | |
EOS | |
chmod +x ${fake_agents_dir}/$agent | |
done | |
mkdir -p /etc/systemd/system/os-collect-config.service.d/ | |
cat > /etc/systemd/system/os-collect-config.service.d/90-disable-heat-agents.conf <<EOD | |
[Service] | |
Environment=HEAT_CONFIG_HOOKS=$fake_agents_dir | |
EOD | |
systemctl daemon-reload | |
systemctl restart os-collect-config | |
EOF | |
cat > enable-update-on-node.sh <<'EOF' | |
rm /etc/systemd/system/os-collect-config.service.d/90-disable-heat-agents.conf | |
systemctl daemon-reload | |
systemctl restart os-collect-config | |
EOF | |
# This will create two scripts: | |
# - disable-update-on-node.sh | |
# - enable-update-on-node.sh | |
# 3. Disable the needed nodes | |
for host in $(cat compute-host-to-exclude.txt); do | |
scp disable-update-on-node.sh enable-update-on-node.sh heat-admin@${host}: | |
ssh heat-admin@$host sudo bash ./disable-update-on-node.sh | |
done | |
# 4. Run the update as usual and do your testing on the canari node. | |
# 5. Re-enable the non-updated nodes. | |
for host in $(cat compute-host-to-exclude.txt); do | |
ssh heat-admin@$host sudo bash ./enable-update-on-node.sh | |
done | |
# 6. Re-Run the update. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment