cmdref.net - Cheat Sheet and Example

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

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

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



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/
    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




middleware/iac/ansible/best-with-include.html.txt ยท Last modified: 2020/04/12 by admin

Page Tools