Ansible playbook to install list of packages on Redhat or CentOS Linux post OS install.
Here i will show you a sample playbook you can use to install a list of packages in linux.
This is a sample playbook we use to install various packages after OS install.
--- - hosts: all name: NGELinux KVM post config gather_facts: yes become: yes vars: packages: - virt-install - libvirt - vmfs-tools - glibc.i686 - iptables-services - cloudstack-agent - monsoon-cloudstack-plugins-agent - qemu-img-ev - qemu-kvm-common-ev - qemu-kvm-ev - qemu-kvm-tools-ev tasks: - name: Check the kernel version is qualified fail: msg="The host is not built with the NGELinuxKVM ksmeta, please reimage and retry" failed_when: ansible_kernel != "3.10.0-863.14.8.el7.x86_64" changed_when: ansible_kernel == "3.10.0-863.14.8.el7.x86_64" tags: - kernel - name: Install additional packages for kvm yum: name="{{ packages }}" enablerepo="OL7-Optional*,nge-*" register: yum_install failed_when: yum_install.rc > 0 and "Cannot open" in yum_install.stderr changed_when: yum_install.rc == 0 tags: - packages - name: update grub config for nested hypervisor lineinfile: path=/etc/default/grub regexp='^GRUB_CMDLINE_LINUX=\"(.*(?<!kvm-intel.nested=1))\"' line='GRUB_CMDLINE_LINUX="\1 kvm-intel.nested=1"' state=present backrefs=True tags: - nestconf - name: update kvm config for nested hypervisor lineinfile: path=/etc/modprobe.d/kvm.conf regexp='#options kvm_intel nested=1' line='options kvm_intel nested=1' state=present backrefs=True tags: - nestconf
It is not tough to understand the playbook.
We have hosts: “all” to include all hosts mentioned in file, and packages mention all the list of packages we need to install, & tasks mention the list of tasks we want to do.
Please post your questions with parts you fail to understand so that i can post the answers.