2018-03-07 03:28:23 +01:00
|
|
|
---
|
2019-05-15 11:44:17 +02:00
|
|
|
- include_tasks: versioncheck.yml
|
2019-05-17 12:50:48 +02:00
|
|
|
when: submodules_versioncheck|bool
|
2018-11-16 11:44:36 +01:00
|
|
|
|
|
|
|
- name: register os-specific variables
|
|
|
|
include_vars: default.yml
|
2019-05-15 16:25:13 +02:00
|
|
|
when:
|
2019-02-20 11:54:02 +01:00
|
|
|
- ansible_distribution != 'Fedora'
|
|
|
|
- ansible_distribution != 'Archlinux'
|
2018-11-16 11:44:36 +01:00
|
|
|
|
|
|
|
- name: register os-specific variables
|
|
|
|
include_vars: "{{ ansible_distribution }}.yml"
|
2019-05-15 16:25:13 +02:00
|
|
|
when:
|
2019-02-20 11:54:02 +01:00
|
|
|
- ansible_distribution == 'Fedora'
|
|
|
|
- ansible_distribution == 'Archlinux'
|
2018-11-16 11:44:36 +01:00
|
|
|
|
2018-03-16 04:54:02 +01:00
|
|
|
- name: Collect all users and groups allowed to login via ssh
|
|
|
|
set_fact:
|
2019-03-27 14:23:41 +01:00
|
|
|
sshd_allow_users: '{{ sshd_default_allowed_users + users.keys() | default({}) | sort }}'
|
2019-03-27 15:16:55 +01:00
|
|
|
sshd_allow_groups: '{{ sshd_default_allowed_groups + users.keys() | default({}) | sort }}'
|
2018-03-16 04:54:02 +01:00
|
|
|
|
2018-03-07 03:28:23 +01:00
|
|
|
- name: Copy sshd configuration
|
2019-03-06 10:06:08 +01:00
|
|
|
become: yes
|
2018-03-07 03:28:23 +01:00
|
|
|
template:
|
2019-04-09 22:13:59 +02:00
|
|
|
src: sshd_config.j2
|
2018-03-07 03:28:23 +01:00
|
|
|
dest: '/etc/ssh/sshd_config'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 'u=rw,g=r,o=r'
|
|
|
|
validate: /usr/sbin/sshd -t -f %s
|
2018-03-08 18:48:33 +01:00
|
|
|
notify:
|
|
|
|
- restart ssh
|
|
|
|
|
2019-04-09 22:03:00 +02:00
|
|
|
- name: Generate new ecdsa ssh host key pair if necessary
|
|
|
|
become: yes
|
|
|
|
command: ssh-keygen -t ecdsa -f 'ssh_host_ecdsa_key' -P '' -q
|
|
|
|
args:
|
|
|
|
chdir: '/etc/ssh/'
|
|
|
|
creates: 'ssh_host_ecdsa_key.pub'
|
|
|
|
notify:
|
|
|
|
- restart ssh
|
2019-05-17 11:13:42 +02:00
|
|
|
when: generate_ecdsa_too|bool
|
2018-03-08 18:48:33 +01:00
|
|
|
|
|
|
|
- name: Generate new ed25519 ssh host key pair if necessary
|
2019-03-06 10:06:08 +01:00
|
|
|
become: yes
|
2018-03-08 18:48:33 +01:00
|
|
|
command: ssh-keygen -t ed25519 -f 'ssh_host_ed25519_key' -P '' -q
|
|
|
|
args:
|
|
|
|
chdir: '/etc/ssh/'
|
|
|
|
creates: 'ssh_host_ed25519_key.pub'
|
|
|
|
notify:
|
|
|
|
- restart ssh
|
2018-03-07 03:28:23 +01:00
|
|
|
|
2019-04-09 22:03:00 +02:00
|
|
|
- name: Remove unwanted host keys
|
|
|
|
become: yes
|
|
|
|
file:
|
|
|
|
path: '/etc/ssh/ssh_host_{{ item }}_key'
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- rsa
|
|
|
|
- dsa
|
|
|
|
notify:
|
|
|
|
- restart ssh
|
2019-05-20 15:31:00 +02:00
|
|
|
when: generate_ecdsa_too|bool
|
2019-04-09 22:03:00 +02:00
|
|
|
|
2018-03-07 03:28:23 +01:00
|
|
|
- name: Remove unwanted host keys
|
2019-03-06 10:06:08 +01:00
|
|
|
become: yes
|
2018-03-07 03:28:23 +01:00
|
|
|
file:
|
|
|
|
path: '/etc/ssh/ssh_host_{{ item }}_key'
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- ecdsa
|
|
|
|
- rsa
|
|
|
|
- dsa
|
2018-03-08 18:48:33 +01:00
|
|
|
notify:
|
|
|
|
- restart ssh
|
2019-05-20 15:31:00 +02:00
|
|
|
when: not generate_ecdsa_too|bool
|
2019-01-08 14:12:27 +01:00
|
|
|
|
2019-05-15 13:31:20 +02:00
|
|
|
- name: make sure the correct keys are available
|
|
|
|
file:
|
2018-03-07 03:28:23 +01:00
|
|
|
path: '/etc/ssh/ssh_host_{{ item }}_key.pub'
|
|
|
|
state: absent
|
2019-03-06 10:06:08 +01:00
|
|
|
become: yes
|
2018-03-07 03:28:23 +01:00
|
|
|
with_items:
|
|
|
|
- ecdsa
|
|
|
|
- rsa
|
|
|
|
- dsa
|
2018-03-08 18:48:33 +01:00
|
|
|
notify:
|
|
|
|
- restart ssh
|
2019-05-17 11:13:42 +02:00
|
|
|
when: not generate_ecdsa_too|bool
|
2018-11-16 11:44:36 +01:00
|
|
|
|
2019-05-15 13:31:20 +02:00
|
|
|
- name: make sure the correct keys are available except ecdsa
|
|
|
|
file:
|
2019-04-09 22:03:00 +02:00
|
|
|
path: '/etc/ssh/ssh_host_{{ item }}_key.pub'
|
|
|
|
state: absent
|
|
|
|
become: yes
|
|
|
|
with_items:
|
|
|
|
- rsa
|
|
|
|
- dsa
|
|
|
|
notify:
|
|
|
|
- restart ssh
|
2019-05-17 11:13:42 +02:00
|
|
|
when: generate_ecdsa_too|bool
|