Hi I am new to Ansible  and writing my first playbook

I want to update /etc/fstab 

UUID=f2550ab4-36cb-4ff0-8afa-9e7839f7ce9f           /                       
   ext4    defaults        1 1
UUID=988c830a-6d78-49f9-9db3-e8617f6dd8d0      /boot                   
 ext4    defaults        1 2
UUID=4a60645a-9009-483a-9d3e-572a9fe355b8     /data1                  ext4 
   defaults        1 2
UUID=2e7eef98-defb-4c6a-8262-799be5ddc9dd       /data2                 ext4 
   defaults        1 2
UUID=e19069ba-0ecf-4e54-8316-8ef2cc9e6758       /data3                 ext4 
   defaults         1 2
UUID=cc0fc3dd-c2f7-4d5f-9a7f-066685cc1d79         /data4                 
 ext4    defaults        1 2
UUID=7b3871c8-1e46-4e3d-94fb-946c2a559c54     /data5                   ext4 
   defaults        1 2
UUID=d5024ed8-34f3-470a-98a6-17d909c8ef84      /data6                  ext4 
   defaults        1 2
UUID=8419d6e7-cc79-4692-954a-37ba50664f3b     /srv                     
 ext4     defaults        1 2
UUID=9f80f114-1e6a-4ba3-aeb7-b72073600a97      /var                     
ext4     defaults        1 2


with 

UUID=f2550ab4-36cb-4ff0-8afa-9e7839f7ce9f           /                       
   ext4    defaults,noatime        1 1
UUID=988c830a-6d78-49f9-9db3-e8617f6dd8d0      /boot                   
 ext4    defaults,noatime        1 2
UUID=4a60645a-9009-483a-9d3e-572a9fe355b8     /data1                  ext4 
   defaults,noatime        1 2
UUID=2e7eef98-defb-4c6a-8262-799be5ddc9dd       /data2                 ext4 
   defaults,noatime        1 2
UUID=e19069ba-0ecf-4e54-8316-8ef2cc9e6758       /data3                 ext4 
   defaults,noatime        1 2
UUID=cc0fc3dd-c2f7-4d5f-9a7f-066685cc1d79         /data4                 
 ext4    defaults,noatime        1 2
UUID=7b3871c8-1e46-4e3d-94fb-946c2a559c54     /data5                   ext4 
   defaults,noatime        1 2
UUID=d5024ed8-34f3-470a-98a6-17d909c8ef84      /data6                  ext4 
   defaults,noatime        1 2
UUID=8419d6e7-cc79-4692-954a-37ba50664f3b     /srv                     
 ext4    defaults,noatime        1 2
UUID=9f80f114-1e6a-4ba3-aeb7-b72073600a97      /var                     
ext4    defaults,noatime        1 2


I was following http://docs.ansible.com/replace_module.html

so I tried 

tasks:
  - name: this is my task
    #lineinfile: dest=/etc/fstab regexp=defaults line="defaults,noatime" 
state=present backup=yes
    replace: dest=/etc/fstab regexp='(\s+)defaults        1 2(\s+.*)?$' 
replace='\1defaults,noatime        1 2\1' backup=yes

which did following 

UUID=b203e2c3-5207-41a8-8f18-795b5ec6550f /                       ext4   
 defaults        1 1
UUID=d966c414-907d-4a76-86ac-ea74922769d3 /boot                   ext4   
 defaults,noatime        1 2
UUID=92f6aef9-7701-4278-b5b3-161b595bb017 /data2                  ext4   
 defaults,noatime        1 2
UUID=4943436a-0cef-45b2-a0df-a0c236b90697 /data4                  ext4   
 defaults,noatime        1 2
UUID=db5435e6-e8f0-4646-9937-bea39e5d3470 /var                    ext4   
 defaults,noatime        1 2


what wrong am I doing here  ?
thanks

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4c904e32-81a0-47c6-b22d-0c8e90343c5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to