diff options
author | James Baxter <j.w.baxter@gmail.com> | 2018-12-06 18:26:32 +0000 |
---|---|---|
committer | Server Team CI Bot <josh.powers+server-team-bot@canonical.com> | 2018-12-06 18:26:32 +0000 |
commit | a4007d063f96b82545aa678ef2cb472ea3b48b1e (patch) | |
tree | 790421f5e7540b22bd646fb0f91d6274fbe51cac /cloudinit | |
parent | a582a2d2dff10b065b4711d583b3b158ee8b08ea (diff) | |
download | vyos-cloud-init-a4007d063f96b82545aa678ef2cb472ea3b48b1e.tar.gz vyos-cloud-init-a4007d063f96b82545aa678ef2cb472ea3b48b1e.zip |
write_files: add support for appending to files.
Add 'append: true' to write_files entries to append 'content' to file
specified by 'path' key. This modifies the file open mode to append.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/config/cc_write_files.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/cloudinit/config/cc_write_files.py b/cloudinit/config/cc_write_files.py index 31d1db61..0b6546e2 100644 --- a/cloudinit/config/cc_write_files.py +++ b/cloudinit/config/cc_write_files.py @@ -49,6 +49,10 @@ binary gzip data can be specified and will be decoded before being written. ... path: /bin/arch permissions: '0555' + - content: | + 15 * * * * root ship_logs + path: /etc/crontab + append: true """ import base64 @@ -113,7 +117,8 @@ def write_files(name, files): contents = extract_contents(f_info.get('content', ''), extractions) (u, g) = util.extract_usergroup(f_info.get('owner', DEFAULT_OWNER)) perms = decode_perms(f_info.get('permissions'), DEFAULT_PERMS) - util.write_file(path, contents, mode=perms) + omode = 'ab' if util.get_cfg_option_bool(f_info, 'append') else 'wb' + util.write_file(path, contents, omode=omode, mode=perms) util.chownbyname(path, u, g) |