Answer the question
In order to leave comments, you need to log in
How does the lineinfile Ansible module work?
Greetings.
I'm trying to add a line to the network interface config using Ansible.
Ansible version: 2.7.2
Config:
# The contents below are automatically generated by Vagrant. Do not modify.
NM_CONTROLLED=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=10.22.33.123
NETMASK=255.255.255.0
DEVICE=eth1
PEERDNS=no
#VAGRANT-END
- name: Configure Internal zone interface
lineinfile:
path: /etc/sysconfig/network-scripts/ifcfg-{{ interface }}
regexp: '^ZONE'
line: 'ZONE="internal"'
notify: "restart network"
become: true
^ZONE=
should be substituted .
At the same time, during some runs on a fresh machine, it substitutes not just ZONE= . For some it works.
Already tried:ZONE="internal"
insertbefore: BOF
Answer the question
In order to leave comments, you need to log in
The problem turned out not to be from Ansible at all.
The zone is being rubbed either by a firewall, or by NetworkManager, after restarting the network, and semi-randomly
I did not find any solutions, except to remove NM from the system.
Well, turn on debugging after minus three V and minus diff, why guess on coffee grounds
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question