# reusing playbooks

**URL:** <https://forum.ansible.com/t/reusing-playbooks/12204>\
**Category:** Ansible Project\
**Created:** [January 15, 2013, 8:14pm UTC](https://forum.ansible.com/t/reusing-playbooks/12204 "2013-01-15T20:14:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [January 15, 2013, 8:14pm UTC](https://forum.ansible.com/t/reusing-playbooks/12204/1 "2013-01-15T20:14:35Z")

</div>

Hi,  
I have been checking the documentation and some of the list, for this answer.

My current layout if like this

svn/  
CitrusLeaf/  
CL200/

files/

tasks/

templates/

vars/

CL400/

files/

tasks/

templates/

vars/

StreamingCluster/

SC200/

files/

tasks/

templates/

vars/

SC400/

files/

tasks/

templates/

vars/

WebServers/

WS200/

files/

tasks/

templates/

vars/

WS400/

files/

tasks/

templates/

vars/

global/

files/

tasks/

templates/

vars/

global\_vars.yml  
hosts

Is my understanding correct?, that if I’m running a play from CitrusLeaf/CL200/tasks that I cannot call a playbook in global/tasks?

I want to keep all my user, and standard config tasks like SSH banners in the global tasks directory because those things should be consistent on all machines.

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [January 15, 2013, 8:26pm UTC](https://forum.ansible.com/t/reusing-playbooks/12204/2 "2013-01-15T20:26:04Z")

</div>

> Is my understanding correct?, that if I'm running a play from  
> CitrusLeaf/CL200/tasks that I cannot call a playbook in global/tasks?

It all assumes paths are relative to the first playbook you execute,  
so "../" and such works fine.

I generally expected to see things tagged versus executing specific  
sub playbook files by name, so you'd seldom be launching a sub  
playbook.

(Other people do though)

--Michael

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [January 15, 2013, 8:37pm UTC](https://forum.ansible.com/t/reusing-playbooks/12204/3 "2013-01-15T20:37:02Z")

</div>

All works as long as you keep paths relative

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [January 15, 2013, 10:20pm UTC](https://forum.ansible.com/t/reusing-playbooks/12204/4 "2013-01-15T22:20:34Z")

</div>

I’m not clear what is required to make this work, or if I need to use variables to deal with this issue? Do I have to use “hosts:, user:,” etc to get the NTP.yml to work?

Thanks,  
James

sheepchase:tasks jmarcus$ ansible-playbook Testing.yml -k  
SSH password:  
ERROR: parse error: playbooks must be formatted as a YAML list  
sheepchase:tasks jmarcus$ head Testing.yml

- hosts: 172.16.145.134  
user: root  
sudo: False  
gather\_facts: True
- include: NTP.yml

tasks:

### Install other preqs

sheepchase:tasks jmarcus$ head -20 Testing.yml

- hosts: 172.16.145.134  
user: root  
sudo: False  
gather\_facts: True
- include: NTP.yml

tasks:

### Install other preqs

- name: Make sure make has the lastest version installed  
action: yum name=make state=latest  
tags:

- InstallPrereqs

- name: Make sure openssl-devel the lastest version installed  
action: yum name=openssl-devel state=latest  
tags:

- InstallPrereqs

sheepchase:tasks jmarcus$ cat NTP.yml  
#- hosts: 172.16.145.134

# user: root

# sudo: False

# gather\_facts: True

tasks:

- name: Make sure NTP has the lastest version installed  
action: yum name=ntp state=latest  
tags:

- NTP

- name: Run a manual NTP udpate  
action: command /usr/sbin/ntpdate -s -b -p 8 -u [0.centos.pool.ntp.org](http://0.centos.pool.ntp.org)  
tags:

- NTP

- name: Make sure NTP is started  
action: service name=ntpd state=started  
tags:

- NTP

- name: Make sure NTP is enabled on boot  
action: service name=ntpd enabled=yes  
tags:

- NTP

- name: Make sure TIMEZONE is set  
action: command cp -f /usr/share/zoneinfo/America/New\_York /etc/localtime  
tags:

- NTP

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [January 15, 2013, 10:28pm UTC](https://forum.ansible.com/t/reusing-playbooks/12204/5 "2013-01-15T22:28:41Z")

</div>

can't really tell from email, pastebin better, but I think your yaml  
file tabbing is incorrect.

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [January 15, 2013, 10:36pm UTC](https://forum.ansible.com/t/reusing-playbooks/12204/6 "2013-01-15T22:36:28Z")

</div>

I guess my question is when calling a playbook do, in this case NTP.yml do I need any of these?

- hosts:  
user:  
sudo:  
gather\_facts:  
tasks:
