diff options
author | Chuck Short <zulcss@ubuntu.com> | 2009-02-04 17:54:00 +0000 |
---|---|---|
committer | Bazaar Package Importer <jamesw@ubuntu.com> | 2009-02-04 17:54:00 +0000 |
commit | 40bc760f17a67700ad19b0d2250deec4e5e06954 (patch) | |
tree | 6f803f5fe1adcb08268e4037e349513aa7d83f83 /ec2-set-hostname.py | |
parent | db066b9caf770d7cdcf9f46f159249d22db99142 (diff) | |
download | vyos-cloud-init-40bc760f17a67700ad19b0d2250deec4e5e06954.tar.gz vyos-cloud-init-40bc760f17a67700ad19b0d2250deec4e5e06954.zip |
* debian/init:
- Remove already ran detection
- Log the running of ec2-run-user-data to /var/log/ec2-user-data.log
* ec2-set-hostname.py:
- set hostname to the Ec2 local-hostname
- Update the /etc/hosts to change the ubuntu hostname to the
public hostname.
* ec2-fetch-credentials:
- Copy the ssh keys to the ubuntu user.
- Setup authorized keys for root to tell the user to login as the
ubuntu user when they try to connect.
* ec2-run-user-data:
- Create an .already-ran file to check to see if ec2-run-user-data
already ran.
- Save the ec2-run-user-data script in /var/ec2.
Diffstat (limited to 'ec2-set-hostname.py')
-rwxr-xr-x | ec2-set-hostname.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ec2-set-hostname.py b/ec2-set-hostname.py index 4c8d7416..f12a4a30 100755 --- a/ec2-set-hostname.py +++ b/ec2-set-hostname.py @@ -25,5 +25,15 @@ api_ver = '2008-02-01' metadata = None base_url = 'http://169.254.169.254/%s/meta-data' % api_ver -my_hostname = urllib.urlopen('%s/public-hostname/' % base_url).read() +my_hostname = urllib.urlopen('%s/local-hostname/' % base_url).read() os.system('hostname %s' % my_hostname) + +# replace the ubuntu hostname in /etc/hosts +my_public_hostname = urllib.urlopen('%s/public-hostname/' % base_url).read() + +f = open("/etc/hosts", "r") +lines = f.read() +f.close() +file = open("/etc/hosts", "w") +file.write(lines.replace("127.0.1.1 ubuntu. ubuntu", "127.0.1.1 "+ my_public_hostname +" "+ my_hostname)) +file.close() |