Skip to content


edit file in place with Ansible

Over the years I have learned to use perl, vi and sed to “edit files in place”. This post how to do it with the latest toy – Ansible.
The task at hand – make a copy of /etc/sudoers, replace every occurrence of jbond with hkloss.

The Playbook:

---
- hosts: localhost

  tasks:
  - name: edit /etc/sudoers replacing jbond with hkloss
    replace:
     dest=/etc/sudoers
     regexp='jbond'
     replace='hkloss'
     backup=yes

Posted in LINUX.

Tagged with , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

WordPress Anti Spam by WP-SpamShield



Copyright © 2016 - 2017 Waldemar Mark Duszyk. All Rights Reserved. Created by Blog Copyright.