Re: Ubuntu instances + cloud-init
to my knowledge it is not distro specific. We are using that on Ubuntu 12.04 (Which is basically a Debian). We have just tried on a Debian 7.4 and that IF condition works. On Wed, Apr 16, 2014 at 2:38 PM, Jonathan Gowar wrote: > On Wed, 2014-04-16 at 14:30 -0300, Rafael Weingartner wrote: > > Well, here it is working. > > if [ $reason = "BOUND" ]; then > > . > > . > > . > > > > > > What is your O.S. version? > > Hmmm ! /facepalm Debian, I've just re-read the subject though, is this > something distro specific? Any work around for Debian? > > Regards, > Jon > > -- Rafael Weingärtner
Re: Ubuntu instances + cloud-init
On Wed, 2014-04-16 at 14:30 -0300, Rafael Weingartner wrote: > Well, here it is working. > if [ $reason = "BOUND" ]; then > . > . > . > > > What is your O.S. version? Hmmm ! /facepalm Debian, I've just re-read the subject though, is this something distro specific? Any work around for Debian? Regards, Jon
Re: Ubuntu instances + cloud-init
On Wed, 2014-04-16 at 10:04 -0300, Rafael Weingartner wrote: > > #!/bin/sh > > # dhclient change hostname script for Ubuntu > > # /etc/dhcp/dhclient-exit-hooks.d/sethostname > > # logs in /var/log/upstart/network-interface-eth0.log > > > > # for debugging: > > echo "cloudstack-sethostname BEGIN" > > export > > set -x > > > > if [ $reason = "BOUND" ]; then > > echo new_ip_address=$new_ip_address > > echo new_host_name=$new_host_name > > echo new_domain_name=$new_domain_name > > > > oldhostname=$(hostname -s) > > if [ $oldhostname != $new_host_name ]; then > > > > # Rename Host > > echo $new_host_name > /etc/hostname > > hostname -F /etc/hostname > > > > # Update /etc/hosts if needed > > TMPHOSTS=/etc/hosts.dhcp.new > > if ! grep "$new_ip_address $new_host_name.$new_domain_name > > $new_host_name" /etc/hosts; then > > # Remove the 127.0.1.1 put there by the debian installer > > grep -v '127\.0\.1\.1 ' < /etc/hosts > $TMPHOSTS > > # Add the our new ip address and name > > echo "$new_ip_address $new_host_name.$new_domain_name > > $new_host_name" >> $TMPHOSTS > > mv $TMPHOSTS /etc/hosts > > fi > > > > # Recreate SSH2 keys > > export DEBIAN_FRONTEND=noninteractive > > dpkg-reconfigure openssh-server > > fi > > fi > > echo "cloudstack-sethostname END" This fails:- + [ = BOUND ] /etc/dhcp/dhclient-exit-hooks.d/sethostname: 11: [: =: unexpected operator Any ideas? Jon
Re: Ubuntu instances + cloud-init
Well, here it is working. if [ $reason = "BOUND" ]; then . . . What is your O.S. version? On Wed, Apr 16, 2014 at 2:25 PM, Jonathan Gowar wrote: > On Wed, 2014-04-16 at 10:04 -0300, Rafael Weingartner wrote: > > > #!/bin/sh > > > # dhclient change hostname script for Ubuntu > > > # /etc/dhcp/dhclient-exit-hooks.d/sethostname > > > # logs in /var/log/upstart/network-interface-eth0.log > > > > > > # for debugging: > > > echo "cloudstack-sethostname BEGIN" > > > export > > > set -x > > > > > > if [ $reason = "BOUND" ]; then > > > echo new_ip_address=$new_ip_address > > > echo new_host_name=$new_host_name > > > echo new_domain_name=$new_domain_name > > > > > > oldhostname=$(hostname -s) > > > if [ $oldhostname != $new_host_name ]; then > > > > > > # Rename Host > > > echo $new_host_name > /etc/hostname > > > hostname -F /etc/hostname > > > > > > # Update /etc/hosts if needed > > > TMPHOSTS=/etc/hosts.dhcp.new > > > if ! grep "$new_ip_address $new_host_name.$new_domain_name > > > $new_host_name" /etc/hosts; then > > > # Remove the 127.0.1.1 put there by the debian installer > > > grep -v '127\.0\.1\.1 ' < /etc/hosts > $TMPHOSTS > > > # Add the our new ip address and name > > > echo "$new_ip_address $new_host_name.$new_domain_name > > > $new_host_name" >> $TMPHOSTS > > > mv $TMPHOSTS /etc/hosts > > > fi > > > > > > # Recreate SSH2 keys > > > export DEBIAN_FRONTEND=noninteractive > > > dpkg-reconfigure openssh-server > > > fi > > > fi > > > echo "cloudstack-sethostname END" > > This fails:- > > + [ = BOUND ] > /etc/dhcp/dhclient-exit-hooks.d/sethostname: 11: [: =: unexpected > operator > > Any ideas? > > Jon > > -- Rafael Weingärtner
Re: Ubuntu instances + cloud-init
Welll, I do not remember finding this on CS docs. I found them googling. cloud-set-guest-password (I registered it on init.d) #!/bin/bash > # > # Init file for Password Download Client > # > # chkconfig: 345 98 02 > # description: Password Download Client > > # Licensed to the Apache Software Foundation (ASF) under one > # or more contributor license agreements. See the NOTICE file > # distributed with this work for additional information > # regarding copyright ownership. The ASF licenses this file > # to you under the Apache License, Version 2.0 (the > # "License"); you may not use this file except in compliance > # with the License. You may obtain a copy of the License at > # > # http://www.apache.org/licenses/LICENSE-2.0 > # > # Unless required by applicable law or agreed to in writing, > # software distributed under the License is distributed on an > # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > # KIND, either express or implied. See the License for the > # specific language governing permissions and limitations > # under the License. > > > # Modify this line to specify the user (default is root) > user=root > > # Add your DHCP lease folders here > DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/* /var/lib/dhcp/*" > password_received=0 > file_count=0 > error_count=0 > > for DHCP_FILE in $DHCP_FOLDERS > do > if [ -f $DHCP_FILE ] > then > file_count=$((file_count+1)) > PASSWORD_SERVER_IP=$(grep dhcp-server-identifier $DHCP_FILE | tail > -1 | awk '{print $NF}' | tr -d '\;') > > if [ -n "$PASSWORD_SERVER_IP" ] > then > logger -t "cloud" "Found password server IP > $PASSWORD_SERVER_IP in $DHCP_FILE" > logger -t "cloud" "Sending request to password server at > $PASSWORD_SERVER_IP" > password=$(wget -q -t 3 -T 20 -O - --header "DomU_Request: > send_my_password" $PASSWORD_SERVER_IP:8080) > password=$(echo $password | tr -d '\r') > > if [ $? -eq 0 ] > then > logger -t "cloud" "Got response from server at > $PASSWORD_SERVER_IP" > > case $password in > > "")logger -t "cloud" "Password server > at $PASSWORD_SERVER_IP did not have any password for the VM" > continue > ;; > > "bad_request")logger -t "cloud" "VM sent an > invalid request to password server at $PASSWORD_SERVER_IP" > error_count=$((error_count+1)) > continue > ;; > > "saved_password") logger -t "cloud" "VM has already > saved a password from the password server at $PASSWORD_SERVER_IP" > continue > ;; > > *)logger -t "cloud" "VM got a valid > password from server at $PASSWORD_SERVER_IP" > password_received=1 > break > ;; > > esac > else > logger -t "cloud" "Failed to send request to password > server at $PASSWORD_SERVER_IP" > error_count=$((error_count+1)) > fi > else > logger -t "cloud" "Could not find password server IP in > $DHCP_FILE" > error_count=$((error_count+1)) > fi > fi > done > > if [ "$password_received" == "0" ] > then > if [ "$error_count" == "$file_count" ] > then > logger -t "cloud" "Failed to get password from any server" > exit 1 > else > logger -t "cloud" "Did not need to change password." > exit 0 > fi > fi > > logger -t "cloud" "Changing password ..." > echo $user:$password | chpasswd > > if [ $? -gt 0 ] > then > usermod -p 'mkpasswd -m SHA-512 $password' $user > > if [ $? -gt 0 ] > then > logger -t "cloud" "Failed to change password for user $user" > exit 1 > else > logger -t "cloud" "Successfully changed password for user $user" > fi > fi > > logger -t "cloud" "Sending acknowledgment to password server at > $PASSWORD_SERVER_IP" > wget -t 3 -T 20 -O - --header "DomU_Request: saved_password" > $PASSWORD_SERVER_IP:8080 > exit 0 > > setHostName (to change hostname after the DHCP server gives you the IP and desired hostName from CS): > #!/bin/sh > # dhclient change hostname script for Ubuntu > # /etc/dhcp/dhclient-exit-hooks.d/sethostname > # logs in /var/log/upstart/network-interface-eth0.log > > # for debugging: > echo "cloudstack-sethostname BEGIN" > export > set -x > > if [ $reason = "BOUND" ]; then > echo new_ip_address=$new_ip_address > echo new_host_name=$new_host_name > echo new_domain_name=$new_domain_name > > oldhostname=$(hostname -s) > if [ $oldhostname != $new_host_n
Re: Ubuntu instances + cloud-init
On Wed, 2014-04-16 at 08:54 -0300, Rafael Weingartner wrote > One to change the root password, and the other to change the host name > according to the one that was defined on CS. > > one is in "/etc/init.d/", and it is called cloud-set-guest-password. > (The script is attached). > > > and the second one is in "tc/dhcp/dhclient-exit-hooks.d/", so it is > called right after the DHCP finishes its job. And its name is > setHostName. (Also attached) Hi, I need to do change the hostname as according to CS, but don't know about cloud-init scripts. What machine would a script to set the hostname sit on? Also, it seems the attachments are missing? Is this documented anywhere, to give me a better understand. Thanks, Jon >
RE: Ubuntu instances + cloud-init
Rafael, Mail system strips scripts, could you include the code in the body of the mail instead? Regards Geoff Higginbottom D: +44 20 3603 0542 | S: +44 20 3603 0540 | M: +447968161581 geoff.higginbot...@shapeblue.com<mailto:geoff.higginbot...@shapeblue.com> From: Rafael Weingartner [mailto:rafaelweingart...@gmail.com] Sent: 16 April 2014 12:55 To: users@cloudstack.apache.org Subject: Re: Ubuntu instances + cloud-init Sure ;) On my Ubuntu 12.04 templates I use two scripts. One to change the root password, and the other to change the host name according to the one that was defined on CS. one is in "/etc/init.d/", and it is called cloud-set-guest-password. (The script is attached). and the second one is in "tc/dhcp/dhclient-exit-hooks.d/", so it is called right after the DHCP finishes its job. And its name is setHostName. (Also attached) On Wed, Apr 16, 2014 at 7:15 AM, Nux! mailto:n...@li.nux.ro>> wrote: On 15.04.2014 22:02, Rafael Weingartner wrote: If that one does not work, I can show you mine. I use Ubuntu 12.04 templates ;) Do show anyhow, don't be shy. :) Lucian -- Sent from the Delta quadrant using Borg technology! Nux! www.nux.ro<http://www.nux.ro> -- Rafael Weingärtner Need Enterprise Grade Support for Apache CloudStack? Our CloudStack Infrastructure Support<http://shapeblue.com/cloudstack-infrastructure-support/> offers the best 24/7 SLA for CloudStack Environments. Apache CloudStack Bootcamp training courses **NEW!** CloudStack 4.2.1 training<http://shapeblue.com/cloudstack-training/> 28th-29th May 2014, Bangalore. Classromm<http://shapeblue.com/cloudstack-training/> 16th-20th June 2014, Region A. Instructor led, On-line<http://shapeblue.com/cloudstack-training/> 23rd-27th June 2014, Region B. Instructor led, On-line<http://shapeblue.com/cloudstack-training/> 15th-20th September 2014, Region A. Instructor led, On-line<http://shapeblue.com/cloudstack-training/> 22nd-27th September 2014, Region B. Instructor led, On-line<http://shapeblue.com/cloudstack-training/> 1st-6th December 2014, Region A. Instructor led, On-line<http://shapeblue.com/cloudstack-training/> 8th-12th December 2014, Region B. Instructor led, On-line<http://shapeblue.com/cloudstack-training/> This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Shape Blue Ltd or related companies. If you are not the intended recipient of this email, you must neither take any action based upon its contents, nor copy or show it to anyone. Please contact the sender if you believe you have received this email in error. Shape Blue Ltd is a company incorporated in England & Wales. ShapeBlue Services India LLP is a company incorporated in India and is operated under license from Shape Blue Ltd. Shape Blue Brasil Consultoria Ltda is a company incorporated in Brasil and is operated under license from Shape Blue Ltd. ShapeBlue is a registered trademark.
Re: Ubuntu instances + cloud-init
Sure ;) On my Ubuntu 12.04 templates I use two scripts. One to change the root password, and the other to change the host name according to the one that was defined on CS. one is in "/etc/init.d/", and it is called cloud-set-guest-password. (The script is attached). and the second one is in "tc/dhcp/dhclient-exit-hooks.d/", so it is called right after the DHCP finishes its job. And its name is setHostName. (Also attached) On Wed, Apr 16, 2014 at 7:15 AM, Nux! wrote: > On 15.04.2014 22:02, Rafael Weingartner wrote: > >> If that one does not work, I can show you mine. I use Ubuntu 12.04 >> templates ;) >> > > Do show anyhow, don't be shy. :) > > > Lucian > > -- > Sent from the Delta quadrant using Borg technology! > > Nux! > www.nux.ro > -- Rafael Weingärtner
Re: Ubuntu instances + cloud-init
On 15.04.2014 22:02, Rafael Weingartner wrote: If that one does not work, I can show you mine. I use Ubuntu 12.04 templates ;) Do show anyhow, don't be shy. :) Lucian -- Sent from the Delta quadrant using Borg technology! Nux! www.nux.ro
Re: Ubuntu instances + cloud-init
If that one does not work, I can show you mine. I use Ubuntu 12.04 templates ;) On Tue, Apr 15, 2014 at 3:50 PM, Nux! wrote: > On 15.04.2014 19:43, Carlos Reátegui wrote: > >> Hi Nux, >> You can have a look at the patch that I created to fix the default >> cloud-init version on 12.04: >> >> https://github.com/creategui/CloudStackImageScripts >> >> The file you are looking for is DataSourceCloudStack.patch >> > > Thanks Carlos, I'll give that a go soon! > > Lucian > > > > -- > Sent from the Delta quadrant using Borg technology! > > Nux! > www.nux.ro > -- Rafael Weingärtner
Re: Ubuntu instances + cloud-init
On 15.04.2014 19:43, Carlos Reátegui wrote: Hi Nux, You can have a look at the patch that I created to fix the default cloud-init version on 12.04: https://github.com/creategui/CloudStackImageScripts The file you are looking for is DataSourceCloudStack.patch Thanks Carlos, I'll give that a go soon! Lucian -- Sent from the Delta quadrant using Borg technology! Nux! www.nux.ro
Re: Ubuntu instances + cloud-init
Hi Nux, You can have a look at the patch that I created to fix the default cloud-init version on 12.04: https://github.com/creategui/CloudStackImageScripts The file you are looking for is DataSourceCloudStack.patch Regards, -Carlos On Apr 15, 2014, at 10:32 AM, Nux! wrote: > On 15.04.2014 17:25, Rafael Weingartner wrote: >> what script are you talking about ? the one to enable password changes? > > Yes, that one. > Ideally I'd hook it into cloud-init like I do with CentOS[1]. > > > [1] - http://li.nux.ro/download/cloudstack/ks/CentOS6_64bit_password_sshkey.ks > > -- > Sent from the Delta quadrant using Borg technology! > > Nux! > www.nux.ro
Re: Ubuntu instances + cloud-init
On 15.04.2014 17:25, Rafael Weingartner wrote: what script are you talking about ? the one to enable password changes? Yes, that one. Ideally I'd hook it into cloud-init like I do with CentOS[1]. [1] - http://li.nux.ro/download/cloudstack/ks/CentOS6_64bit_password_sshkey.ks -- Sent from the Delta quadrant using Borg technology! Nux! www.nux.ro
Re: Ubuntu instances + cloud-init
what script are you talking about ? the one to enable password changes? On Tue, Apr 15, 2014 at 12:43 PM, Nux! wrote: > Hello, > > Those who are running Ubuntu instances, do you use cloud-init or the > Cloudstack scripts? > I'm trying to build some templates with 12.04 but can't find the right > version of cloud-init for it (0.7.4); their "cloud images" comes with 0.6.3 > who can't use Cloudstack as data source. > > Hints? > > -- > Sent from the Delta quadrant using Borg technology! > > Nux! > www.nux.ro > -- Rafael Weingärtner
Ubuntu instances + cloud-init
Hello, Those who are running Ubuntu instances, do you use cloud-init or the Cloudstack scripts? I'm trying to build some templates with 12.04 but can't find the right version of cloud-init for it (0.7.4); their "cloud images" comes with 0.6.3 who can't use Cloudstack as data source. Hints? -- Sent from the Delta quadrant using Borg technology! Nux! www.nux.ro