[one-users] ONE context package
Campbell, Bill
bcampbell at axcess-financial.com
Wed Feb 26 08:20:11 PST 2014
For item 1, no that should do it, just make sure it's executable and it should run. (the vmcontext init.d script will run all scripts in the /etc/one-context.d directory in order). I set this up for Ubuntu, but I'm pretty sure Debian is the same when it comes to setting the hostname. You mention you reboot the VM, you may have to redeploy (as the context script is already generated from your previous deployment package).
For item 2, you could include it in your base image, or in the example provided, add it to the files repository along with that init.sh script, and then assign both files to the template. This way the files will be included with the context information, will copy the ##-script over to the instance, and restart the vmcontext service.
----- Original Message -----
From: "ML mail" <mlnospam at yahoo.com>
To: "users" <users at lists.opennebula.org>
Sent: Wednesday, February 26, 2014 11:12:08 AM
Subject: Re: [one-users] ONE context package
Hi Bill,
Thanks for your answer and example scripts. I have a few more questions or issues regarding your examples:
- I tried out your small hostname script which I have copied on my Debian 7 VM under /etc/one-context.d/98-hostname. I have then set in my VM a tag called HOSTNAME with a value and rebooted the VM. Unfortunately the hostname did not get changed. Did I miss something here?
- I suppose I would have to re-create the one-context package manually if I would like to include the aforementioned 98-hostname script in the official one-context package, correct? or I could manually copy it into my image before deploying it?
Regards,
ML
On Wednesday, February 26, 2014 3:08 PM, "Campbell, Bill" <bcampbell at axcess-financial.com> wrote:
We don't have the automatic lookup from DNS (that would rely on the DNS record being created first prior to VM deployment), but we use a script that is placed in our base images /etc/one-context.d/ directory that does this (which relies on option 2 as you mention below, a HOSTNAME context variable):
#!/bin/bash
if [ -f /mnt/context.sh ]; then
. /mnt/context.sh
else
exit 0
fi
hostname $HOSTNAME
echo $HOSTNAME > /etc/hostname
exit 0
The above example is for our Ubuntu instances, so it may need to be modified for RHEL or SUSE based virtuals, if that's what you use.
In addition, if using 4.4, use the files datastore and create an 'init.sh' script that can then load up additional files that you assign to the template (so you don't need to manually update each image). We use an init.sh script like this to inject new configuration/contextualization options so we don't need to update our base image very often:
#!/bin/sh
#
# OpenNebula Init Script
#
# init.sh
#
# Copies additional context scripts to the appropriate directory
#
## Set environment
SOURCE=/mnt
DEST=/etc/one-context.d
if [ -f /etc/redhat-release ]; then
OSVERSION=RHEL
else
OSVERSION=UBUNTU
fi
if [ -f /usr/bin/rsync ]; then
echo "Applying additional contextualization scripts..."
else
if [ "$OSVERSION" != "UBUNTU" ]; then
yum -y install rsync
else
apt-get update && apt-get -y install rsync
fi
fi
## Copy Files. This will IGNORE any *.sh files in the source/destination directories, as all context scripts
## should NOT have the .sh extension.
for i in $(ls $SOURCE --ignore=*.sh)
do
if [ -f $DEST/$i ]; then
echo "$i exists in context directory. Skipping..."
else
rsync -au $SOURCE/$i /etc/one-context.d/
chown root.root /etc/one-context.d/*
chmod 700 /etc/one-context.d/*
service vmcontext restart
fi
done
exit 0
This will check the OS Version and install the appropriate package. It will NOT copy any file that has the .sh extension, but if you follow the context script standard of ##-<scriptname> then you can add additional context upon deployment. Rudimentary, sure, but works well enough for us.
From: "ML mail" <mlnospam at yahoo.com>
To: users at lists.opennebula.org
Sent: Wednesday, February 26, 2014 5:39:46 AM
Subject: [one-users] ONE context package
Hi,
I am very happy with the ONE context package for automated contextualization on Debian and CentOS but I miss one feature: automatically and manually setting the hostname of the VM.
Basically it would be great to have the following two options:
- automatically set the hostname of the VM based doing a reverse DNS lookup on the IP address, for example I have as reverse DNS entry "one-vm-1-0-16-172.mydomain.com" then the hostname of my VM would be automatically set to "one-vm-1-0-16-172".
- using a HOSTNAME tag in the VM to manually enter a hostname and overriding the automatic hostname attribution described above
What do you think?
Regards,
ML
_______________________________________________
Users mailing list
Users at lists.opennebula.org
http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.
_______________________________________________
Users mailing list
Users at lists.opennebula.org
http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
_______________________________________________
Users mailing list
Users at lists.opennebula.org
http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
NOTICE: Protect the information in this message in accordance with the company's security policies. If you received this message in error, immediately notify the sender and destroy all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20140226/6707a4e4/attachment-0002.htm>
More information about the Users
mailing list