Skip to main content

Posts

Showing posts from November, 2017

Ansible: How installing a group of packages?

Installing a set of packages with Ansible The context I need to install a group of packages on multiple Linux servers. Ansible is the right tool for that. The host file: hosts [test_machines]    test1.my_domain.com    test2.my_domain.com [dev]    dev1.my_domain.com    dev2.my_domain.com [uat]    uat1.my_domain.com    uat2.my_domain.com [prod]    prd1.my_domain.com    prd2.my_domain.com The playbook : add_packages.yml - hosts: all   vars_files:     - data/all_my_packages.yml   tasks:   - name: Ensure a set of packages is installed.     yum:       name={{ item.name }}       state={{ item.state }}     with_items: '{{ packages }}' The datafile: data/all_my_packages.yml packages:  - { name: 'glibc.i686', state: 'present' }  - { name: 'glibc.x86_64', state: 'present' ...