[wani@linux tmp ]$ cat a.yaml
- hosts: localhost
tasks:
- lineinfile:
path: /tmp/a
regexp: "^<value1> <text1>"
state: absent
- lineinfile:
path: /tmp/a
regexp: "^<value3> <text1>"
line: "<valuex> <text1>"
[wani@linux tmp ]$ ansible-playbook a.yaml
[WARNING]: Host file not found: /etc/ansible/hosts
[WARNING]: provided hosts list is empty, only localhost is available
PLAY [localhost] ****************************************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************************************
ok: [localhost]
TASK [lineinfile] ***************************************************************************************************************************************************************************
changed: [localhost]
TASK [lineinfile] ***************************************************************************************************************************************************************************
changed: [localhost]
PLAY RECAP **********************************************************************************************************************************************************************************
localhost : ok=3 changed=2 unreachable=0 failed=0
[wani@linux tmp ]$ cat /tmp/a
<value2> <text2>
<valuex> <text1>