Conditional upon variable

247 views
Skip to first unread message

John Oliver

unread,
Jul 28, 2014, 6:32:35 PM7/28/14
to ansible...@googlegroups.com
I tried to:

    command: /usr/sbin/setsebool -P httpd_can_network_connect_db 1
    when: "{{rc_db_host}}" = "localhost"

Ansible exploded in rage.  I've never sent his much red text, even from python errors :-)  I tried with quotes, without, '=', '=='...   It looks like there's duplication in the error message, too:

ERROR: Syntax Error while loading YAML script, roundcube.yml
Note: The error may actually appear before this position: line 129, column 28

    command: /usr/sbin/setsebool -P httpd_can_network_connect_db 1
    when: "{{rc_db_host}}" == "localhost"
                                         ^
We could be wrong, but this one looks like it might be an issue with 
unbalanced quotes.  If starting a value with a quote, make sure the 
line ends with the same set of quotes.  For instance this arbitrary 
example:

    foo: "bad" "wolf"

Could be written as:

    foo: '"bad" "wolf"'


We could be wrong, but this one looks like it might be an issue with
missing quotes.  Always quote template expression brackets when they 
start a value. For instance:            

    with_items:
      - {{ foo }}

Should be written as:

    with_items:
      - "{{ foo }}"      


We could be wrong, but this one looks like it might be an issue with 
unbalanced quotes.  If starting a value with a quote, make sure the 
line ends with the same set of quotes.  For instance this arbitrary 
example:

    foo: "bad" "wolf"

Could be written as:

    foo: '"bad" "wolf"'


Michael Peters

unread,
Jul 28, 2014, 6:36:39 PM7/28/14
to ansible...@googlegroups.com
Try something like this:

command: /usr/sbin/setsebool -P httpd_can_network_connect_db 1
when: rc_db_host == "localhost"

You don't need to use templating in the when clauses.
> --
> 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-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/20545b8b-b76d-4dec-8fc9-94cb4c9930fa%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

John Oliver

unread,
Jul 28, 2014, 6:45:15 PM7/28/14
to ansible...@googlegroups.com
Thanks!!!
Reply all
Reply to author
Forward
0 new messages