expected <block end>, but found '-'

4,706 views
Skip to first unread message

Bob Tanner

unread,
Sep 21, 2017, 4:03:34 PM9/21/17
to Ansible Project
I'm following this post, https://www.ibm.com/developerworks/cloud/library/cl-provision-docker-containers-ansible/index.html, and Listing 11 

---
- name: initialize provisioning
  hosts
: docker
 
 
- name: start up target container
    docker
:
      image
: python:2.7
      name
: lab
      pull
: missing
      detach
: yes
      tty
: yes
      command
: sleep infinity
      state
: started
 
# dynamically update inventory to make it available down the playbook
 
- name: register new container hostname
    add_host
: name=lab
 
- name: provision container
  connection
: docker
  hosts
: lab
  tasks
:
     
# ...
 
- name: finalize build
  hosts
: docker
  tasks
:
   
- name: stop container
      docker
:
        name
: lab
        image
: python:2.7
        state
: stopped



But ansible-playbook throws an error
ERROR! Syntax Error while loading YAML.

 
The error appears to have been in '/Users/tanner/projects/ansible.git/playbooks.git/docker-testing.yml': line 5, column 3, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - name: start up target container ^ here exception type: <class 'yaml.parser.ParserError'> exception: while parsing a block mapping in "<unicode string>", line 2, column 3: - name: initialize provisioning ^ expected <block end>, but found '-' in "<unicode string>", line 5, column 3: - name: start up target container ^
Why?

Matt Martz

unread,
Sep 21, 2017, 4:11:41 PM9/21/17
to ansible...@googlegroups.com
You seem to be missing `tasks:` in your first play.  As such YAML wasn't expecting you to start a list there.

--
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/8272e557-4555-450b-9ef0-f7d48f817441%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Bob Tanner

unread,
Sep 21, 2017, 4:41:31 PM9/21/17
to Ansible Project


On Thursday, September 21, 2017 at 3:11:41 PM UTC-5, Matt Martz wrote:
You seem to be missing `tasks:` in your first play.  As such YAML wasn't expecting you to start a list there.


So the original authors Listing 11 is wrong?

 

Matt Martz

unread,
Sep 21, 2017, 4:44:13 PM9/21/17
to ansible...@googlegroups.com
I didn't go look at the authors page.  Based on what you provided, the first play is missing `tasks:`

--
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.

For more options, visit https://groups.google.com/d/optout.

thomas okonkwo

unread,
May 21, 2020, 6:36:02 PM5/21/20
to Ansible Project

I ran into this error earlier today and i found the easiest way to fix problems like these and other indentation problem in yaml config file. 


check out www.yamllint.com


**How it works**

Open the URL and copy your yaml configuration file into the blank page and paste (of course, you can tweak your sensitive information so you don't leak them). What this does is, fix the indentations issues and point out the exact location and by how much space you need to adjust.


To read more indepth documentations about Yaml Lint, click https://yamllint.readthedocs.io/en/stable



On Thursday, September 21, 2017 at 9:44:13 PM UTC+1, Matt Martz wrote:
I didn't go look at the authors page.  Based on what you provided, the first play is missing `tasks:`
On Thu, Sep 21, 2017 at 3:41 PM, Bob Tanner <basicth...@gmail.com> wrote:


On Thursday, September 21, 2017 at 3:11:41 PM UTC-5, Matt Martz wrote:
You seem to be missing `tasks:` in your first play.  As such YAML wasn't expecting you to start a list there.


So the original authors Listing 11 is wrong?

 

--
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...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages