[Bug 1086646] Re: text/x-shellscript doesn't run if text/cloud-boothook present
DaveQB
1086646 at bugs.launchpad.net
Fri Dec 7 00:58:12 UTC 2012
Thanks for the info Scott.
To to clarify, I under you can user hostname in a cloud-config, the
problem I am solving is for autoscaling launch configuration and needing
a common base hostname (for config management purposes and only for
humans to identify) but unique amongst them.
So the host name I am setting is:
prd-myshinnyhostname-ap-southeast-1a-$RANDOM
Which I can't see anyway to do in cloud-config unfortunately, otherwise I would stick to use that for this autoscale launch config.
I am injecting into /etc/cloud/cloud.cfg to save having to have a cloud-config file at all. Just lazy maybe, but figured it works best with how I am setting the hostname (cloud-config hostname is useless for this use case)
So back to the issue, I had the below. The boothook worked but the shell script didn't touch the file in /etc or the test file.
(the work around I have for now is to just have a boothook, and the boothook injects into /etc/rc.local the shell script and then adds a line to clean up after it has run so as to have a one-time run of the shell script. Working well)
I will try your user-data file and report back.
________________________
Content-Type: multipart/mixed; boundary="===============2371311152411390760=="
MIME-Version: 1.0
--===============2371311152411390760==
Content-Type: text/cloud-boothook; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="boothook"
#cloud-boothook
#!/bin/bash
if [ ! -f /etc/id ]
then
sed -i 's/preserve_hostname/preserve_hostname: True/g' /etc/cloud/cloud.cfg
sed -i 's/apt_preserve_sources_list/apt_preserve_sources_list: True/g' /etc/cloud/cloud.cfg
# set hostname
OLD=prd-TEST-ap-southeast-1
NEW=${OLD}-$RANDOM
echo ${NEW} > /etc/hostname
hostname ${NEW}
echo 127.0.1.2 ${NEW}.domain.edu.au ${NEW} >> /etc/hosts
echo $INSTANCE_ID > /etc/id
fi
exit 0
--===============2371311152411390760==
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="boothook-script"
#!/bin/bash -x
touch /etc/$(date +%F)
H=test
echo $H > /etc/test
--
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to cloud-init in Ubuntu.
https://bugs.launchpad.net/bugs/1086646
Title:
text/x-shellscript doesn't run if text/cloud-boothook present
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1086646/+subscriptions
More information about the Ubuntu-server-bugs
mailing list