Merge ~gilles-dartiguelongue/cloud-init:gentoo-fixes into cloud-init:master

Proposed by Gilles Dartiguelongue
Status: Work in progress
Proposed branch: ~gilles-dartiguelongue/cloud-init:gentoo-fixes
Merge into: cloud-init:master
Diff against target: 136 lines (+48/-17)
4 files modified
cloudinit/distros/gentoo.py (+17/-14)
config/cloud.cfg.tmpl (+6/-2)
templates/hosts.gentoo.tmpl (+24/-0)
tools/render-cloudcfg (+1/-1)
Reviewer Review Type Date Requested Status
Chad Smith Needs Information
Server Team CI bot continuous-integration Approve
Review via email: mp+358777@code.launchpad.net

Description of the change

Fix various issues with Gentoo distribution and templates

A couple of issues with gentoo support that are now fixed:
 - locale is now at /etc/env.d/02locale
 - packages: provide 'emerge' command as a list not string to subp
 - cloud.cfg template supports gentoo now
 - Do not use 'emerge --upgrade world' unless a full upgrade is requested
 - only use --sync before package installs

LP: #1799544

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

Are there existing gentoo cloud-init enable images? if not, which lxd gentoo image did you start with and how were you getting cloud-init installed?

Revision history for this message
Gilles Dartiguelongue (gilles-dartiguelongue) wrote :

I'm working on creating cloud-init enabled lxd images using packer from the gentoo lxc template. I can push the required json file somewhere as I intend to make this public when I'm satisfied with the result.

Revision history for this message
Ryan Harper (raharper) wrote :
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:7868b97507d0dd7d7721ad5c4539e22c67635f92
https://jenkins.ubuntu.com/server/job/cloud-init-ci/513/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/513/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chad Smith (chad.smith) wrote :

Hi,
Thank you for contributing to cloud-init.

To contribute, you must sign the Canonical Contributor License Agreement
(CLA) [1].

If you have already signed it as an individual, your Launchpad user will
be listed in the contributor-agreement-canonical launchpad group [2].
Unfortunately there is no easy way to check if an organization or company
you are doing work for has signed. If you are unsure or have questions,
email <email address hidden> or ping chad.smith, raharper or powersj
in #cloud-init channel via freenode.

For information on how to sign, please see the HACKING document [3].

Thanks again, and please feel free to reach out with any questions.


[1] http://www.canonical.com/contributors
[2] https://launchpad.net/~contributor-agreement-canonical/+members
[3] http://cloudinit.readthedocs.io/en/latest/topics/hacking.html

Revision history for this message
Chad Smith (chad.smith) wrote :

Thanks again for this branch Gilles.

Can you comment on my inline question and mention whether you have signed the CLA then we can go ahead an land this branch .

review: Needs Information
Revision history for this message
Chad Smith (chad.smith) wrote :

I updated the commit message at the top of the merge proposal. Please review it to see if it works for you. Thanks again

Revision history for this message
Chad Smith (chad.smith) wrote :

This branch can land in tip, but we haven't yet gotten confirmation that the CLA is signed per comment https://code.launchpad.net/~gilles-dartiguelongue/cloud-init/+git/cloud-init/+merge/358777/comments/941288

As soon as you get a chance to confirm that you've signed this we will land this branch.

Much thanks!

Unmerged commits

7868b97... by Gilles Dartiguelongue <email address hidden>

gentoo: add support for package_upgrade

b15c4c4... by Gilles Dartiguelongue <email address hidden>

gentoo: fix update_package_sources function

Method is meant to update packages repository, not to update the system.

3756cde... by Gilles Dartiguelongue <email address hidden>

gentoo: fix filename for storing locale

There must have been a misunderstanding as locale.gen is meant to
contain locales to be generated if no argument is passed to locale-gen.

When using openrc, Gentoo stores system locale in /etc/env.d/02locale
which is generally manipulated through eselect.

823454f... by Gilles Dartiguelongue <email address hidden>

Add support for gentoo in cloud.cfg and templates

85459ea... by Gilles Dartiguelongue <email address hidden>

