Subject: [ansible-project] double with_items and loops


I have the following, and wish to combine them, but don't know how because
my with_items is referencing a variable.  Wondering if someone can guide me
(if possible) on how to combine these two stanzas:

- name: Add DNS1 to ifcfg-* files if missing
  lineinfile:
    path: "{{ net_path }}{{ item }}"
    state: present
    regexp: "^DNS1"
    line: "DNS1={{ dns1 }}"
  with_items: "{{ ifcfg_list.stdout_lines }}"
  ignore_errors: yes
  notify:
    - Networking

- name: Add DNS2 to ifcfg-* files if missing
  lineinfile:
    path: "{{ net_path }}{{ item }}"
    state: present
    regexp: "^DNS2"
    line: "DNS2={{ dns2 }}"
  with_items: "{{ ifcfg_list.stdout_lines }}"
  ignore_errors: yes
  notify:
    - Networking

Here is how far I get:

How do I incorporate:
"{{ ifcfg_list.stdout_lines }}"

That allows me to loop through all ifcfg-* files (except ifcfg-lo)

- name: Add DNS to ifcfg-* files if missing
  lineinfile:
    path: "{{ net_path }}{{ item.nic }}" #<--- This item is no longer
reference by ifcfg_list.stdout_lines
    state: present
    regexp: "{{ item.regexp }}"
    line: "{{ item.line }}"
  with_items:
    - {regexp: "^DNS1", line: "DNS1={{ dns1 }}", nic:
"ifcfg_list.stdout_lines"} #<--- The nic section of these looks incorrect
to me, and I doubt it would work
    - {regexp: "^DNS2", line: "DNS2={{ dns2 }}", nic:
"ifcfg_list.stdout_lines"}
  ignore_errors: yes
  notify:
    - Networking

--
To post to this group, send email to [EMAIL PROTECTED].