Hi ,
I have a file :
cat test.txt
Baseline: ABC ABC1 ABC23 ABC24 +ABC33 ABC_PAD +ABC_PAD_CAD
Now i want to add +TEST_ABC at the end of Line :
Desired O/P :
Baseline: ABC ABC1 ABC23 ABC24 +ABC33 ABC_PAD +ABC_PAD_CAD +TEST_ABC
I am using lineinfile module but the string is getting added after the
line
Desired O/P :
Baseline: ABC ABC1 ABC23 ABC24 +ABC33 ABC_PAD +ABC_PAD_CAD +TEST_ABC
Actual O/P:
Desired O/P :
Baseline: ABC ABC1 ABC23 ABC24 +ABC33 ABC_PAD +ABC_PAD_CAD
+TEST_ABC
Below is the task
---
- hosts: localhost
vars:
file_location: /home/raka/test.txt
gather_facts: False
tasks:
- name: Update file
lineinfile:
path: "{{ file_location }}"
state: present
backup: yes
insertafter: '(\s+Baseline: .*)(/>)$'
line: "{{ add_name }}"
Now on executing the playbook as
ansible-playbook file-update.yml -e "add_name=+TEST_ABC"
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/0b6322db-2a1a-4eed-bf0b-2cc67371f170%40googlegroups.com.