I tried, but it is failed.
My task is:
- name: Transfer custom error pages and restart httpd service
action: copy src={{ local_custom_error_pages_loc }}/{{ item }} dest={{
custom_error_page_dir }}/{{ item }} owner=root group=root mode=0644
with_items:
- 404_error_page
- 503_error_page
- 403_error_page
Note: 404_error_page, 503_error_page and 403_error_page are variable names
which are defined in vars.yml.
404_error_page: 404_ErrorPage.html
503_error_page: MaintenancePage.html
403_error_page: 403_ErrorPage.html
The error message is:
failed: [192.168.126.143] => (item=404_error_page) => {"failed": true,
"item": "404_error_page"}
msg: could not find
src=/home/agilairedev/playbooks/jboss_deploy_harden/repositories/custom_error_pages/
*404_error_page*
failed: [192.168.126.143] => (item=503_error_page) => {"failed": true,
"item": "503_error_page"}
msg: could not find
src=/home/agilairedev/playbooks/jboss_deploy_harden/repositories/custom_error_pages/503_error_page
failed: [192.168.126.143] => (item=403_error_page) => {"failed": true,
"item": "403_error_page"}
msg: could not find
src=/home/agilairedev/playbooks/jboss_deploy_harden/repositories/custom_error_pages/403_error_page
FATAL: all hosts have already failed -- aborting
We can see, variable 404_error_page is not replaced with its value,
404_ErrorPage.html.
If I use $foo, it works well.
with_items:
- $404_error_page
- $503_error_page
- $403_error_page
On Thursday, December 5, 2013 9:18:26 PM UTC+8, Michael DeHaan wrote:
>
> with_items:
> - bar
> - baz
>
> Is all you need now
>
> -- Michael
>
> On Dec 4, 2013, at 11:47 PM, "[email protected] <javascript:>" <
> [email protected] <javascript:>> wrote:
>
> In ansible 1.0, I can use $foo in with_items. For example,
> with_items:
> - $404_error_page
> - $503_error_page
> - $403_error_page
> Ansible 1.0 works well. It can find the variable and replace the value.
>
> In Ansible 1.4, I try to use {{ foo }} or "{{ foo }}", but both are wrong.
>
> Case1, Syntax Error.
> with_items:
> - {{ 404_error_page }}
> - {{ 503_error_page }}
> - {{ 403_error_page }}
>
> Case2, ansible would not find the variable.
> with_items:
> - "{{ 404_error_page }}"
> - "{{ 503_error_page }}"
> - "{{ 403_error_page }}"
>
> Who knows how to define with_items by variables in ansible 1.4?
>
> --
> 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] <javascript:>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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].
For more options, visit https://groups.google.com/groups/opt_out.