Skip to content

Instantly share code, notes, and snippets.

@bcoca
Created November 26, 2014 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcoca/b8b3a0b5251e91091038 to your computer and use it in GitHub Desktop.
Save bcoca/b8b3a0b5251e91091038 to your computer and use it in GitHub Desktop.
play.yml:
- hosts: localhost
connection: local
gather_facts: false
vars:
things:
- "{{ foo }}"
- "{{ foob }}"
foo: "Hello"
tasks:
- name: debug things
debug: var=things
- debug: var="{{ item }}"
with_items: a_list
- name: "things with_items"
template: src=templates/test.j2 dest=/tmp/{{ item.name }}.txt
with_items: things
ignore_errors: True
- name: "things with_items2"
template: src=templates/test.j2 dest=/tmp/{{ item.name }}.txt
with_items: "{{things}}"
ignore_errors: True
- name: "things direct template reference"
template: src=templates/test.j2 dest=/tmp/things.txt
results under 1.7.2:
[WARNING]: It is unnecessary to use '{{' in loops, leave variables in loop
expressions bare.
PLAY [localhost] **************************************************************
TASK: [debug things] **********************************************************
ok: [localhost] => {
"things": [
"Hello",
"{{ foob }}"
]
}
TASK: [debug var="{{ item }}"] ************************************************
ok: [localhost] => (item=a_list) => {
"a_list": "{{ a_list }}",
"item": "a_list"
}
TASK: [things with_items] *****************************************************
fatal: [localhost] => One or more undefined variables: 'unicode object' has no attribute 'name'
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/bcoca/play.retry
localhost : ok=2 changed=0 unreachable=1 failed=0
results under 1.8.0:
[WARNING]: It is unnecessary to use '{{' in loops, leave variables in loop
expressions bare.
PLAY [localhost] **************************************************************
TASK: [debug things] **********************************************************
ok: [localhost] => {
"things": [
"Hello",
"{{ foob }}"
]
}
TASK: [debug var="{{ item }}"] ************************************************
skipping: [localhost]
TASK: [things with_items] *****************************************************
skipping: [localhost]
TASK: [things with_items2] ****************************************************
fatal: [localhost] => One or more undefined variables: 'unicode object' has no attribute 'name'
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/bcoca/play.retry
localhost : ok=1 changed=0 unreachable=1 failed=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment