2016-12-27 14:03:35 +01:00
|
|
|
---
|
|
|
|
- name: verify Match Address directive
|
|
|
|
command: "grep 'Match Address' /etc/ssh/sshd_config"
|
|
|
|
changed_when: False
|
|
|
|
failed_when: False
|
2017-01-31 11:45:35 +01:00
|
|
|
#check_mode: no (for migration to Ansible 2.2)
|
|
|
|
always_run: yes
|
2016-12-27 14:03:35 +01:00
|
|
|
register: grep_matchaddress_ssh
|
|
|
|
|
|
|
|
- name: Add Match Address sshd directive
|
|
|
|
lineinfile:
|
|
|
|
dest: /etc/ssh/sshd_config
|
|
|
|
line: "\nMatch Address {{ evolinux_ssh_password_auth_addresses | join(',') }}\n PasswordAuthentication yes"
|
|
|
|
validate: '/usr/sbin/sshd -T -f %s'
|
2017-01-03 11:44:20 +01:00
|
|
|
notify: reload sshd
|
2017-01-03 16:37:23 +01:00
|
|
|
when: evolinux_ssh_match_address and grep_matchaddress_ssh.rc != 0 and evolinux_ssh_password_auth_addresses != []
|
2016-12-27 14:03:35 +01:00
|
|
|
|
|
|
|
- name: Modify Match Address sshd directive
|
|
|
|
replace:
|
|
|
|
dest: /etc/ssh/sshd_config
|
|
|
|
regexp: '^(Match Address ((?!{{ item }}).)*)$'
|
|
|
|
replace: '\1,{{ item }}'
|
|
|
|
validate: '/usr/sbin/sshd -T -f %s'
|
|
|
|
with_items: "{{ evolinux_ssh_password_auth_addresses }}"
|
2017-01-03 11:44:20 +01:00
|
|
|
notify: reload sshd
|
2017-01-03 16:37:23 +01:00
|
|
|
when: evolinux_ssh_match_address and grep_matchaddress_ssh.rc == 0
|
2016-12-27 14:03:35 +01:00
|
|
|
|
|
|
|
- name: disable SSH access for root
|
|
|
|
replace:
|
|
|
|
dest: /etc/ssh/sshd_config
|
|
|
|
regexp: '^PermitRootLogin (yes|without-password)'
|
|
|
|
replace: "PermitRootLogin no"
|
|
|
|
when: evolinux_ssh_disable_root
|
|
|
|
|
|
|
|
- name: disable AcceptEnv in ssh config
|
|
|
|
replace:
|
|
|
|
dest: /etc/ssh/sshd_config
|
|
|
|
regexp: '^AcceptEnv'
|
|
|
|
replace: "#AcceptEnv"
|
2017-01-03 16:37:23 +01:00
|
|
|
when: evolinux_ssh_disable_acceptenv
|
2017-01-03 17:02:23 +01:00
|
|
|
|
|
|
|
- meta: flush_handlers
|