I cannot get out of the gates with Ansible

570 views
Skip to first unread message

Julian Brown

unread,
Oct 19, 2017, 8:50:40 AM10/19/17
to Ansible Project
- I cannot get any playbook to work
- I am trying to use Ansible to configure cloud VM's for me.
- Macbook Pro is my central system

Here is my first playbook:

Julians-Macbook-Pro:deploy_with_ansible julianbrown$ cat deploy_julian_bin.yml
---
- hosts: all
remote_user: root

tasks:
- name: deploy bin git repo
  git:
    repo: XXXXXXXXXXXXXXXXXXXXXXXXXX [ removed for privacy reasons ]
    dest: /root/bin
    version: master


So I am trying to follow playbooks and use them.

/etc/ansible/hosts

[all]
testing.tld

Julians-Macbook-Pro:deploy_with_ansible julianbrown$ ansible --version
ansible 2.4.0.0
  config file = /Users/julianbrown/ansible_deploy/deploy_with_ansible/ansible.cfg
  configured module search path = [u'/Users/julianbrown/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.4.0.0/libexec/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.14 (default, Sep 25 2017, 09:53:22) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]

I get a syntax error, yet that is exactly the structure of most playbooks I have seen.

Julians-Macbook-Pro:deploy_with_ansible julianbrown$ ansible-playbook deploy_julian_bin.yml
ERROR! Syntax Error while loading YAML.


The error appears to have been in '/Users/julianbrown/ansible_deploy/deploy_with_ansible/deploy_julian_bin.yml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- hosts: all
remote_user: root
^ here

exception type: <class 'yaml.parser.ParserError'>
exception: while parsing a block collection
  in "<unicode string>", line 2, column 1
did not find expected '-' indicator
  in "<unicode string>", line 3, column 1


What am I doing wrong?

Thanx

Julian

Toshio Kuratomi

unread,
Oct 19, 2017, 9:06:52 AM10/19/17
to ansible...@googlegroups.com
Indentation :-)

Add two spaces in front of the remote_user to get past this particular problem.

-toshio

Thanx

Julian

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/28f82479-2eee-4461-a9d2-f9a54fe225eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Coca

unread,
Oct 19, 2017, 9:47:19 AM10/19/17
to Ansible Project
Ansible uses YAML as the playbook format, which means
spaces/indentation is significant, make sure your playbook looks like
this:

---
- hosts: all
remote_user: root
tasks:
- name: deploy bin git repo
git:
repo: XXXXXXXXXXXXXXXXXXXXXXXXXX [ removed for privacy reasons ]
dest: /root/bin
version: master



----------
Brian Coca

Julian Brown

unread,
Oct 19, 2017, 10:21:54 AM10/19/17
to Ansible Project
Thank you that worked

Thanx

Julian
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages