I have a question.

Can an item inside "with_items" or "loop" be skipped? using condition "when 
some_variable is not defined" ?

Here is my play.










*- name: "Update text in the file"  lineinfile:    path: 
/path-to-the-file/    backrefs: yes    regexp: "{{ item.regexp }}"    line: 
"{{ item.line }}"  with_items:    - { regexp: '^text1', line: "text1 = {{ 
VAR1 }}", when: VAR1 is defined }      - { regexp: '^text2', line: "text2 = 
{{ VAR2 }}" }      - { regexp: '^text3', line: "text3 = {{ VAR3 }}" }*

What I'm trying to achieve is, it should replace the line only when VAR1 
value is defined, else it should skip this item and move on to 2nd item.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/35c4ae4e-6a76-488b-a4bc-2c1511332d2cn%40googlegroups.com.

Reply via email to