cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Etc


Reference














.

middleware:iac:ansible:best-with-include.html



Ansible

Ansible Best Playbooks with Include

How to execute

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


directory structure

ansible/
    test.yml
    centos7.yml
    ubuntu16.yml
    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/
        common-centos7.yml
        apache.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/common-centos7.yml
    - include: tasks/nginx.yml

tasks/common-centos7.yml




middleware/iac/ansible/best-with-include.html.txt ยท Last modified: 2017/09/13 by admin

Page Tools