Problem scenario
How do you use the yum module in an Ansible playbook to install a yum package?
Solution
Prerequisites
This assumes you have installed Ansible and configured a managed node to work with it. If you need assistance with this, see this posting.
Procedures
1. On the Ansible control server, create this .yaml file (e.g., called good.yaml):
- hosts: all
tasks:
- name: Install Apache web server and nmap
yum:
name: "{{ packages }}"
vars:
packages:
- httpd
- nmap
become: yes
2. Run this: ansible-playbook good.yaml