← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~papodaca/cloud-init:chef_omnibus_version into cloud-init:master


Ethan Apodaca has proposed merging ~papodaca/cloud-init:chef_omnibus_version into cloud-init:master.

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

For more details, see:

Add option to pin chef omnibus install version

Most users of chef will want to pin the version that is installed.
Typically new versions of chef have to be evaluated for breakage etc.

This change proposes a new optional `omnibus_version` field to the
chef configuration. This changes also adds an reference to the new
field to the chef example. 

LP: #1462693
Your team cloud-init commiters is requested to review the proposed merge of ~papodaca/cloud-init:chef_omnibus_version into cloud-init:master.
diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py
index 02c70b1..5f63c20 100644
--- a/cloudinit/config/cc_chef.py
+++ b/cloudinit/config/cc_chef.py
@@ -302,12 +302,16 @@ def install_chef(cloud, chef_cfg, log):
         retries = max(0, util.get_cfg_option_int(chef_cfg,
+        version = util.get_cfg_option_str(chef_cfg, "omnibus_version", none)
         content = url_helper.readurl(url=url, retries=retries).contents
         with util.tempdir() as tmpd:
             # Use tmpdir over tmpfile to avoid 'text file busy' on execute
             tmpf = "%s/chef-omnibus-install" % tmpd
             util.write_file(tmpf, content, mode=0o700)
-            util.subp([tmpf], capture=False)
+            params = [tmpf]
+            if version:
+                params += ["-v", version]
+            util.subp(params, capture=False)
         log.warn("Unknown chef install type '%s'", install_type)
         run = False
diff --git a/doc/examples/cloud-config-chef.txt b/doc/examples/cloud-config-chef.txt
index 9d23581..ce76b5d 100644
--- a/doc/examples/cloud-config-chef.txt
+++ b/doc/examples/cloud-config-chef.txt
@@ -94,6 +94,10 @@ chef:
  # if install_type is 'omnibus', change the url to download
  omnibus_url: "https://www.chef.io/chef/install.sh";
+ # if install_type is 'omnibus', pinned version can passed
+ # to the instal script
+ omnibus_version: "12.3.0"
 # Capture all subprocess output into a logfile
 # Useful for troubleshooting cloud-init issues

Follow ups