Search code examples
chef-infraknife

Chef: Upgrade chef-client version during knife boostrap on node


Suppose you bootstrap an Ubuntu node through your Chef Workstation via "knife bootstrap" specifying the chef-client version to install on node using the parameter "--bootstrap-version" as "12.9.41".

At the end of the bootstrap operation checking for the chef-client version on node you'll get the one specified on knife command:

[root@myhostname greg]# chef-client -v
Chef: 12.9.41

Suppose now you want to upgrade the chef-client version on your node. For example because a new cookbook on your runlist needs a newer version to work.

If you run again the bootstrap command specifying instead "--bootstrap-version 12.10.24" at the end the chef-client is still the same on node:

[root@myhostname greg]# chef-client -v
Chef: 12.9.41

On knife bootstrap command stdout you get also:

34.210.102.44 [sudo] password for greg: -----> Existing Chef installation detected
34.210.102.44 Starting the first Chef Client run...
34.210.102.44 Starting Chef Client, version 12.9.41

Is there a way to tell knife to "force" version specified on "--bootstrap-version" even if another chef-client version is installed on node?

WORKAROUND

I found another way to do it using the "--bootstrap-install-command" parameter on knife bootstrap command and specifying a bash command that goes to remove and install the target version manually:

--bootstrap-install-command "sudo apt-get remove chef -y && curl -LO https://omnitruck.chef.io/install.sh && sudo bash ./install.sh -v 12.10.24 && rm install.sh"

After the execution the chef-client version on node is the new one:

[root@myhostname greg]# chef-client -v
Chef: 12.10.24

Some details about my test case scenario:

[ChefServer]
ChefServer version: 12.3.1
chef-client version: 12.5.1
berks version: 4.0.1 

[Workstation]
SO: Ubuntu 14.04
Workstation Knife version: 12.19.36

[Node]
SO: Ubuntu 14.04

Solution

  • Not really, as the name implies bootstrap is only for the initial bootstrap and not long term maintenance. There are a number of cookbooks to aid in upgrading Chef itself on nodes but you'll have to check which are compatible with such an old version.