Revert back to using cheetah + adjust resultant code + templates

At this point there is a mixture of "double hash" cheetah comments and '#*'
cheetah comments.
This commit is contained in:
Joshua Harlow 2012-07-09 16:41:45 -04:00 committed by Scott Moser
parent 5e953fddfb
commit 134de1bb7b
14 changed files with 176 additions and 173 deletions

View File

@ -1,9 +1,7 @@
# Pypi requirements for cloud-init to work # Pypi requirements for cloud-init to work
# Used for templating any files or strings that are considered # Used for untemplating any files or strings with parameters.
# to be templates, not cheetah since it pulls in alot of extra libs. cheetah
# This one is pretty dinky and does want we want (var substituion)
Tempita
# This is used for any pretty printing of tabular data. # This is used for any pretty printing of tabular data.
PrettyTable PrettyTable

View File

@ -45,9 +45,9 @@ from cloudinit.settings import (PER_INSTANCE, PER_ALWAYS, PER_ONCE,
CLOUD_CONFIG) CLOUD_CONFIG)
# Pretty little welcome message template # Pretty little cheetah formatted welcome message template
WELCOME_MSG_TPL = ("Cloud-init v. {{version}} running '{{action}}' at " WELCOME_MSG_TPL = ("Cloud-init v. ${version} running '${action}' at "
"{{timestamp}}. Up {{uptime}} seconds.") "${timestamp}. Up ${uptime} seconds.")
# Module section template # Module section template
MOD_SECTION_TPL = "cloud_%s_modules" MOD_SECTION_TPL = "cloud_%s_modules"

View File

@ -26,23 +26,20 @@ from cloudinit.settings import PER_ALWAYS
frequency = PER_ALWAYS frequency = PER_ALWAYS
FINAL_MESSAGE_DEF = ("Cloud-init v. {{version}} finished at {{timestamp}}." # Cheetah formated default message
" Up {{uptime}} seconds.") FINAL_MESSAGE_DEF = ("Cloud-init v. ${version} finished at ${timestamp}."
" Up ${uptime} seconds.")
def handle(_name, cfg, cloud, log, args): def handle(_name, cfg, cloud, log, args):
msg_in = None msg_in = ''
if len(args) != 0: if len(args) != 0:
msg_in = args[0] msg_in = str(args[0])
else: else:
msg_in = util.get_cfg_option_str(cfg, "final_message") msg_in = util.get_cfg_option_str(cfg, "final_message". msg_in)
if not msg_in:
template_fn = cloud.get_template_filename('final_message')
if template_fn:
msg_in = util.load_file(template_fn)
msg_in = msg_in.strip()
if not msg_in: if not msg_in:
msg_in = FINAL_MESSAGE_DEF msg_in = FINAL_MESSAGE_DEF

View File

