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

  - name: edit /etc/sudoers replacing jbond with hkloss

Today (10/26/17), I had an “eureka” moment….. Why even bother with a playbook?

# ansible req -a "sed -i 's/bondjames//g' /etc/sudoers"

The line above removes “bondjames” entry from each line of /etc/sudoers on hosts defined in the inventory file as the group reg.

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.