Enabling passwordless login to wheel group using Ansible

If Ansible is used in the infrastructure for automation then its necessary to enable passwordless login to the account which is being used to execute the commands on the target host. In order to do this on RHEL machine the /etc/sudoers files needs to be updated. The section which has to be updated is as shown below:

With the help Ansible it can be easily executed on the remote machine by the following set of command

- name: Enabling passwordless login on the remote host
  hosts: all
  vars:
    username: devops
  tasks:
  - name: Allow 'wheel' group to have passwordless sudo
    lineinfile:
      dest: /etc/sudoers
      state: present
      regexp: '^%wheel'
      line: '%wheel ALL=(ALL) NOPASSWD: ALL'
      validate: 'visudo -cf %s'
Share

You must be logged in to post a comment.

Proudly powered by WordPress   Premium Style Theme by www.gopiplus.com