canonical / canonical/cloud-init
Add variable for local IP address to /etc/hosts manager
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
This bug was originally filed in Launchpad as [LP: #1020695](https://bugs.launchpad.net/cloud-init/+bug/1020695)
Launchpad details
affected_projects = ['centos']
assignee = pas256
assignee_name = Peter Sankauskas
date_closed = None
date_created = 2012-07-03T18:53:49.900760+00:00
date_fix_committed = None
date_fix_released = None
id = 1020695
importance = low
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1020695
milestone = None
owner = pas256
owner_name = Peter Sankauskas
private = False
status = triaged
submitter = pas256
submitter_name = Peter Sankauskas
tags = []
duplicates = []
_Launchpad user **Peter Sankauskas(pas256)** wrote on 2012-07-03T18:53:49.900760+00:00_
Hi,
>
> I would like to set first line in the /etc/hosts file to be something like
> this:
>
> local-ip FQDN Hostname
>
> The ip address should be the one returned from `ec2metadata --local-ipv4`.
> After this line, I would like the usual 127.0.0.1 localhost line. I have
> edited the template at /etc/cloud/templates/hosts.tmpl to have:
>
> ## The value '$hostname' will be replaced with the local-hostname
> 10.2.46.37 $fqdn $hostname
> 127.0.0.1 localhost
I guess it would be good to have a variable available for substitution
available. Could you open a bug on cloud-init for that?
http://bugs.launchpad.net/cloud-init/+filebug
> but I do not know how to get the local IP address as a variable to put into
> the template. At the moment, it is hardcoded, which is not ideal.
>
> Does anyone know what variable I can use in the template file?
The hack that I can think of is to add an upstart job or user-data hook
that just does this for you.
Anyone have better ideas?
Contributor guide
Assessment
This issue has not been assessed yet.