exception: mapping values are not allowed in this context

1,199 views
Skip to first unread message

John Harmon

unread,
Mar 21, 2018, 11:53:34 AM3/21/18
to Ansible Project
I have the following playbook.  If I comment out the line for import_playbook, the error goes away.  Can anybody see what is wrong with this?  I am guessing a syntax error, but I can't seem to find it.  Thanks in advance!:

---
- hosts: "{{ host }}"
  gather_facts
: false
  tasks
:

- import_playbook: update_gitlab_scripts.yml

   
- name: "Check tcp tuning settings"
      shell
: "/home/gomer/scripts/check_tcp_tuning.sh"
      no_log
: true
     
register: results

   
- fail:
        msg
: "TCP Tuning needed for {{ ansible_hostname }}"
     
when: results.rc > 0

ERROR:
ERROR! Syntax Error while loading YAML.


The error appears to have been in '/etc/ansible/playbooks/checks/check_tcp_tuning.yml': line 8, column 11, but may
be elsewhere
in the file depending on the exact syntax problem.

The offending line appears to be:


   
- name: "Check tcp tuning settings"
         
^ here

exception type
: <class 'yaml.scanner.ScannerError'>
exception
: mapping values are not allowed in this context
 
in "<unicode string>", line 8, column 11


Matt Martz

unread,
Mar 21, 2018, 12:01:18 PM3/21/18
to ansible...@googlegroups.com
`import_playbook` cannot be used within a play.  Your play starts with `- hosts: "{{ host }}"`.  Your `import_playbook` would need to come either before that, or after your `fail` task.

Maybe you are looking for `import_tasks` instead?

--
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/c958ac69-cc85-4308-a941-5bacb4cb101d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

John Harmon

unread,
Mar 21, 2018, 12:03:59 PM3/21/18
to Ansible Project
Matt, thank you.  I wasn't aware of import_tasks, but it does what I want it to do.  Thanks again!
Reply all
Reply to author
Forward
0 new messages