<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">Hi Javier,<br><br>You are right I had to define the HOSTNAME variable in the template context and not as a tag in the already running VM. This means that I can't share templates among VMs, which is a bit stupid of course. With this solution you need one template per VM. <br><br>I see the issue with the HOSTNAME environment variable which is actually set at bootup of Linux so no problem with me for using a name such as SET_HOSTNAME like you suggest.<br><br>What do you think about having that same script also defining the hostname dynamically (if none was defined with the SET_HOSTNAME context variable) based on a DNS reverse lookup if the IP address of the VM has a PTR record?<br><br>Regards,<br>ML<br><div><span><br></span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div
style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Thursday, February 27, 2014 12:27 PM, Javier Fontan <jfontan@opennebula.org> wrote:<br> </font> </div> <div class="y_msg_container">Hi,<br clear="none"><br clear="none">ML, I think you should add it in the template context section, custom variables.<br clear="none"><br clear="none">I am adding scripts to configure the hostname in the context phase.<br clear="none">These are simple scripts (one for rpm and other for deb based distros)<br clear="none">that do just what you've commented, call hostname and modify the conf<br clear="none">file. [1]<br clear="none"><br clear="none">I've just found a problem with it and it is calling the configuration<br clear="none">variable
"HOSTNAME". The shell automatically sets HOSTNAME and even if<br clear="none">we don't specify it so it's a bit tricky to check wether the user<br clear="none">intents to configure the hostname or leave it as it is.<br clear="none"><br clear="none">I am proposing to use the custom variable "SET_HOSTNAME" to configure<br clear="none">the host name. What do you think?<br clear="none"><br clear="none">Concerning the addition of scripts in the context package, there is a<br clear="none">guide in both the documentation [2] and the source code [3] on how to<br clear="none">create custom packages. Having the required dependencies it's fairly<br clear="none">easy to add or modify the configuration script you may need.<br clear="none"><br clear="none">Cheers<br clear="none"><br clear="none">[1] <a shape="rect" href="http://dev.opennebula.org/issues/2453" target="_blank">http://dev.opennebula.org/issues/2453</a><br clear="none">[2] <a shape="rect"
href="http://docs.opennebula.org/stable/user/virtual_machine_setup/cong.html#generating-custom-contextualization-packages" target="_blank">http://docs.opennebula.org/stable/user/virtual_machine_setup/cong.html#generating-custom-contextualization-packages</a><br clear="none">[3] <a shape="rect" href="https://github.com/OpenNebula/one/tree/master/share/scripts/context-packages" target="_blank">https://github.com/OpenNebula/one/tree/master/share/scripts/context-packages</a><br clear="none"><br clear="none">On Thu, Feb 27, 2014 at 8:02 AM, ML mail <<a shape="rect" ymailto="mailto:mlnospam@yahoo.com" href="mailto:mlnospam@yahoo.com">mlnospam@yahoo.com</a>> wrote:<br clear="none">> Regarding the hostname script that's exactly what I did, I also tried to<br clear="none">> redeploy this persistent image. Where exactly did you set the HOSTNAME<br clear="none">> variable? I have setted it in the tags of that specific VM (where I would<br
clear="none">> also add the SSH_PUBLIC_KEY variable). But that might be wrong?<br clear="none">><br clear="none">> Regards,<br clear="none">> ML<br clear="none">><br clear="none">><br clear="none">> On Thursday, February 27, 2014 2:47 AM, "Campbell, Bill"<br clear="none">> <<a shape="rect" ymailto="mailto:bcampbell@axcess-financial.com" href="mailto:bcampbell@axcess-financial.com">bcampbell@axcess-financial.com</a>> wrote:<br clear="none">> For item 1, no that should do it, just make sure it's executable and it<br clear="none">> should run. (the vmcontext init.d script will run all scripts in the<br clear="none">> /etc/one-context.d directory in order). I set this up for Ubuntu, but I'm<br clear="none">> pretty sure Debian is the same when it comes to setting the hostname. You<br clear="none">> mention you reboot the VM, you may have to redeploy (as the context script<br clear="none">> is
already generated from your previous deployment package).<br clear="none">><br clear="none">> For item 2, you could include it in your base image, or in the example<br clear="none">> provided, add it to the files repository along with that init.sh script, and<br clear="none">> then assign both files to the template. This way the files will be included<br clear="none">> with the context information, will copy the ##-script over to the instance,<br clear="none">> and restart the vmcontext service.<br clear="none">><br clear="none">> ________________________________<br clear="none">> From: "ML mail" <<a shape="rect" ymailto="mailto:mlnospam@yahoo.com" href="mailto:mlnospam@yahoo.com">mlnospam@yahoo.com</a>><br clear="none">> To: "users" <<a shape="rect" ymailto="mailto:users@lists.opennebula.org" href="mailto:users@lists.opennebula.org">users@lists.opennebula.org</a>><br clear="none">> Sent: Wednesday,
February 26, 2014 11:12:08 AM<br clear="none">> Subject: Re: [one-users] ONE context package<br clear="none">><br clear="none">> Hi Bill,<br clear="none">><br clear="none">> Thanks for your answer and example scripts. I have a few more questions or<br clear="none">> issues regarding your examples:<br clear="none">><br clear="none">> - I tried out your small hostname script which I have copied on my Debian 7<br clear="none">> VM under /etc/one-context.d/98-hostname. I have then set in my VM a tag<br clear="none">> called HOSTNAME with a value and rebooted the VM. Unfortunately the hostname<br clear="none">> did not get changed. Did I miss something here?<br clear="none">><br clear="none">> - I suppose I would have to re-create the one-context package manually if I<br clear="none">> would like to include the aforementioned 98-hostname script in the official<br clear="none">> one-context package, correct? or I
could manually copy it into my image<br clear="none">> before deploying it?<br clear="none">><br clear="none">> Regards,<br clear="none">> ML<br clear="none">><br clear="none">><br clear="none">><br clear="none">> On Wednesday, February 26, 2014 3:08 PM, "Campbell, Bill"<br clear="none">> <<a shape="rect" ymailto="mailto:bcampbell@axcess-financial.com" href="mailto:bcampbell@axcess-financial.com">bcampbell@axcess-financial.com</a>> wrote:<br clear="none">> We don't have the automatic lookup from DNS (that would rely on the DNS<br clear="none">> record being created first prior to VM deployment), but we use a script that<br clear="none">> is placed in our base images /etc/one-context.d/ directory that does this<br clear="none">> (which relies on option 2 as you mention below, a HOSTNAME context<br clear="none">> variable):<br clear="none">><br clear="none">> #!/bin/bash<br clear="none">><br
clear="none">> if [ -f /mnt/context.sh ]; then<br clear="none">> . /mnt/context.sh<br clear="none">> else<br clear="none">> exit 0<br clear="none">> fi<br clear="none">> hostname $HOSTNAME<br clear="none">> echo $HOSTNAME > /etc/hostname<br clear="none">><br clear="none">> exit 0<br clear="none">><br clear="none">> The above example is for our Ubuntu instances, so it may need to be modified<br clear="none">> for RHEL or SUSE based virtuals, if that's what you use.<br clear="none">><br clear="none">> In addition, if using 4.4, use the files datastore and create an 'init.sh'<br clear="none">> script that can then load up additional files that you assign to the<br clear="none">> template (so you don't need to manually update each image). We use an<br clear="none">> init.sh script like this to inject new configuration/contextualization<br clear="none">> options so we don't need to update our
base image very often:<br clear="none">><br clear="none">> <br clear="none">> #!/bin/sh<br clear="none">> #<br clear="none">> # OpenNebula Init Script<br clear="none">> #<br clear="none">> # init.sh<br clear="none">> #<br clear="none">> # Copies additional context scripts to the appropriate directory<br clear="none">> #<br clear="none">> ## Set environment<br clear="none">> SOURCE=/mnt<br clear="none">> DEST=/etc/one-context.d<br clear="none">><br clear="none">> if [ -f /etc/redhat-release ]; then<br clear="none">> OSVERSION=RHEL<br clear="none">> else<br clear="none">> OSVERSION=UBUNTU<br clear="none">> fi<br clear="none">> if [ -f /usr/bin/rsync ]; then<br clear="none">> echo "Applying additional contextualization scripts..."<br clear="none">> else<br clear="none">> if [ "$OSVERSION" != "UBUNTU" ]; then<br clear="none">> yum -y install rsync<br clear="none">> else<br
clear="none">> apt-get update && apt-get -y install rsync<br clear="none">> fi<br clear="none">> fi<br clear="none">><br clear="none">> ## Copy Files. This will IGNORE any *.sh files in the source/destination<br clear="none">> directories, as all context scripts<br clear="none">> ## should NOT have the .sh extension.<br clear="none">> for i in $(ls $SOURCE --ignore=*.sh)<br clear="none">> do<br clear="none">> if [ -f $DEST/$i ]; then<br clear="none">> echo "$i exists in context directory. Skipping..."<br clear="none">> else<br clear="none">> rsync -au $SOURCE/$i /etc/one-context.d/<br clear="none">> chown root.root /etc/one-context.d/*<br clear="none">> chmod 700 /etc/one-context.d/*<br clear="none">> service vmcontext restart<br clear="none">> fi<br clear="none">> done<br clear="none">> exit 0<br clear="none">><br clear="none">> This will check the OS Version and install the
appropriate package. It will<br clear="none">> NOT copy any file that has the .sh extension, but if you follow the context<br clear="none">> script standard of ##-<scriptname> then you can add additional context upon<br clear="none">> deployment. Rudimentary, sure, but works well enough for us.<br clear="none">><br clear="none">><br clear="none">> ________________________________<br clear="none">> From: "ML mail" <<a shape="rect" ymailto="mailto:mlnospam@yahoo.com" href="mailto:mlnospam@yahoo.com">mlnospam@yahoo.com</a>><br clear="none">> To: <a shape="rect" ymailto="mailto:users@lists.opennebula.org" href="mailto:users@lists.opennebula.org">users@lists.opennebula.org</a><br clear="none">> Sent: Wednesday, February 26, 2014 5:39:46 AM<br clear="none">> Subject: [one-users] ONE context package<br clear="none">><br clear="none">> Hi,<br clear="none">><br clear="none">> I am very happy with
the ONE context package for automated contextualization<br clear="none">> on Debian and CentOS but I miss one feature: automatically and manually<br clear="none">> setting the hostname of the VM.<br clear="none">><br clear="none">> Basically it would be great to have the following two options:<br clear="none">><br clear="none">> - automatically set the hostname of the VM based doing a reverse DNS lookup<br clear="none">> on the IP address, for example I have as reverse DNS entry<br clear="none">> "one-vm-1-0-16-172.mydomain.com" then the hostname of my VM would be<br clear="none">> automatically set to "one-vm-1-0-16-172".<br clear="none">> - using a HOSTNAME tag in the VM to manually enter a hostname and overriding<br clear="none">> the automatic hostname attribution described above<br clear="none">><br clear="none">> What do you think?<br clear="none">><br clear="none">> Regards,<br clear="none">> ML<br
clear="none">><br clear="none">> _______________________________________________<br clear="none">> Users mailing list<br clear="none">> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br clear="none">><br clear="none">><br clear="none">> NOTICE: Protect the information in this message in accordance with the<br clear="none">> company's security policies. If you received this message in error,<br clear="none">> immediately notify the sender and destroy all copies.<br clear="none">><br clear="none">><br clear="none">> _______________________________________________<br clear="none">> Users mailing list<br clear="none">> <a shape="rect"
ymailto="mailto:Users@lists.opennebula.org" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><div class="yqt9110583617" id="yqtfd63585"><br clear="none">><br clear="none">><br clear="none">><br clear="none">> _______________________________________________<br clear="none">> Users mailing list<br clear="none">> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br clear="none">><br clear="none">><br clear="none">> NOTICE: Protect the information in this
message in accordance with the<br clear="none">> company's security policies. If you received this message in error,<br clear="none">> immediately notify the sender and destroy all copies.<br clear="none">><br clear="none">><br clear="none">> _______________________________________________<br clear="none">> Users mailing list<br clear="none">> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org" href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br clear="none">><br clear="none">><br clear="none">><br clear="none">> _______________________________________________<br clear="none">> Users mailing list<br clear="none">> <a shape="rect" ymailto="mailto:Users@lists.opennebula.org"
href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br clear="none">> <a shape="rect" href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a></div><br clear="none">><br clear="none"><br clear="none"><br clear="none"><br clear="none">-- <br clear="none">Javier Fontán Muiños<br clear="none">Developer<br clear="none">OpenNebula - The Open Source Toolkit for Data Center Virtualization<br clear="none">www.OpenNebula.org | @OpenNebula | github.com/jfontan<br><br></div> </div> </div> </div> </div></body></html>