Sync mcollective config with /etc/nailgun_uid

The contents of /etc/nailgun_uid can be changed by nailgun agent. We need to
synchronize the change to mcollective config.

Closes-Bug: #1675668
Change-Id: Idabc7be6181bc89c09e4d0caa4a7cf0c22767bfe
This commit is contained in:
Georgy Kibardin 2017-03-23 13:58:21 +03:00
parent 6288a593e2
commit ea8fc2bdfe
1 changed files with 18 additions and 6 deletions

View File

@ -58,18 +58,30 @@ sed -i "/^\s*server\b/ d" /etc/ntp.conf
echo "server $masternode_ip burst iburst" >> /etc/ntp.conf
systemctl restart ntp
sync_identity() {
while true
do
if new_identity=$(grep -s --line-regexp "[[:digit:]]\+" /etc/nailgun_uid)
then
if [ "$new_identity" != "$identity" ]
then
identity=$new_identity
sed -i '/^identity =/d' /etc/mcollective/server.cfg > /dev/null 2>&1
echo "identity = $identity" >> /etc/mcollective/server.cfg
service mcollective restart
fi
fi
sleep 5
done
}
#
# Update mcollective config
#
sed -i "s/^plugin.rabbitmq.pool.1.host\b.*$/plugin.rabbitmq.pool.1.host = $masternode_ip/" /etc/mcollective/server.cfg
sed -i "s/^plugin.rabbitmq.pool.1.user\b.*$/plugin.rabbitmq.pool.1.user = $mco_user/" /etc/mcollective/server.cfg
sed -i "s/^plugin.rabbitmq.pool.1.password\b.*$/plugin.rabbitmq.pool.1.password= $mco_pass/" /etc/mcollective/server.cfg
while true; do
sleep 5
grep --line-regexp "[[:digit:]]\+" /etc/nailgun_uid && break
done
echo "identity = $(head -n 1 /etc/nailgun_uid)" >> /etc/mcollective/server.cfg
service mcollective restart
sync_identity &
# restart the dispynode service
systemctl restart dispynode