gentoo: fix package installation command

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/distros/gentoo.py b/cloudinit/distros/gentoo.py
2index dc57717..22ad2cf 100644
3--- a/cloudinit/distros/gentoo.py
4+++ b/cloudinit/distros/gentoo.py
5@@ -20,7 +20,7 @@ LOG = logging.getLogger(__name__)
6
7
8 class Distro(distros.Distro):
9- locale_conf_fn = '/etc/locale.gen'
10+ locale_conf_fn = '/etc/env.d/02locale'
11 network_conf_fn = '/etc/conf.d/net'
12 resolve_conf_fn = '/etc/resolv.conf'
13 hostname_conf_fn = '/etc/conf.d/hostname'
14@@ -189,30 +189,33 @@ class Distro(distros.Distro):
15 distros.set_etc_timezone(tz=tz, tz_file=self._find_tz_file(tz))
16
17 def package_command(self, command, args=None, pkgs=None):
18- if pkgs is None:
19- pkgs = []
20-
21- cmd = list('emerge')
22+ cmd = ['emerge']
23 # Redirect output
24 cmd.append("--quiet")
25
26- if args and isinstance(args, str):
27- cmd.append(args)
28- elif args and isinstance(args, list):
29- cmd.extend(args)
30+ if command == "upgrade":
31+ cmd.extend(["--update", "world"])
32+ else:
33+ if pkgs is None:
34+ pkgs = []
35+
36+ if args and isinstance(args, str):
37+ cmd.append(args)
38+ elif args and isinstance(args, list):
39+ cmd.extend(args)
40
41- if command:
42- cmd.append(command)
43+ if command:
44+ cmd.append(command)
45
46- pkglist = util.expand_package_list('%s-%s', pkgs)
47- cmd.extend(pkglist)
48+ pkglist = util.expand_package_list('%s-%s', pkgs)
49+ cmd.extend(pkglist)
50
51 # Allow the output of this to flow outwards (ie not be captured)
52 util.subp(cmd, capture=False)
53
54 def update_package_sources(self):
55 self._runner.run("update-sources", self.package_command,
56- ["-u", "world"], freq=PER_INSTANCE)
57+ ["--sync"], freq=PER_INSTANCE)
58
59
60 def convert_resolv_conf(settings):
61diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl
62index 1fef133..3f5a41a 100644
63--- a/config/cloud.cfg.tmpl
64+++ b/config/cloud.cfg.tmpl
65@@ -134,7 +134,7 @@ cloud_final_modules:
66 # (not accessible to handlers/transforms)
67 system_info:
68 # This will affect which distro class gets used
69-{% if variant in ["centos", "debian", "fedora", "rhel", "suse", "ubuntu", "freebsd"] %}
70+{% if variant in ["centos", "debian", "fedora", "rhel", "suse", "ubuntu", "freebsd", "gentoo"] %}
71 distro: {{ variant }}
72 {% else %}
73 # Unknown/fallback distro.
74@@ -172,7 +172,7 @@ system_info:
75 primary: http://ports.ubuntu.com/ubuntu-ports
76 security: http://ports.ubuntu.com/ubuntu-ports
77 ssh_svcname: ssh
78-{% elif variant in ["centos", "rhel", "fedora", "suse"] %}
79+{% elif variant in ["centos", "rhel", "fedora", "suse", "gentoo"] %}
80 # Default user name + that default users groups (if added/used)
81 default_user:
82 name: {{ variant }}
83@@ -180,6 +180,10 @@ system_info:
84 gecos: {{ variant }} Cloud User
85 {% if variant == "suse" %}
86 groups: [cdrom, users]
87+{% elif variant == "gentoo" %}
88+ groups: [users, wheel]
89+ primary_group: users
90+ no_user_group: true
91 {% else %}
92 groups: [wheel, adm, systemd-journal]
93 {% endif %}
94diff --git a/templates/hosts.gentoo.tmpl b/templates/hosts.gentoo.tmpl
95new file mode 100644
96index 0000000..cd045fa
97--- /dev/null
98+++ b/templates/hosts.gentoo.tmpl
99@@ -0,0 +1,24 @@
100+## template:jinja
101+{#
102+This file /etc/cloud/templates/hosts.gentoo.tmpl is only utilized
103+if enabled in cloud-config. Specifically, in order to enable it
104+you need to add the following to config:
105+ manage_etc_hosts: True
106+-#}
107+# Your system has configured 'manage_etc_hosts' as True.
108+# As a result, if you wish for changes to this file to persist
109+# then you will need to either
110+# a.) make changes to the master file in /etc/cloud/templates/hosts.gentoo.tmpl
111+# b.) change or remove the value of 'manage_etc_hosts' in
112+# /etc/cloud/cloud.cfg or cloud-config from user-data
113+#
114+# The following lines are desirable for IPv4 capable hosts
115+127.0.0.1 {{fqdn}} {{hostname}}
116+127.0.0.1 localhost.localdomain localhost
117+127.0.0.1 localhost4.localdomain4 localhost4
118+
119+# The following lines are desirable for IPv6 capable hosts
120+::1 {{fqdn}} {{hostname}}
121+::1 localhost.localdomain localhost
122+::1 localhost6.localdomain6 localhost6
123+
124diff --git a/tools/render-cloudcfg b/tools/render-cloudcfg
125index 8b7cb87..d109044 100755
126--- a/tools/render-cloudcfg
127+++ b/tools/render-cloudcfg
128@@ -4,7 +4,7 @@ import argparse
129 import os
130 import sys
131
132-VARIANTS = ["bsd", "centos", "fedora", "rhel", "suse", "ubuntu", "unknown"]
133+VARIANTS = ["bsd", "centos", "fedora", "gentoo", "rhel", "suse", "ubuntu", "unknown"]
134
135 if "avoid-pep8-E402-import-not-top-of-file":
136 _tdir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))

Subscribers

People subscribed via source and target branches