`
- name: read network
hosts: localhost
vars:
CUSTOMER: "{{ CUST | default("me") }}"
list: " {{ lookup('file', 'networks').split('n')[0] }} "
gway: " {{ list.split(' ')[2] }} "
netw: " {{ list.split(' ')[1] }} "
tasks:
- name: test1
lineinfile:
path: 'networks'
state: absent
** regexp: "{{netw}}"**
- debug:
var: gway
- debug:
var: netw
The variable netw printed in output correct: my networks file has networks and gateways example:
172.16.25.0/29 172.16.25.1
but not delete the line from file.
if i write this hard coded it’s working: regexp: “172.16.25.1”