Skip to content

Commit e6db5fa

Browse files
committed
add sshd role
1 parent 701da11 commit e6db5fa

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

ansible/roles/sshd/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# sshd
2+
3+
Configure sshd.
4+
5+
## Role variables
6+
7+
- `sshd_password_authentication`: Optional bool. Whether to enable password login. Default `false`.

ansible/roles/sshd/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sshd_password_authentication: false # Whether to enable password login

ansible/roles/sshd/handlers/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- name: Restart sshd
2+
systemd:
3+
name: sshd
4+
state: restarted
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
- name: Configure SSH password authentication
2+
# NB: If parameters are defined multiple times the first value wins;
3+
# The default /etc/ssh/sshd_config has
4+
# Include /etc/ssh/sshd_config.d/*.conf
5+
# early on, which is generally held to be the correct approach, so adding
6+
# values to the end of that file won't work
7+
lineinfile:
8+
dest: /etc/ssh/sshd_config.d/10-ansible.conf # will beat 50-cloud-init and 50-redhat
9+
regexp: "^PasswordAuthentication"
10+
line: "PasswordAuthentication {{ 'yes' if sshd_password_authentication | bool else 'no' }}"
11+
state: present
12+
create: true
13+
validate: sshd -t -f %s
14+
notify:
15+
- Restart sshd
16+

ansible/roles/sshd/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- import_tasks: configure.yml

environments/common/layouts/everything

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,6 @@ cluster
8585

8686
[sssd]
8787
# Hosts to configure sssd on
88+
89+
[sshd]
90+
# Hosts where the OpenSSH server daemon should be configured

0 commit comments

Comments
 (0)