---- name: Install common system packages hosts: all become: yes # Equivalent to -b vars: common_packages: - net-tools - vim - tree - htop - iftop - gcc - gcc-c++ - glibc - iotop - lrzsz - sl - wget - unzip - telnet - nmap - nc - psmisc - dos2unix - bash-completion - bash-completion-extras - sysstat - rsync - nfs-utils - httpd-tools tasks: - name: Ensure EPEL is present (RHEL/CentOS) yum: name: epel-release state: present when: ansible_facts['os_family'] == 'RedHat' - name: Install common packages package: # Automatically adapts to yum / dnf / apt name: "{{ item }}" state: present loop: "{{ common_packages }}" - name: Refresh bash completion cache shell: | source /etc/profile.d/bash_completion.sh || true changed_when: false # Do not mark as changed
ansible-playbook packages.yml