Hi, I am trying to create a role for multiple installations of apache on
one host.
*My group_vars:*
apache:
- { name: vhost1,
dir: installation1,
...lot of other variables...
file:
- { src: /deploy/1.txt, dst: /tmp/1.txt }
- { src: /deploy/2.txt, dst: /tmp/2.txt }
}
- { name: vhost2,
dir: installation2,
...lot of other variables...
file:
- { src: /deploy/3.txt, dst: /tmp/3.txt }
}
*Task with problem:*
- name: copy files
copy: src={{ item.file.src }} dest={{ item.file.dst }}
with_items: apache
*Error:*
ERROR: Syntax Error while loading YAML script, /roles/apache/vars/main.yml
Note: The error may actually appear before this position: line 39, column 9
file:
- { src: /deploy/1.txt, dst: /tmp/1.txt }
*I try:*
*My group_vars:*
apache:
- name: vhost1
dir: installation1
...lot of other variables...
file:
- { src: /deploy/1.txt, dst: /tmp/1.txt }
- { src: /deploy/2.txt, dst: /tmp/2.txt }
- name: vhost2
dir: installation2
...lot of other variables...
file:
- { src: /deploy/3.txt, dst: /tmp/3.txt }
*Task with problem:*
- name: copy files
copy: src={{ item.file.src }} dest={{ item.file.dst }}
with_items: apache
*Error:*
fatal: [test] => One or more undefined variables: 'list object' has no
attribute 'src'
*and also try:My group_vars*
apache:
- name: vhost1
dir: installation1
...lot of other variables...
file:
- src: /deploy/1.txt
dst: /tmp/1.txt
- src: /deploy/2.txt
dst: /tmp/2.txt
- name: vhost2
dir: installation2
...lot of other variables...
file:
- src: /deploy/3.txt
dst: /tmp/3.txt
*Task with problem:*
- name: copy files
copy: src={{ item.file.src }} dest={{ item.file.dst }}
with_items: apache
*Error:*
fatal: [test] => One or more undefined variables: 'list object' has no
attribute 'src'
How can I solve my problem? Depending on my needs, I need to have in the
variable "file" specification of one or more files to be copied.
--
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/65e29b3c-419d-400e-b01d-559958284610%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.