Ansible : Playbook - Yum Module examples

Share on :

Ansible : Playbook - Yum Module examples

EXAMPLES:
- name: install the latest version of Apache
yum:
name: httpd
state: latest

- name: remove the Apache package
yum:
name: httpd
state: absent

- name: install the latest version of Apache from the testing repo
yum:
name: httpd
enablerepo: testing
state: present

- name: install one specific version of Apache
yum:
name: httpd-2.2.29-1.4.amzn1
state: present

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

- name: upgrade all packages, excluding kernel & foo related packages
yum:
name: '*'
state: latest
exclude: kernel*,foo*

- name: install the nginx rpm from a remote repo
yum:
name: http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-
state: present

- name: install nginx rpm from a local file
yum:
name: /usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm
state: present

- name: install the 'Development tools' package group
yum:
name: "@Development tools"
state: present

- name: install the 'Gnome desktop' environment group
yum:
name: "@^gnome-desktop-environment"
state: present

- name: List ansible packages and register result to print with debug later.
yum:
list: ansible
register: result


Share on :

You may also like...

1 Response

  1. Rajani says:

    Thanks for sharing such a good blog.
    DevOps Training
    DevOps Online Training

Leave a Reply

Your email address will not be published. Required fields are marked *