replace module and lineinfile are not editing the file

16 views
Skip to first unread message

chall...@gmail.com

unread,
Nov 21, 2016, 2:55:37 PM11/21/16
to Ansible Project
I want to change the value of "readahead" to 256, i have tried using both replace and lineinfile modules, both modules don't seem to work. they show the task as changed but when i log in and see the value stays the same.
#################################################################################
---
- name: configure the servers
  hosts: tag_Name_Test
  connection: local
  become: yes
  become_method: sudo
  tasks:
####
    - name: changing the readahead value
      replace:
           dest: /usr/lib/tuned/throughput-performance/tuned.conf
           regexp: "^readahead=>4096$"
           replace: "readahead=>256"
      become: yes

####
    - name: remove readahead old value
      lineinfile: dest=/usr/lib/tuned/throughput-performance/tuned.conf
                  regexp='^readahead=>4096'
                  line='readahead=>4096'
                  state=absent
      become: yes

    - name: adding readhead
      lineinfile:  dest=/usr/lib/tuned/throughput-performance/tuned.conf
                   regexp='^[disk]'
                   line='readahead=>256'
                   state=present
                   insertafter='[disk]'
                   backrefs=yes
      become: yes

#####################################################################################

Kai Stian Olstad

unread,
Nov 21, 2016, 3:20:45 PM11/21/16
to ansible...@googlegroups.com
On 21. nov. 2016 20:55, chall...@gmail.com wrote:
> I want to change the value of "*readahead" to 256*, i have tried using both
> replace and lineinfile modules, both modules don't seem to work. they show
> the task as changed but when i log in and see the value stays the same.
> #################################################################################
> ---
> - name: configure the servers
> hosts: tag_Name_Test
> connection: local

Here you say, run every task on the localhost.
If you check the machine you are running Ansible from aka Control
Machine you'll see that the files is changed there.

--
Kai Stian Olstad

chall...@gmail.com

unread,
Nov 21, 2016, 3:46:39 PM11/21/16
to Ansible Project
sorry, i meant to say the value is not being changed on target machine but ansible shows it as changed.
Reply all
Reply to author
Forward
0 new messages