i would put the config in a template that you can then conditionally
include, trying to put the server configuration like this into a
variable is very error prone.

On Mon, May 25, 2015 at 2:38 PM,  <[email protected]> wrote:
> Hello, I've been using ansible for almost 3 months now, awesome tool.
> I've hit a little bump, I'm trying to make ansible variables work inside
> yaml multilines in this way:
>
> ansible 1.9.1 (detached HEAD b47d1d7e69) last updated 2015/05/25 13:25:12
> (GMT -500)
>   lib/ansible/modules/core: (detached HEAD 32e609720a) last updated
> 2015/05/25 13:25:30 (GMT -500)
>   lib/ansible/modules/extras: (detached HEAD 8dfa63d1d8) last updated
> 2015/05/25 13:25:32 (GMT -500)
>   v2/ansible/modules/core: (detached HEAD 32e609720a) last updated
> 2015/05/25 13:25:34 (GMT -500)
>   v2/ansible/modules/extras: (detached HEAD 8dfa63d1d8) last updated
> 2015/05/25 13:25:37 (GMT -500)
>
>
> # file: ./group-vars/www
>     www_port: 443
>     nginx_sites:
>       - name: www
>         servers:
>           - conf: |
>               listen {{www_port}} ssl spdy;
>               listen [::]:{{www_port}} ssl spdy;
>               location ~ \.php$ {
>                 try_files $uri =404;
>                 fastcgi_pass unix:/var/run/php5-fpm.sock;
>                 fastcgi_index index.php;
>                 fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
>                 include fastcgi_params;
>               }
>               # Prevent clients from accessing hidden files (starting with a
> dot)
>               # This is particularly important if you store .htpasswd files
> in the site hierarchy
>               location ~* (?:^|/)\. {
>                 deny all;
>               }
>               # Prevent clients from accessing to backup/config/source files
>               location ~*
> (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ {
>                 deny all;
>               }
>
> # file: ./roles/nginx/templates/site-template.j2
> # {{ansible_managed}}
> {% for server in item.servers %}
> server {
> {{ server.conf }}
> }
> {% endfor %}
>
>
> Unfortunately ansible always sends a missing quotes syntax error, and I'm
> not sure how to proceed, since enclosing the variable in double-quotes (i.e.
> "{{www_port}}") or the entire line does nothing.
> Is there a way to do so?
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/bb8e1805-2ed5-4877-bdeb-dd0b9a8b7e82%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Brian Coca

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJ5XC8kD4hsxw%3D5YeHYCq19bsWA8LuCvq3SAbtDxrnL-KgspuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to