Table of Contents

Ansible Best Playbooks with Include



Ansible CLI Commands Cheet Sheat and Configuration Examples


How to execute

$ ansible-playbook web -i hosts webserver.yml
$ ansible-playbook dbs  -i hosts dbserver.yml


directory structure

ansible/
    sec-web.yml
    sec-ap.yml
    sec-db.yml
    fx-web.yml
    fx-ap.yml
    fx-db.yml
    
    hosts/
        hosts_sec
        hosts_fx
        hosts_user01

    tasks/
        centos6.yml
        centos7.yml
        ubuntu18.yml
        apache24.yml
        nginx.yml
        mysql.yml

    files/
        xxxx.rpm
        xxxx.sh
        xxxx.conf

hosts

[web]
192.168.0.101
192.168.0.102

[db]
192.168.0.100

[production:children]
web
db

sec-web.yml

- hosts: all
  sudo: yes
  tasks:
    - include: tasks/centos7.yml
    - include: tasks/nginx.yml

tasks/common-centos7.yml





Ansible CLI Commands Cheet Sheat and Configuration Examples





Ansible CLI Commands Cheet Sheat and Configuration Examples