# Running a playbook

**URL:** <https://forum.ansible.com/t/running-a-playbook/11753>\
**Category:** Ansible Project\
**Created:** [August 2, 2012, 6:53pm UTC](https://forum.ansible.com/t/running-a-playbook/11753 "2012-08-02T18:53:50Z")\
**Posts on this page:** 8\
**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:** [August 2, 2012, 6:53pm UTC](https://forum.ansible.com/t/running-a-playbook/11753/1 "2012-08-02T18:53:50Z")

</div>

Hi,  
ansible --version  
ansible 0.6

Am I doing this correctly? I read the docs but feel like I'm missing  
something obvious

sheepchase:playbooks jmarcus$ cat clpubkey.yml

- hosts: CL800  
user: jmarcus  
sudo: True

authorized\_key user=jmarcus key="ssh-dss  
juSJfd6l1lAl2b+HijuFSSSOFqk5SKdc8jiRVscC2sjtXVLDgL0AZD0O5y8wAAAIBd7DB68PnWcn0LREZj4Y/Nf4yY3wWCb+hsaIQdILG0Ak1r+Lq54MreW/Cz/0nAAAAB3NzaC1kc3MAAACBAP+LzrIXaw/uj14/Yn7hHsxGOlbVHPQ7aW1kApbwCWlP0MQNyjFVZEfYoC2waoClilTz4SPg5IpXh52FAAAAFQD3YN++AfX7lOvZJCjOiHa6mLU1ZlLC16yxxdX8AB+pGX27bq+hMxYwwM66tg0X3nt6bIg1b7ML8oyi3gXmQoYluqnQQU9xmo+kfdqZXbGVj2J+4L0JtQgQq7z4spz3cYzaeeZwQxz9Nnyatnoo6W6B48+1FDrvykw1wTt2tVRnlRbcjiG67EFuDzD1PAkUsbgAAAIEAkUU9FF5UZphNYThdxy+Y6tDZQhNP8g1qPWatBvNjNM+aMfiyISYga1lEpWvogAcEqvBdX58jSzW2RdIpPnVbG7e08yIg0lAAxOE+1Fziu1vc2/kRiK3mp6US26v3QfUBcdVkq0fRJNTg62jSgthaY=  
jmarcus@sheepchase.local"

ansible-playbook clpubkey.yml -K -f 1

Is it the dash?

sheepchase:playbooks jmarcus$ ansible-playbook clpubkey.yml -K -f 1  
sudo password:  
Traceback (most recent call last):  
&nbsp;&nbsp;File "/Users/jmarcus/ClusterHosts/ansible/bin/ansible-playbook",  
line 132, in \<module\>  
&nbsp;&nbsp;&nbsp;&nbsp;sys.exit(main(sys.argv[1:]))  
&nbsp;&nbsp;File "/Users/jmarcus/ClusterHosts/ansible/bin/ansible-playbook",  
line 105, in main  
&nbsp;&nbsp;&nbsp;&nbsp;only\_tags=only\_tags,  
&nbsp;&nbsp;File "/Users/jmarcus/ClusterHosts/ansible/lib/ansible/playbook/\_\_init\_\_.py",  
line 115, in \_\_init\_\_  
&nbsp;&nbsp;&nbsp;&nbsp;self.playbook = self.\_load\_playbook\_from\_file(playbook)  
&nbsp;&nbsp;File "/Users/jmarcus/ClusterHosts/ansible/lib/ansible/playbook/\_\_init\_\_.py",  
line 125, in \_load\_playbook\_from\_file  
&nbsp;&nbsp;&nbsp;&nbsp;playbook\_data = utils.parse\_yaml\_from\_file(path)  
&nbsp;&nbsp;File "/Users/jmarcus/ClusterHosts/ansible/lib/ansible/utils.py",  
line 234, in parse\_yaml\_from\_file  
&nbsp;&nbsp;&nbsp;&nbsp;return parse\_yaml(data)  
&nbsp;&nbsp;File "/Users/jmarcus/ClusterHosts/ansible/lib/ansible/utils.py",  
line 225, in parse\_yaml  
&nbsp;&nbsp;&nbsp;&nbsp;return yaml.load(data)  
&nbsp;&nbsp;File "/Library/Python/2.7/site-packages/yaml/\_\_init\_\_.py", line 71, in load  
&nbsp;&nbsp;&nbsp;&nbsp;return loader.get\_single\_data()  
&nbsp;&nbsp;File "/Library/Python/2.7/site-packages/yaml/constructor.py", line  
37, in get\_single\_data  
&nbsp;&nbsp;&nbsp;&nbsp;node = self.get\_single\_node()  
&nbsp;&nbsp;File "/Library/Python/2.7/site-packages/yaml/composer.py", line 36,  
in get\_single\_node  
&nbsp;&nbsp;&nbsp;&nbsp;document = self.compose\_document()  
&nbsp;&nbsp;File "/Library/Python/2.7/site-packages/yaml/composer.py", line 55,  
in compose\_document  
&nbsp;&nbsp;&nbsp;&nbsp;node = self.compose\_node(None, None)  
&nbsp;&nbsp;File "/Library/Python/2.7/site-packages/yaml/composer.py", line 82,  
in compose\_node  
&nbsp;&nbsp;&nbsp;&nbsp;node = self.compose\_sequence\_node(anchor)  
&nbsp;&nbsp;File "/Library/Python/2.7/site-packages/yaml/composer.py", line 110,  
in compose\_sequence\_node  
&nbsp;&nbsp;&nbsp;&nbsp;while not self.check\_event(SequenceEndEvent):  
&nbsp;&nbsp;File "/Library/Python/2.7/site-packages/yaml/parser.py", line 98, in  
check\_event  
&nbsp;&nbsp;&nbsp;&nbsp;self.current\_event = self.state()  
&nbsp;&nbsp;File "/Library/Python/2.7/site-packages/yaml/parser.py", line 393,  
in parse\_block\_sequence\_entry  
&nbsp;&nbsp;&nbsp;&nbsp;"expected \<block end\>, but found %r" % token.id, token.start\_mark)  
yaml.parser.ParserError: while parsing a block collection  
&nbsp;&nbsp;in "\<string\>", line 1, column 1:  
&nbsp;&nbsp;&nbsp;&nbsp;- hosts: CL800  
&nbsp;&nbsp;&nbsp;&nbsp;^  
expected \<block end\>, but found '?'  
&nbsp;&nbsp;in "\<string\>", line 2, column 1:  
&nbsp;&nbsp;&nbsp;&nbsp;user: jmarcus  
&nbsp;&nbsp;&nbsp;&nbsp;^

---

<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:** [August 2, 2012, 6:56pm UTC](https://forum.ansible.com/t/running-a-playbook/11753/2 "2012-08-02T18:56:44Z")

</div>

apparently you lead continued lines in YAML with a single space

I agree this kind of looks terrible and there's probably a clever way to do {{ import filename as string }} in Jinja2, which would be nicer. If someone figures that out, I'll add it to the docs.

---

<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:** [August 2, 2012, 7:25pm UTC](https://forum.ansible.com/t/running-a-playbook/11753/3 "2012-08-02T19:25:51Z")

</div>

Sorry so how do I deal with it? Do I need to put a space somewhere?

or something like

juSJfd6l1lAl2b+HijuFSSSOFqk5SKdc8jiRVscC2sjtXVLDgL0AZD0O5y8wAAAIBd7DB68PnWcn0LREZj4Y/Nf4yY3wWCb+hsaIQdILG0Ak1r+Lq54MreW/Cz/0nAAAAB3NzaC1kc3MAAACBAP+LzrIXaw/uj14/Yn7hHsxGOlbVHPQ7aW1kA  
\ pbwCWlP0MQNyjFVZEfYoC2waoClilTz4SPg5IpXh52FAAAAFQD3YN++AfX7lOvZJCjOiHa6mLU1ZlLC16yxxdX8AB+pGX27bq+hMxYwwM66tg0X3nt6bIg1b7ML8oyi3gXmQoYluqnQQU9xmo+kfdqZXbGVj2J+4L0JtQgQq7z4spz3cYzae  
\ eZwQxz9Nnyatnoo6W6B48+1FDrvykw1wTt2tVRnlRbcjiG67EFuDzD1PAkUsbgAAAIEAkUU9FF5UZphNYThdxy+Y6tDZQhNP8g1qPWatBvNjNM+aMfiyISYga1lEpWvogAcEqvBdX58jSzW2RdIpPnVbG7e08yIg0lAAxOE+1Fziu1vc2/kRiK  
\  
3mp6US26v3QfUBcdVkq0fRJNTg62jSgthaY=jmarcus@sheepchase.local  
(mailto:jmarcus@sheepchase.local

---

<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:** [August 2, 2012, 7:29pm UTC](https://forum.ansible.com/t/running-a-playbook/11753/4 "2012-08-02T19:29:26Z")

</div>

looks like Jinja2 includes are nothing more than

{% include 'path/to/file' -%}

probably easier to keep the long SSH keys out of the playbook.

disclaimer: untested

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [August 2, 2012, 7:51pm UTC](https://forum.ansible.com/t/running-a-playbook/11753/5 "2012-08-02T19:51:20Z")

</div>

James:

When I deal with public keys , I put each one on a line (gave up trying to get multiline right with yaml). They live in a list keep them in a global\_vars.yaml file so I don’t have the ugly long lines in my regular play books.

So, my global-vars.yaml has something like:

---

<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:** [August 2, 2012, 8:50pm UTC](https://forum.ansible.com/t/running-a-playbook/11753/6 "2012-08-02T20:50:53Z")

</div>

Thanks I'll give it a go

---

<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:** [August 14, 2012, 5:49pm UTC](https://forum.ansible.com/t/running-a-playbook/11753/7 "2012-08-14T17:49:44Z")

</div>

Hi,  
I'm wondering if you can expand on creating user in relation to ssh keys.

Should I do something like this or is there a more effective way to do this play

- name: Create a user for Vendor Support  
&nbsp;&nbsp;&nbsp;&nbsp;action: user name=Vendor comment="Vendor Support"  
password=encrystring createhome=yes groups=wheel  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- createusers

&nbsp;&nbsp;- name: Force password change for Vendor  
&nbsp;&nbsp;&nbsp;&nbsp;action: command /usr/bin/chage -d 0 Vendor  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- createusers

&nbsp;&nbsp;- name: Create the .ssh directory for Vendor user  
&nbsp;&nbsp;&nbsp;&nbsp;action: command mkdir .ssh chdir=/home/Vendor  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- createusers

&nbsp;&nbsp;- name: Chown the .ssh directory for Vendor user  
&nbsp;&nbsp;&nbsp;&nbsp;action: command /bin/chown Vendor:wheel /home/Vendor/.ssh  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- createusers

&nbsp;&nbsp;- name: chmod the .ssh directory for Vendor user  
&nbsp;&nbsp;&nbsp;&nbsp;action: command /bin/chmod 700 /home/Vendor/.ssh  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- createusers

&nbsp;&nbsp;- name: Copy the authorized\_keys2 file for Vendor user  
&nbsp;&nbsp;&nbsp;&nbsp;action: copy  
src=/Users/jmarcus/ServerConfig/IT/Vendor/Sites/global/files/Vendor.authorized\_keys2  
dest=/home/Vendor/.ssh/authorized\_keys2 owner=Vendor group=Vendor  
mode=0644  
&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- createusers

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:** [August 14, 2012, 6:01pm UTC](https://forum.ansible.com/t/running-a-playbook/11753/8 "2012-08-14T18:01:47Z")

</div>

you can put tags on a play and it will tag all tasks in the play.

the file module manipulates files and directories
