← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~t0rrant/cloud-init:1819966-sysconfig-options into cloud-init:master


Manuel Torrinha has proposed merging ~t0rrant/cloud-init:1819966-sysconfig-options into cloud-init:master.

Commit message:
Added support for arbitrary options in sysconfig

These options should be added within the `sysconfig` key, as such:

  version: 2
    NTPSERVERARGS: "minpoll 3 maxpoll 4"
    RES_OPTIONS: "rotate"

LP: #1819966
Signed-off-by: Manuel Torrinha <manuel.torrinha@xxxxxxxxxxxxxxxxxx>

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:

I do not feel comfortable with having a dummy handler for this, I guess
the purpose of the `network` key is exclusive for network interfaces and
network interface interaction. Having a handle_ function is perhaps not
the best choice.

For now this does what is intended, will eventually discuss this with the
cloud-init team and maybe this will be done in some other way.

On a final note, when running tox tests I get several errors/warnings, however:

Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
Your team cloud-init commiters is requested to review the proposed merge of ~t0rrant/cloud-init:1819966-sysconfig-options into cloud-init:master.
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index c0c415d..a15df67 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -652,6 +652,14 @@ class NetworkStateInterpreter(object):
             LOG.debug('v2(ethernets) -> v1(physical):\n%s', phy_cmd)
+    def handle_sysconfig(self, command):
+        '''
+        sysconfig:
+          NTPSERVERARGS: "minpoll 3 maxpoll 4"
+          RES_OPTIONS: "rotate"
+        '''
+        LOG.debug('[handle_sysconfig] %s', command.items())
     def handle_vlans(self, command):
         v2_vlans = {
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index be5dede..c608d68 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -724,6 +724,10 @@ class Renderer(renderer.Renderer):
             if network_state.use_ipv6:
+            if network_state.config and network_state.config['sysconfig']:
+                for opt, val in network_state.config['sysconfig'].items():
+                    netcfg.append("{}=\"{}\"".format(opt, val))
                             "\n".join(netcfg) + "\n", file_mode)

Follow ups