ansible ssh passwd auth disable

---
- hosts: localhost
  tasks:
  - lineinfile:
      path: /etc/selinux/config
      regexp: '^SELINUX='
      line: 'SELINUX=enforcing'
  - name: Ensure the default Apache port is 8080
    lineinfile:
      path: /etc/httpd/conf/httpd.conf
      regexp: '^Listen '
      insertafter: '^#Listen '
      line: Listen 80
  - name: disable passwd auth for ssh
    lineinfile:
      path: /etc/sudoers
      regexp: '^PasswordAuthentication '
      insertafter: '^#PasswordAuthentication '
      line: PasswordAuthentication no


[root@localhost ~]# ansible-playbook hosts.yml

PLAY [localhost] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [lineinfile] **************************************************************
ok: [localhost]

TASK [Ensure the default Apache port is 8080] **********************************
ok: [localhost]

TASK [disable passwd auth for ssh] *********************************************
changed: [localhost]

PLAY RECAP *********************************************************************
localhost                  : ok=4    changed=1    unreachable=0    failed=0 

[root@localhost ~]# cat /etc/sudoers | grep PasswordAuthentication
PasswordAuthentication no
[root@localhost ~]#

Comments