Difference between revisions of "Enable passwordless sudo for a specific user"

From wikieduonline
Jump to navigation Jump to search
Line 9: Line 9:
 
  - hosts: YOUR_MACHINE
 
  - hosts: YOUR_MACHINE
 
   tasks:
 
   tasks:
     - lineinfile:
+
     - [[lineinfile]]:
 
         path: [[/etc/sudoers]]
 
         path: [[/etc/sudoers]]
 
         state: present
 
         state: present

Revision as of 03:20, 16 August 2021



Passwordless sudo using Ansible

#!/usr/bin/env ansible-playbook

- hosts: YOUR_MACHINE
  tasks:
    - lineinfile:
        path: /etc/sudoers
        state: present
        regexp: '^%sudo'
        line: '%sudo ALL=(ALL) NOPASSWD: ALL'
        validate: 'visudo -cf %s'

Activities

See also

Advertising: