sedcommentssalt-projectsudoers

How to replace a commented line in sudoers file with sed via Salt Stack?


Hi I would like to change the following line in the /etc/sudoers file on all of my Salt minions.

# %wheel        ALL=(ALL)       NOPASSWD: ALL

With the following:

%wheel          ALL=(ALL)       NOPASSWD: /usr/bin/salt*

So far I have tried the following command along with a plethora of similar commands with slightly different options/syntax:

sed -i '/# %wheel        ALL=(ALL)       NOPASSWD: ALL/c %wheel          ALL=(ALL)       NOPASSWD: /usr/bin/salt*' /etc/sudoers

I don't get an error message from this particular command, however file is not updated.

Could anyone provide me with the correct option/syntax for my specific use?


Solution

  • $ sed -i 's|# \(.*\)ALL|\1/usr/bin/salt*|' /etc/sudoers