Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible: How can I update the system CentOS with Ansible

I am trying to update the CentOS systems with ansible. Unfortunately I am not able to do that.

I already tried:

- name: install updates   yum: update_cache=yes   when: ansible_os_family == "RedHat 

Isn't working.


- name: install updates   yum: name=* state=latest   when: ansible_os_family == "RedHat 

The last task works but is it true, that the task updates the system?

like image 849
tuCsen Avatar asked May 01 '15 12:05

tuCsen


People also ask

How do I run Ansible yum update?

The first task you're telling the system to only update the yum cache. On the second you are effectively upgrading all packages to the latest version by using state=latest but you should also use update_cache=yes on the same task to be sure you're refreshing the cache with its latest package information.

Does Ansible work on CentOS?

Ansible can interact with clients through either command line tools or through its configuration scripts called Playbooks. In this guide, you'll install Ansible on a CentOS 7 server and learn some basics of how to use the software.


1 Answers

The first task you're telling the system to only update the yum cache.

On the second you are effectively upgrading all packages to the latest version by using state=latest but you should also use update_cache=yes on the same task to be sure you're refreshing the cache with its latest package information.

The yum module documentation provides exactly this example:

- name: upgrade all packages   yum: name=* state=latest 

After the execution of the task, the terminal should display a message in yellow meaning the status of the task is changed.

like image 81
Pedro Salgado Avatar answered Oct 02 '22 16:10

Pedro Salgado