title: Why have an Ansible "master playbook"?
body: <p>What is the point in having a master playbook in an Ansible project?  The Ansible <a href="http://docs.ansible.com/ansible/playbooks_best_practices.html#directory-layout" rel="nofollow">best practices</a> describe a project layout like this:</p>
  
  <pre><code>production      # inventory file for production servers
  staging         # inventory file for staging servers
  site.yml        # master playbook
  webservers.yml  # playbook for webserver tier
  dbservers.yml   # playbook for dbserver tier
  </code></pre>
  
  <p>The master playbook will look something like this:</p>
  
  <pre><code># site.yml
  ---
  - include: webservers.yml
  - include: dbservers.yml
  </code></pre>
  
  <p>The webservers and dbservers will look something like this:</p>
  
  <pre><code>---
  - name: configure webservers
    hosts: webservers
  
    tasks:
      (tasks go here)
  
    roles:
      (roles go here)
  </code></pre>
  
  <p>Normally, if you had just one inventory file, you might specify it in your ansible.cfg file:</p>
  
  <pre><code># ansible.cfg
  [defaults]
  hostfile = inventory
  </code></pre>
  
  <p>You could then simply run your playbook with the command:</p>
  
  <pre><code>$ ansible-playbook site.yml
  </code></pre>
  
  <p>But if we split our inventory into two separate files, you'll always need to specify an inventory file when you run the playbook:</p>
  
  <pre><code>$ ansible-playbook -i production site.yml
  </code></pre>
  
  <p>However, since your webserver or dbserver playbooks are in all likelihood going to specify "hosts: webservers" or "host: dbservers" to indicate these respective groups in your inventory files, why wouldn't you just run these commands?</p>
  
  <pre><code>$ ansible-playbook -i production webservers.yml
  $ ansible-playbook -i production dbservers.yml
  </code></pre>
  
  <p>What does having a site.yml master playbook buy you?</p>
  
  <p>Thanks.</p>