Gilles Dartiguelongue has proposed merging ~gilles-dartiguelongue/cloud-init:gentoo-fixes into cloud-init:master.
Requested reviews: cloud-init commiters (cloud-init-dev) For more details, see: https://code.launchpad.net/~gilles-dartiguelongue/cloud-init/+git/cloud-init/+merge/358777 Fix various issues with Gentoo distribution class I discovered while playing with cloud-init and LXD images. Fixes bug #1799544. -- Your team cloud-init commiters is requested to review the proposed merge of ~gilles-dartiguelongue/cloud-init:gentoo-fixes into cloud-init:master.
diff --git a/cloudinit/distros/gentoo.py b/cloudinit/distros/gentoo.py index dc57717..f8b5223 100644 --- a/cloudinit/distros/gentoo.py +++ b/cloudinit/distros/gentoo.py @@ -20,7 +20,7 @@ LOG = logging.getLogger(__name__) class Distro(distros.Distro): - locale_conf_fn = '/etc/locale.gen' + locale_conf_fn = '/etc/env.d/02locale' network_conf_fn = '/etc/conf.d/net' resolve_conf_fn = '/etc/resolv.conf' hostname_conf_fn = '/etc/conf.d/hostname' @@ -189,30 +189,33 @@ class Distro(distros.Distro): distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz)) def package_command(self, command, args=None, pkgs=None): - if pkgs is None: - pkgs = [] - - cmd = list('emerge') + cmd = ['emerge'] # Redirect output cmd.append("--quiet") - if args and isinstance(args, str): - cmd.append(args) - elif args and isinstance(args, list): - cmd.extend(args) + if command == "upgrade": + cmd.append(["--update", "world"]) + else: + if pkgs is None: + pkgs = [] + + if args and isinstance(args, str): + cmd.append(args) + elif args and isinstance(args, list): + cmd.extend(args) - if command: - cmd.append(command) + if command: + cmd.append(command) - pkglist = util.expand_package_list('%s-%s', pkgs) - cmd.extend(pkglist) + pkglist = util.expand_package_list('%s-%s', pkgs) + cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, capture=False) def update_package_sources(self): self._runner.run("update-sources", self.package_command, - ["-u", "world"], freq=PER_INSTANCE) + ["--sync"], freq=PER_INSTANCE) def convert_resolv_conf(settings): diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl index 1fef133..3f5a41a 100644 --- a/config/cloud.cfg.tmpl +++ b/config/cloud.cfg.tmpl @@ -134,7 +134,7 @@ cloud_final_modules: # (not accessible to handlers/transforms) system_info: # This will affect which distro class gets used -{% if variant in ["centos", "debian", "fedora", "rhel", "suse", "ubuntu", "freebsd"] %} +{% if variant in ["centos", "debian", "fedora", "rhel", "suse", "ubuntu", "freebsd", "gentoo"] %} distro: {{ variant }} {% else %} # Unknown/fallback distro. @@ -172,7 +172,7 @@ system_info: primary: http://ports.ubuntu.com/ubuntu-ports security: http://ports.ubuntu.com/ubuntu-ports ssh_svcname: ssh -{% elif variant in ["centos", "rhel", "fedora", "suse"] %} +{% elif variant in ["centos", "rhel", "fedora", "suse", "gentoo"] %} # Default user name + that default users groups (if added/used) default_user: name: {{ variant }} @@ -180,6 +180,10 @@ system_info: gecos: {{ variant }} Cloud User {% if variant == "suse" %} groups: [cdrom, users] +{% elif variant == "gentoo" %} + groups: [users, wheel] + primary_group: users + no_user_group: true {% else %} groups: [wheel, adm, systemd-journal] {% endif %} diff --git a/templates/hosts.gentoo.tmpl b/templates/hosts.gentoo.tmpl new file mode 100644 index 0000000..cd045fa --- /dev/null +++ b/templates/hosts.gentoo.tmpl @@ -0,0 +1,24 @@ +## template:jinja +{# +This file /etc/cloud/templates/hosts.gentoo.tmpl is only utilized +if enabled in cloud-config. Specifically, in order to enable it +you need to add the following to config: + manage_etc_hosts: True +-#} +# Your system has configured 'manage_etc_hosts' as True. +# As a result, if you wish for changes to this file to persist +# then you will need to either +# a.) make changes to the master file in /etc/cloud/templates/hosts.gentoo.tmpl +# b.) change or remove the value of 'manage_etc_hosts' in +# /etc/cloud/cloud.cfg or cloud-config from user-data +# +# The following lines are desirable for IPv4 capable hosts +127.0.0.1 {{fqdn}} {{hostname}} +127.0.0.1 localhost.localdomain localhost +127.0.0.1 localhost4.localdomain4 localhost4 + +# The following lines are desirable for IPv6 capable hosts +::1 {{fqdn}} {{hostname}} +::1 localhost.localdomain localhost +::1 localhost6.localdomain6 localhost6 + diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg index 8b7cb87..d109044 100755 --- a/tools/render-cloudcfg +++ b/tools/render-cloudcfg @@ -4,7 +4,7 @@ import argparse import os import sys -VARIANTS = ["bsd", "centos", "fedora", "rhel", "suse", "ubuntu", "unknown"] +VARIANTS = ["bsd", "centos", "fedora", "gentoo", "rhel", "suse", "ubuntu", "unknown"] if "avoid-pep8-E402-import-not-top-of-file": _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
_______________________________________________ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp