Subject: [ansible-project] double with_items and loops


On Thursday, January 25, 2018 at 12:26:40 PM UTC-7, Kai Stian Olstad wrote:

I tried the following, but it failed.  Likely some syntax issues (doesn't
like my var).  I am having a hard time finding comprehensive docs on
with_nested.  I will keep trying, but if you have some suggestions, I am
all ears.

- name: Add DNS entries to ifcfg-* files if missing
  lineinfile:
    path: "{{ net_path }}{{ item[0] }}"
    state: present
    regexp: "{{ item[1] }}"
    line: "{{ item[2] }}"
  with_nested:
    - ifcfg_list.stdout_lines
    - [ '^DNS1', '^DNS2' ]
    - [ 'DNS1={{ dns1 }}', 'DNS2={{ dns2 }}' ]

Failed message:
failed: [ansible-oel6] (item=[u'ifcfg_list.stdout_lines', u'^DNS1', u
'DNS1=10.253.1.23']) => {"changed": false, "item": [
"ifcfg_list.stdout_lines", "^DNS1", "DNS1=10.253.1.23"], "msg": "Destination
/etc/sysconfig/network-scripts/ifcfg_list.stdout_lines does not exist !",
"rc": 257}
--
To post to this group, send email to [EMAIL PROTECTED].