Yum Update all my nodes at a time

Hi,

I’m Prash, from india . I’m still new to Chef. So, let say that I have 5 nodes and I want to yum update all the nodes from the workstation, Can I do it, Is there any cookbooks to perform this process?

Thank you

Yes, there is a YUM cookbook available (a few infact). I would run the following command from the Chef-DK

knife supermarket search yum

Which will output the following data:

yum:
cookbook:             https://supermarket.chef.io/api/v1/cookbooks/yum
cookbook_description: Configures various yum components on Red Hat-like systems
cookbook_maintainer:  chef
cookbook_name:        yum
yum-centos:
cookbook:             https://supermarket.chef.io/api/v1/cookbooks/yum-centos
cookbook_description: Installs and configures the Centos Yum repositories
cookbook_maintainer:  chef
cookbook_name:        yum-centos
yum-cron:
cookbook:             https://supermarket.chef.io/api/v1/cookbooks/yum-cron
cookbook_description: Installs/Configures yum-cron
cookbook_maintainer:  osuosl
cookbook_name:        yum-cron
yum-epel:
cookbook:             https://supermarket.chef.io/api/v1/cookbooks/yum-epel
cookbook_description: Installs and configures the EPEL Yum repository
cookbook_maintainer:  chef
cookbook_name:        yum-epel
yum-fedora:
cookbook:             https://supermarket.chef.io/api/v1/cookbooks/yum-fedora
cookbook_description: Installs and configures the Fedora Yum repositories
cookbook_maintainer:  chef
cookbook_name:        yum-fedora

You can then install the cookbook using the following:

knife supermarket install <cookbook name>

…and have a play around to see if it suits your needs. If it does not, writing a custom cookbook with the following could be the simple answer you are looking for.

execute 'yum_update_upgrade' do
command 'sudo yum update && sudo yum upgrade'
end

execute(“yum_update_upgrade”) do
10.0.109.167 action [:run]
10.0.109.167 retries 0
10.0.109.167 retry_delay 2
10.0.109.167 default_guard_interpreter :execute
10.0.109.167 command "sudo yum update && sudo yum upgrade"
10.0.109.167 backup 5
10.0.109.167 returns 0
10.0.109.167 declared_type :execute
10.0.109.167 cookbook_name "yum-upate"
10.0.109.167 recipe_name "default"
10.0.109.167 end
10.0.109.167
10.0.109.167 Platform:
10.0.109.167 ---------
10.0.109.167 x86_64-linux
10.0.109.167
10.0.109.167
10.0.109.167 Running handlers:
10.0.109.167 [2017-01-13T09:33:24-05:00] ERROR: Running exception handlers
10.0.109.167 Running handlers complete
10.0.109.167 [2017-01-13T09:33:24-05:00] ERROR: Exception handlers complete
10.0.109.167 Chef Client failed. 0 resources updated in 03 seconds
10.0.109.167 [2017-01-13T09:33:24-05:00] FATAL: Stacktrace dumped to /var/chef/c ache/chef-stacktrace.out
10.0.109.167 [2017-01-13T09:33:24-05:00] FATAL: Please provide the contents of t he stacktrace.out file if you file a bug report
10.0.109.167 [2017-01-13T09:33:24-05:00] ERROR: execute[yum_update_upgrade] (yum -upate::default line 10) had an error: Mixlib::ShellOut::ShellCommandFailed: Exp ected process to exit with [0], but received '1’
10.0.109.167 ---- Begin output of sudo yum update && sudo yum upgrade ----
10.0.109.167 STDOUT:
10.0.109.167 STDERR: sudo: sorry, you must have a tty to run sudo
10.0.109.167 ---- End output of sudo yum update && sudo yum upgrade ----
10.0.109.167 Ran sudo yum update && sudo yum upgrade returned 1
10.0.109.167 [2017-01-13T09:33:24-05:00] FATAL: Chef::Exceptions::ChildConvergeE rror: Chef run process exited unsuccessfully (exit code 1)

i am getting this error when i tried to execute this command on my recipie

10.0.109.167 Dependencies Resolved
10.0.109.167
10.0.109.167 ================================================================================
10.0.109.167 Package
10.0.109.167 Arch Version Repository Size
10.0.109.167 ================================================================================
10.0.109.167 Updating:
10.0.109.167 java-1.6.0-openjdk
10.0.109.167 x86_64 1:1.6.0.41-1.13.13.1.el6_8 rhui-REGION-rhel-server-releases 42 M
10.0.109.167 java-1.6.0-openjdk-devel
10.0.109.167 x86_64 1:1.6.0.41-1.13.13.1.el6_8 rhui-REGION-rhel-server-releases 15 M
10.0.109.167
10.0.109.167 Transaction Summary
10.0.109.167 ================================================================================
10.0.109.167 Upgrade 2 Package(s)
10.0.109.167
10.0.109.167 Total download size: 56 M
10.0.109.167 Is this ok [y/N]: Exiting on user Command
10.0.109.167 Your transaction was saved, rerun it with:
10.0.109.167 yum load-transaction /tmp/yum_save_tx-2017-01-13-09-5182OM1N.yumtx
10.0.109.167 STDERR:
10.0.109.167 ---- End output of yum update && yum upgrade ----
10.0.109.167 Ran yum update && yum upgrade returned 1
10.0.109.167 [2017-01-13T09:51:50-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

i TRIED BY REMOVING SUDO IN THE COMMAND SO IT THIS ERROR CAN YOU PLEASE HELP ME IN SLOVING THIS…

Just add a -y so yum won’t try to be interactive and will assume yes to all questions. And if chef is run as root, there’s indeed no need for sudo.

Prash,

you could just use knife to accomplish this task as well:

with password and all specific platform i.e linux or whatever accepts ssh
connections:
knife ssh -x -p ‘platform:<platform_type>’ ‘sudo yum
update -y’ -C 5`

if no password is known
knife ssh -x --i ‘platform:<platform_type>’
‘sudo yum update -y’ -C 5`

can you please explain me the above commands with an example / may i know -C 5 is for?

-C is for count, how many nodes at a time you want to run this command on
simultaneously

with out bootstrapping a node with cookbook how can this be done by knife utility?