Code review comment for ~t0rrant/cloud-init:1819966-sysconfig-options

Revision history for this message
Ryan Harper (raharper) wrote :

The best way to update the /etc/sysconfig/network contents with custom values is via the write_files in append mode.

A more robust solution would be to implement a config module: cc_sysconfig.py which could read in existing files from /etc/sysconfig, parse them with util.load_shell_content() which returns a dict of key=values; and let users provide new key/value:

sysconfig:
   network:
       mode: append # <update|append|overwrite>
       content:
  NTPSERVERARGS: "minpoll 3 maxpoll 3"
  RES_OPTION: "rotate"

Append mode would merely append the KEY=VALUE pairs from the content dictionary in the file specified (/etc/sysconfig/network).

Update would replace the existing KEY with the new value, if KEY wasn't present, it would append it.

overwrite would allow writing a completely new file with the KEY/VALUE pairs provided.

Some challenges include retaining existing comments, indicating where cloud-init made changes within the file, handling interactions from cloudinit.net whose's renderers currently update/write values.

« Back to merge proposal