Lab 023

Ansible Playbook安装基础组件

---
# ansible-playbook -l app1 base_component.yml
- name: install base componnet [0.0.1]
  hosts: all
  gather_facts: yes
  vars:
    update_all: True

  tasks:
  - name: update system
    shell: yum makecache ; yum update -y
    when: (ansible_os_family == "RedHat" and update_all == 'True')

  - name: install base component For RedHat Family
    package: name={{ item }} update_cache=no state=latest
    with_items:
     - net-tools
     - automake
     - autoconf
     - dstat
     - gcc
     - gcc-c++
     - gdb
     - make
     - nc
     - telnet
     - vim
     - tree
     - ntpdate
     - libselinux-python
     - chkconfig
     - sysstat
     - iptraf
     - openssl
     - openssl-devel
     - fail2ban
     - smem
    when: ansible_os_family == "RedHat"

  - service: name=fail2ban state=restarted