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

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
Line 4: Line 4:
  
 
== Passwordless sudo using [[DevOps/Ansible|Ansible]] ==
 
== Passwordless sudo using [[DevOps/Ansible|Ansible]] ==
<pre>
 
#!/usr/bin/env ansible-playbook
 
  
- hosts: YOUR_MACHINE
+
#!/usr/bin/env ansible-playbook
  tasks:
+
    - lineinfile:
+
- hosts: YOUR_MACHINE
        path: /etc/sudoers
+
  tasks:
        state: present
+
    - lineinfile:
        regexp: '^%sudo'
+
        path: /etc/sudoers
        line: '%sudo ALL=(ALL) NOPASSWD: ALL'
+
        state: present
        validate: 'visudo -cf %s'
+
        regexp: '^%sudo'
</pre>
+
        line: '%sudo ALL=(ALL) NOPASSWD: ALL'
 +
        validate: 'visudo -cf %s'
  
  

Revision as of 08:25, 19 August 2020



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: