I'm using lineinfile as follows:
lineinfile dest=./hosts_exp insertafter='\[hosts1\]' line="xxxxxxxxx" state=present
My hosts_exp
is as follows:
[local]
localhost
[hosts1]
[hosts2]
[hosts3]
lineinfile inserts the text after [hosts3] instead of inserting it after [hosts1].
use:
lineinfile:
dest: "./hosts_exp"
line: "xxxxxxxxx"
insertafter: '^\[hosts1\]'
state: present
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With