Add openssh role

This commit is contained in:
Ryan Cavicchioni 2019-03-13 01:48:49 -05:00
parent 4aa5cd77a7
commit 3900e5c4d0
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
7 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,9 @@
---
openssh_package_name: 'openssh-server'
openssh_package_state: 'present'
openssh_service_name: 'sshd'
openssh_service_state: 'started'
openssh_service_enabled: true
openssh_sshd_config: {}

View File

@ -0,0 +1,6 @@
---
- name: reload openssh
service:
name: "{{ openssh_service_name }}"
state: reloaded
when: openssh_service_enabled

View File

@ -0,0 +1,24 @@
---
- name: gather OS specific variables
include_vars: "{{ item }} "
with_first_found:
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- name: install openssh
package:
name: "{{ openssh_package_name }}"
state: "{{ openssh_package_state }}"
- name: configure openssh
template:
src: sshd_config.j2
dest: /etc/ssh/sshd_config
validate: sshd -t -f %s
notify:
- reload openssh
- name: start openssh
service:
name: "{{ openssh_service_name }}"
state: "{{ openssh_service_state }}"
enabled: "{{ openssh_service_enabled }}"

View File

@ -0,0 +1,16 @@
# {{ ansible_managed }}
{% set sshd_config = openssh_default_sshd_config | combine(openssh_sshd_config) %}
{% for k, v in sshd_config | dictsort %}
{% if v is sameas true %}
{{ k }} {{ v }}
{% elif v is sameas false %}
{{ k }} {{ v }}
{% elif v is string or v is number %}
{{ k }} {{ v }}
{% else %}
{% for vi in v %}
{{ k }} {{ vi }}
{% endfor %}
{% endif %}
{% endfor %}

View File

@ -0,0 +1 @@
---

View File

@ -0,0 +1 @@
---

View File

@ -0,0 +1,9 @@
---
openssh_default_sshd_config:
PasswordAuthentication: 'no'
ChallengeResponseAuthentication: 'no'
UsePAM: 'yes'
X11Forwarding: 'yes'
PrintMotd: 'no'
AcceptEnv: LANG LC_*
Subsystem: 'sftp /usr/lib/openssh/sftp-server'