@ -36,11 +36,11 @@ def handle(name, cfg, cloud, log, _args):
return return
# Render from a template file # Render from a template file
distro_n = cloud.distro.name tpl_fn_name = cloud.get_template_filename("hosts.%s" %
tpl_fn_name = cloud.get_template_filename("hosts.%s" % (distro_n)) (cloud.distro.name))
if not tpl_fn_name: if not tpl_fn_name:
raise RuntimeError(("No hosts template could be" raise RuntimeError(("No hosts template could be"
" found for distro %s") % (distro_n)) " found for distro %s") % (cloud.distro.name))
out_fn = cloud.paths.join(False, '/etc/hosts') out_fn = cloud.paths.join(False, '/etc/hosts')
templater.render_to_file(tpl_fn_name, out_fn, templater.render_to_file(tpl_fn_name, out_fn,

View File

@ -20,13 +20,13 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from tempita import Template from Cheetah.Template import Template
from cloudinit import util from cloudinit import util
def render_from_file(fn, params): def render_from_file(fn, params):
return render_string(util.load_file(fn), params, name=fn) return render_string(util.load_file(fn), params)
def render_to_file(fn, outfn, params, mode=0644): def render_to_file(fn, outfn, params, mode=0644):
@ -34,8 +34,7 @@ def render_to_file(fn, outfn, params, mode=0644):
util.write_file(outfn, contents, mode=mode) util.write_file(outfn, contents, mode=mode)
def render_string(content, params, name=None): def render_string(content, params):
tpl = Template(content, name=name)
if not params: if not params:
params = dict() params = {}
return tpl.substitute(params) return Template(content, searchList=[params]).respond()

View File

@ -25,15 +25,16 @@ from cloudinit import util
import argparse import argparse
# Package names that will showup in requires to what we can actually # Package names that will showup in requires to what we can actually
# use in our debian 'control' file # use in our debian 'control' file, this is a translation of the 'requires'
# file pypi package name to a debian/ubuntu package name.
PKG_MP = { PKG_MP = {
'tempita': 'python-tempita',
'boto': 'python-boto', 'boto': 'python-boto',
'configobj': 'python-configobj', 'configobj': 'python-configobj',
'oauth': 'python-oauth', 'oauth': 'python-oauth',
'yaml': 'python-yaml', 'pyyaml': 'python-yaml',
'prettytable': 'python-prettytable', 'prettytable': 'python-prettytable',
'argparse': 'python-argparse', 'argparse': 'python-argparse',
'cheetah': 'python-cheetah',
} }
@ -43,7 +44,7 @@ def write_debian_folder(root, version, revno):
# Fill in the change log template # Fill in the change log template
templater.render_to_file(util.abs_join(find_root(), templater.render_to_file(util.abs_join(find_root(),
'packages', 'debian', 'changelog'), 'packages', 'debian', 'changelog.in'),
util.abs_join(deb_dir, 'changelog'), util.abs_join(deb_dir, 'changelog'),
params={ params={
'version': version, 'version': version,
@ -53,27 +54,23 @@ def write_debian_folder(root, version, revno):
# Write out the control file template # Write out the control file template
cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')] cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')]
(stdout, _stderr) = util.subp(cmd) (stdout, _stderr) = util.subp(cmd)
pkgs = [p.lower().strip() for p in stdout.splitlines()]
# Map to known packages # Map to known packages
pkgs = [p.lower().strip() for p in stdout.splitlines()]
requires = [] requires = []
for p in pkgs: for p in pkgs:
tgt_pkg = None tgt_pkg = PKG_MP.get(p)
for name in PKG_MP.keys():
if p.find(name) != -1:
tgt_pkg = PKG_MP.get(name)
break
if not tgt_pkg: if not tgt_pkg:
raise RuntimeError(("Do not know how to translate %s to " raise RuntimeError(("Do not know how to translate pypi dependency"
" a known package") % (p)) " %r to a known package") % (p))
else: else:
requires.append(tgt_pkg) requires.append(tgt_pkg)
templater.render_to_file(util.abs_join(find_root(), templater.render_to_file(util.abs_join(find_root(),
'packages', 'debian', 'control'), 'packages', 'debian', 'control.in'),
util.abs_join(deb_dir, 'control'), util.abs_join(deb_dir, 'control'),
params={'requires': requires}) params={'requires': requires})
# Just copy the following directly # Just copy the following directly
for base_fn in ['dirs', 'copyright', 'compat', 'pycompat', 'rules']: for base_fn in ['dirs', 'copyright', 'compat', 'pycompat', 'rules']:
shutil.copy(util.abs_join(find_root(), shutil.copy(util.abs_join(find_root(),
@ -143,6 +140,12 @@ def main():
cmd.extend(os.listdir(xdir)) cmd.extend(os.listdir(xdir))
util.subp(cmd, capture=capture) util.subp(cmd, capture=capture)
# Copy it locally for reference
shutil.copy(util.abs_join(tdir, tar_fn),
util.abs_join(os.getcwd(), tar_fn))
print("Copied that archive to %r for local usage (if desired)." %
(util.abs_join(os.getcwd(), tar_fn)))
print("Running 'debuild' in %r" % (xdir)) print("Running 'debuild' in %r" % (xdir))
with util.chdir(xdir): with util.chdir(xdir):
cmd = ['debuild', '--preserve-envvar', 'INIT_SYSTEM'] cmd = ['debuild', '--preserve-envvar', 'INIT_SYSTEM']

View File

@ -31,14 +31,16 @@ from cloudinit import templater
from cloudinit import util from cloudinit import util
# Mapping of expected packages to there full name... # Mapping of expected packages to there full name...
# this is a translation of the 'requires'
# file pypi package name to a redhat/fedora package name.
PKG_MP = { PKG_MP = {
'boto': 'python-boto', 'boto': 'python-boto',
'tempita': 'python-tempita', 'cheetah': 'python-cheetah',
'prettytable': 'python-prettytable', 'prettytable': 'python-prettytable',
'oauth': 'python-oauth', 'oauth': 'python-oauth',
'configobj': 'python-configobj', 'configobj': 'python-configobj',
'yaml': 'PyYAML', 'pyyaml': 'PyYAML',
'argparse': 'python-argparse' 'argparse': 'python-argparse',
} }
# Subdirectories of the ~/rpmbuild dir # Subdirectories of the ~/rpmbuild dir
@ -106,25 +108,18 @@ def generate_spec_contents(args, tmpl_fn, arc_fn):
subs['revno'] = revno subs['revno'] = revno
subs['release'] = "bzr%s" % (revno) subs['release'] = "bzr%s" % (revno)
subs['archive_name'] = arc_fn subs['archive_name'] = arc_fn
subs['bd_requires'] = ['python-devel', 'python-setuptools']
cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')] cmd = [util.abs_join(find_root(), 'tools', 'read-dependencies')]
(stdout, _stderr) = util.subp(cmd) (stdout, _stderr) = util.subp(cmd)
# Map to known packages
pkgs = [p.lower().strip() for p in stdout.splitlines()] pkgs = [p.lower().strip() for p in stdout.splitlines()]
# Map to known packages # Map to known packages
requires = [] requires = []
for p in pkgs: for p in pkgs:
tgt_pkg = None tgt_pkg = PKG_MP.get(p)
for name in PKG_MP.keys():
if p.find(name) != -1:
tgt_pkg = PKG_MP.get(name)
break
if not tgt_pkg: if not tgt_pkg:
raise RuntimeError(("Do not know how to translate %s to " raise RuntimeError(("Do not know how to translate pypi dependency"
" a known package") % (p)) " %r to a known package") % (p))
else: else:
requires.append(tgt_pkg) requires.append(tgt_pkg)
subs['requires'] = requires subs['requires'] = requires
@ -195,8 +190,10 @@ def main():
print("Archived the code in %r" % (real_archive_fn)) print("Archived the code in %r" % (real_archive_fn))
# Form the spec file to be used # Form the spec file to be used
tmpl_fn = util.abs_join(find_root(), 'packages', 'redhat', 'cloud-init.spec') tmpl_fn = util.abs_join(find_root(), 'packages',
contents = generate_spec_contents(args, tmpl_fn, os.path.basename(archive_fn)) 'redhat', 'cloud-init.spec.in')
contents = generate_spec_contents(args, tmpl_fn,
os.path.basename(archive_fn))
spec_fn = util.abs_join(root_dir, 'cloud-init.spec') spec_fn = util.abs_join(root_dir, 'cloud-init.spec')
util.write_file(spec_fn, contents) util.write_file(spec_fn, contents)
print("Created spec file at %r" % (spec_fn)) print("Created spec file at %r" % (spec_fn))

View File

@ -1,4 +1,5 @@
cloud-init ({{version}}~{{revision}}-1) UNRELEASED; urgency=low ## This is a cheetah template
cloud-init (${version}~${revision}-1) UNRELEASED; urgency=low
* build * build

View File

@ -1,13 +1,16 @@
## This is a cheetah template
Source: cloud-init Source: cloud-init
Section: admin Section: admin
Priority: extra Priority: extra
Maintainer: Scott Moser <smoser@ubuntu.com> Maintainer: Scott Moser <smoser@ubuntu.com>
Build-Depends: cdbs, Build-Depends: cdbs,
debhelper (>= 5.0.38), debhelper (>= 5.0.38),
python (>= 2.6.6-3~), python (>= 2.6.6-3~),
python-nose, python-nose,
pyflakes, pyflakes,
pylint, pylint,
python-setuptools,
python-cheetah,
python-mocker, python-mocker,
python-setuptools python-setuptools
XS-Python-Version: all XS-Python-Version: all
@ -18,13 +21,13 @@ Architecture: all
Depends: cloud-utils, Depends: cloud-utils,
procps, procps,
python, python,
{{for r in requires}} #for $r in $requires
{{r}}, ${r},
{{endfor}} #end for
python-software-properties, python-software-properties,
${misc:Depends}, \${misc:Depends},
${python:Depends} \${python:Depends}
XB-Python-Version: ${python:Versions} XB-Python-Version: \${python:Versions}
Description: Init scripts for cloud instances Description: Init scripts for cloud instances
Cloud instances need special scripts to run during initialisation Cloud instances need special scripts to run during initialisation
to retrieve and install ssh keys and to let the user run various scripts. to retrieve and install ssh keys and to let the user run various scripts.

View File

@ -1,3 +1,4 @@
## This is a cheetah template
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
# See: http://www.zarb.org/~jasonc/macros.php # See: http://www.zarb.org/~jasonc/macros.php
@ -5,20 +6,21 @@
# Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html # Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
Name: cloud-init Name: cloud-init
Version: {{version}} Version: ${version}
Release: {{release}}%{?dist} Release: ${release}%{?dist}
Summary: Cloud instance init scripts Summary: Cloud instance init scripts
Group: System Environment/Base Group: System Environment/Base
License: GPLv3 License: GPLv3
URL: http://launchpad.net/cloud-init URL: http://launchpad.net/cloud-init
Source0: {{archive_name}} Source0: ${archive_name}
BuildArch: noarch BuildArch: noarch
BuildRoot: %{_tmppath} BuildRoot: %{_tmppath}
BuildRequires: python-devel BuildRequires: python-devel
BuildRequires: python-setuptools BuildRequires: python-setuptools
BuildRequires: python-cheetah
# System util packages needed # System util packages needed
Requires: shadow-utils Requires: shadow-utils
@ -30,23 +32,23 @@ Requires: procps
Requires: shadow-utils Requires: shadow-utils
# Install pypi 'dynamic' requirements # Install pypi 'dynamic' requirements
{{for r in requires}} #for $r in $requires
Requires: {{r}} Requires: ${r}
{{endfor}} #end for
{{if sysvinit}} #if $sysvinit
Requires(post): chkconfig Requires(post): chkconfig
Requires(postun): initscripts Requires(postun): initscripts
Requires(preun): chkconfig Requires(preun): chkconfig
Requires(preun): initscripts Requires(preun): initscripts
{{endif}} #end if
{{if systemd}} #if $systemd
BuildRequires: systemd-units BuildRequires: systemd-units
Requires(post): systemd-units Requires(post): systemd-units
Requires(postun): systemd-units Requires(postun): systemd-units
Requires(preun): systemd-units Requires(preun): systemd-units
{{endif}} #end if
%description %description
Cloud-init is a set of init scripts for cloud instances. Cloud instances Cloud-init is a set of init scripts for cloud instances. Cloud instances
@ -54,89 +56,89 @@ need special scripts to run during initialization to retrieve and install
ssh keys and to let the user run various scripts. ssh keys and to let the user run various scripts.
%prep %prep
%setup -q -n %{name}-%{version}~{{release}} %setup -q -n %{name}-%{version}~${release}
%build %build
%{__python} setup.py build %{__python} setup.py build
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf \$RPM_BUILD_ROOT
%{__python} setup.py install -O1 \ %{__python} setup.py install -O1 \
--skip-build --root $RPM_BUILD_ROOT \ --skip-build --root \$RPM_BUILD_ROOT \
--init-system={{init_sys}} --init-system=${init_sys}
# Note that /etc/rsyslog.d didn't exist by default until F15. # Note that /etc/rsyslog.d didn't exist by default until F15.
# el6 request: https://bugzilla.redhat.com/show_bug.cgi?id=740420 # el6 request: https://bugzilla.redhat.com/show_bug.cgi?id=740420
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d mkdir -p \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d
cp -p tools/21-cloudinit.conf \ cp -p tools/21-cloudinit.conf \
$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf \$RPM_BUILD_ROOT/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf \$RPM_BUILD_ROOT
%post %post
{{if systemd}} #if $systemd
if [ $1 -eq 1 ] if [ \$1 -eq 1 ]
then then
/bin/systemctl enable cloud-config.service >/dev/null 2>&1 || : /bin/systemctl enable cloud-config.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-final.service >/dev/null 2>&1 || : /bin/systemctl enable cloud-final.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-init.service >/dev/null 2>&1 || : /bin/systemctl enable cloud-init.service >/dev/null 2>&1 || :
/bin/systemctl enable cloud-init-local.service >/dev/null 2>&1 || : /bin/systemctl enable cloud-init-local.service >/dev/null 2>&1 || :
fi fi
{{endif}} #end if
{{if sysvinit}} #if $sysvinit
/sbin/chkconfig --add %{_initrddir}/cloud-init-local /sbin/chkconfig --add %{_initrddir}/cloud-init-local
/sbin/chkconfig --add %{_initrddir}/cloud-init /sbin/chkconfig --add %{_initrddir}/cloud-init
/sbin/chkconfig --add %{_initrddir}/cloud-config /sbin/chkconfig --add %{_initrddir}/cloud-config
/sbin/chkconfig --add %{_initrddir}/cloud-final /sbin/chkconfig --add %{_initrddir}/cloud-final
{{endif}} #end if
%preun %preun
{{if sysvinit}} #if $sysvinit
if [ $1 -eq 0 ] if [ \$1 -eq 0 ]
then then
/sbin/service cloud-init stop >/dev/null 2>&1 /sbin/service cloud-init stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cloud-init /sbin/chkconfig --del cloud-init || :
/sbin/service cloud-init-local stop >/dev/null 2>&1 /sbin/service cloud-init-local stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cloud-init-local /sbin/chkconfig --del cloud-init-local || :
/sbin/service cloud-config stop >/dev/null 2>&1 /sbin/service cloud-config stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cloud-config /sbin/chkconfig --del cloud-config || :
/sbin/service cloud-final stop >/dev/null 2>&1 /sbin/service cloud-final stop >/dev/null 2>&1 || :
/sbin/chkconfig --del cloud-final /sbin/chkconfig --del cloud-final || :
fi fi
{{endif}} #end if
{{if systemd}} #if $systemd
if [ $1 -eq 0 ] if [ \$1 -eq 0 ]
then then
/bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || : /bin/systemctl --no-reload disable cloud-config.service >/dev/null 2>&1 || :
/bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || : /bin/systemctl --no-reload disable cloud-final.service >/dev/null 2>&1 || :
/bin/systemctl --no-reload disable cloud-init.service >/dev/null 2>&1 || : /bin/systemctl --no-reload disable cloud-init.service >/dev/null 2>&1 || :
/bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || : /bin/systemctl --no-reload disable cloud-init-local.service >/dev/null 2>&1 || :
fi fi
{{endif}} #end if
%postun %postun
{{if systemd}} #if $systemd
/bin/systemctl daemon-reload >/dev/null 2>&1 || : /bin/systemctl daemon-reload >/dev/null 2>&1 || :
{{endif}} #end if
%files %files
{{if sysvinit}} #if $sysvinit
%attr(0755, root, root) %{_initddir}/cloud-config %attr(0755, root, root) %{_initddir}/cloud-config
%attr(0755, root, root) %{_initddir}/cloud-final %attr(0755, root, root) %{_initddir}/cloud-final
%attr(0755, root, root) %{_initddir}/cloud-init-local %attr(0755, root, root) %{_initddir}/cloud-init-local
%attr(0755, root, root) %{_initddir}/cloud-init %attr(0755, root, root) %{_initddir}/cloud-init
{{endif}} #end if
{{if systemd}} #if $systemd
%{_unitdir}/cloud-* %{_unitdir}/cloud-*
{{endif}} #end if
# Program binaries # Program binaries
%{_bindir}/cloud-init* %{_bindir}/cloud-init*
@ -165,4 +167,4 @@ fi
%changelog %changelog
{{changelog}} ${changelog}

View File

@ -1,12 +1,12 @@
log_level :info log_level :info
log_location "/var/log/chef/client.log" log_location "/var/log/chef/client.log"
ssl_verify_mode :verify_none ssl_verify_mode :verify_none
validation_client_name "{{validation_name}}" validation_client_name "$validation_name"
validation_key "/etc/chef/validation.pem" validation_key "/etc/chef/validation.pem"
client_key "/etc/chef/client.pem" client_key "/etc/chef/client.pem"
chef_server_url "{{server_url}}" chef_server_url "$server_url"
environment "{{environment}}" environment "$environment"
node_name "{{node_name}}" node_name "$node_name"
json_attribs "/etc/chef/firstboot.json" json_attribs "/etc/chef/firstboot.json"
file_cache_path "/var/cache/chef" file_cache_path "/var/cache/chef"
file_backup_path "/var/backups/chef" file_backup_path "/var/backups/chef"

View File

@ -1,22 +1,23 @@
{{# This file /etc/cloud/templates/hosts.tmpl is only utilized #*
This file /etc/cloud/templates/hosts.redhat.tmpl is only utilized
if enabled in cloud-config. Specifically, in order to enable it if enabled in cloud-config. Specifically, in order to enable it
you need to add the following to config: you need to add the following to config:
manage_etc_hosts: True}} manage_etc_hosts: True
# *#
# Your system has configured 'manage_etc_hosts' as True. # Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist # As a result, if you wish for changes to this file to persist
# then you will need to either # then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl # a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in # b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data # /etc/cloud/cloud.cfg or cloud-config from user-data
# #
# The following lines are desirable for IPv4 capable hosts # The following lines are desirable for IPv4 capable hosts
127.0.0.1 {{fqdn}} {{hostname}} 127.0.0.1 ${fqdn} ${hostname}
127.0.0.1 localhost.localdomain localhost 127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4 127.0.0.1 localhost4.localdomain4 localhost4
# The following lines are desirable for IPv6 capable hosts # The following lines are desirable for IPv6 capable hosts
::1 {{fqdn}} {{hostname}} ::1 ${fqdn} ${hostname}
::1 localhost.localdomain localhost ::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6 ::1 localhost6.localdomain6 localhost6

View File

@ -1,7 +1,9 @@
{{# This file /etc/cloud/templates/hosts.tmpl is only utilized ## This file (/etc/cloud/templates/hosts.tmpl) is only utilized
if enabled in cloud-config. Specifically, in order to enable it ## if enabled in cloud-config. Specifically, in order to enable it
you need to add the following to config: ## you need to add the following to config:
manage_etc_hosts: True}} ## manage_etc_hosts: True
##
## Note, double-hash commented lines will not appear in /etc/hosts
# #
# Your system has configured 'manage_etc_hosts' as True. # Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist # As a result, if you wish for changes to this file to persist
@ -10,8 +12,8 @@
# b.) change or remove the value of 'manage_etc_hosts' in # b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data # /etc/cloud/cloud.cfg or cloud-config from user-data
# #
# The following lines are desirable for IPv4 capable hosts ## The value '$hostname' will be replaced with the local-hostname
127.0.1.1 {{fqdn}} {{hostname}} 127.0.1.1 $fqdn $hostname
127.0.0.1 localhost 127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts # The following lines are desirable for IPv6 capable hosts
@ -21,4 +23,3 @@ ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes ff02::1 ip6-allnodes
ff02::2 ip6-allrouters ff02::2 ip6-allrouters
ff02::3 ip6-allhosts ff02::3 ip6-allhosts

View File

@ -1,59 +1,60 @@
# Note, this file is written by cloud-init on first boot of an instance \## Note, this file is written by cloud-init on first boot of an instance
# modifications made here will not survive a re-bundle. \## modifications made here will not survive a re-bundle.
# if you wish to make changes you can: \## if you wish to make changes you can:
# a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg \## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
# or do the same in user-data \## or do the same in user-data
# b.) add sources in /etc/apt/sources.list.d \## b.) add sources in /etc/apt/sources.list.d
# c.) make changes to template file /etc/cloud/templates/sources.list.tmpl \## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
\###
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution. # newer versions of the distribution.
deb {{mirror}} {{codename}} main deb $mirror $codename main
deb-src {{mirror}} {{codename}} main deb-src $mirror $codename main
# Major bug fix updates produced after the final release of the \## Major bug fix updates produced after the final release of the
# distribution. \## distribution.
deb {{mirror}} {{codename}}-updates main deb $mirror $codename-updates main
deb-src {{mirror}} {{codename}}-updates main deb-src $mirror $codename-updates main
# N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu \## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
# team. Also, please note that software in universe WILL NOT receive any \## team. Also, please note that software in universe WILL NOT receive any
# review or updates from the Ubuntu security team. \## review or updates from the Ubuntu security team.
deb {{mirror}} {{codename}} universe deb $mirror $codename universe
deb-src {{mirror}} {{codename}} universe deb-src $mirror $codename universe
deb {{mirror}} {{codename}}-updates universe deb $mirror $codename-updates universe
deb-src {{mirror}} {{codename}}-updates universe deb-src $mirror $codename-updates universe
# N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu \## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
# team, and may not be under a free licence. Please satisfy yourself as to \## team, and may not be under a free licence. Please satisfy yourself as to
# your rights to use the software. Also, please note that software in \## your rights to use the software. Also, please note that software in
# multiverse WILL NOT receive any review or updates from the Ubuntu \## multiverse WILL NOT receive any review or updates from the Ubuntu
# security team. \## security team.
# deb {{mirror}} {{codename}} multiverse # deb $mirror $codename multiverse
# deb-src {{mirror}} {{codename}} multiverse # deb-src $mirror $codename multiverse
# deb {{mirror}} {{codename}}-updates multiverse # deb $mirror $codename-updates multiverse
# deb-src {{mirror}} {{codename}}-updates multiverse # deb-src $mirror $codename-updates multiverse
# Uncomment the following two lines to add software from the 'backports' \## Uncomment the following two lines to add software from the 'backports'
# repository. \## repository.
# N.B. software from this repository may not have been tested as \## N.B. software from this repository may not have been tested as
# extensively as that contained in the main release, although it includes \## extensively as that contained in the main release, although it includes
# newer versions of some applications which may provide useful features. \## newer versions of some applications which may provide useful features.
# Also, please note that software in backports WILL NOT receive any review \## Also, please note that software in backports WILL NOT receive any review
# or updates from the Ubuntu security team. \## or updates from the Ubuntu security team.
# deb {{mirror}} {{codename}}-backports main restricted universe multiverse # deb $mirror $codename-backports main restricted universe multiverse
# deb-src {{mirror}} {{codename}}-backports main restricted universe multiverse # deb-src $mirror $codename-backports main restricted universe multiverse
# Uncomment the following two lines to add software from Canonical's \## Uncomment the following two lines to add software from Canonical's
# 'partner' repository. \## 'partner' repository.
# This software is not part of Ubuntu, but is offered by Canonical and the \## This software is not part of Ubuntu, but is offered by Canonical and the
# respective vendors as a service to Ubuntu users. \## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu {{codename}} partner # deb http://archive.canonical.com/ubuntu $codename partner
# deb-src http://archive.canonical.com/ubuntu {{codename}} partner # deb-src http://archive.canonical.com/ubuntu $codename partner
deb http://security.ubuntu.com/ubuntu {{codename}}-security main deb http://security.ubuntu.com/ubuntu $codename-security main
deb-src http://security.ubuntu.com/ubuntu {{codename}}-security main deb-src http://security.ubuntu.com/ubuntu $codename-security main
deb http://security.ubuntu.com/ubuntu {{codename}}-security universe deb http://security.ubuntu.com/ubuntu $codename-security universe
deb-src http://security.ubuntu.com/ubuntu {{codename}}-security universe deb-src http://security.ubuntu.com/ubuntu $codename-security universe
# deb http://security.ubuntu.com/ubuntu {{codename}}-security multiverse # deb http://security.ubuntu.com/ubuntu $codename-security multiverse
# deb-src http://security.ubuntu.com/ubuntu {{codename}}-security multiverse # deb-src http://security.ubuntu.com/ubuntu $codename-security multiverse