Running a playbook

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):
  File "/Users/jmarcus/ClusterHosts/ansible/bin/ansible-playbook",
line 132, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/Users/jmarcus/ClusterHosts/ansible/bin/ansible-playbook",
line 105, in main
    only_tags=only_tags,
  File "/Users/jmarcus/ClusterHosts/ansible/lib/ansible/playbook/__init__.py",
line 115, in __init__
    self.playbook = self._load_playbook_from_file(playbook)
  File "/Users/jmarcus/ClusterHosts/ansible/lib/ansible/playbook/__init__.py",
line 125, in _load_playbook_from_file
    playbook_data = utils.parse_yaml_from_file(path)
  File "/Users/jmarcus/ClusterHosts/ansible/lib/ansible/utils.py",
line 234, in parse_yaml_from_file
    return parse_yaml(data)
  File "/Users/jmarcus/ClusterHosts/ansible/lib/ansible/utils.py",
line 225, in parse_yaml
    return yaml.load(data)
  File "/Library/Python/2.7/site-packages/yaml/__init__.py", line 71, in load
    return loader.get_single_data()
  File "/Library/Python/2.7/site-packages/yaml/constructor.py", line
37, in get_single_data
    node = self.get_single_node()
  File "/Library/Python/2.7/site-packages/yaml/composer.py", line 36,
in get_single_node
    document = self.compose_document()
  File "/Library/Python/2.7/site-packages/yaml/composer.py", line 55,
in compose_document
    node = self.compose_node(None, None)
  File "/Library/Python/2.7/site-packages/yaml/composer.py", line 82,
in compose_node
    node = self.compose_sequence_node(anchor)
  File "/Library/Python/2.7/site-packages/yaml/composer.py", line 110,
in compose_sequence_node
    while not self.check_event(SequenceEndEvent):
  File "/Library/Python/2.7/site-packages/yaml/parser.py", line 98, in
check_event
    self.current_event = self.state()
  File "/Library/Python/2.7/site-packages/yaml/parser.py", line 393,
in parse_block_sequence_entry
    "expected <block end>, but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block collection
  in "<string>", line 1, column 1:
    - hosts: CL800
    ^
expected <block end>, but found '?'
  in "<string>", line 2, column 1:
    user: jmarcus
    ^

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.

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

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

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:

Thanks I'll give it a go

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
    action: user name=Vendor comment="Vendor Support"
password=encrystring createhome=yes groups=wheel
    tags:
       - createusers

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

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

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

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

  - name: Copy the authorized_keys2 file for Vendor user
    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
    tags:
       - createusers

Thanks,
James

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

the file module manipulates files and directories