mirror of
https://github.com/willshersystems/ansible-sshd
synced 2024-11-30 06:30:18 +01:00
a257ae7317
ansible_virtualization_type is undefined in Ansible > 2.5 when no virtualization is used. A jinja2 filter has been added that provides a default value (None) so that the check does not fail
40 lines
1.1 KiB
YAML
40 lines
1.1 KiB
YAML
---
|
|
- name: Set OS dependent variables
|
|
include_vars: "{{ item }}"
|
|
with_first_found:
|
|
- "{{ ansible_distribution }}_{{ ansible_distribution_major_version }}.yml"
|
|
- "{{ ansible_distribution }}.yml"
|
|
- "{{ ansible_os_family }}_{{ ansible_distribution_major_version }}.yml"
|
|
- "{{ ansible_os_family }}.yml"
|
|
- default.yml
|
|
|
|
- name: OS is supported
|
|
assert:
|
|
that: sshd_os_supported == True
|
|
|
|
- name: Install ssh packages
|
|
package:
|
|
name: "{{ item }}"
|
|
state: present
|
|
with_items: "{{ sshd_packages }}"
|
|
|
|
- name: Configuration
|
|
template:
|
|
src: sshd_config.j2
|
|
dest: "{{ sshd_config_file }}"
|
|
owner: "{{ sshd_config_owner }}"
|
|
group: "{{ sshd_config_group }}"
|
|
mode: "{{ sshd_config_mode }}"
|
|
validate: "{{ sshd_binary }} -t -f %s"
|
|
notify: reload_sshd
|
|
|
|
- name: Service enabled and running
|
|
service:
|
|
name: "{{ sshd_service }}"
|
|
enabled: true
|
|
state: started
|
|
when: "sshd_manage_service and ansible_virtualization_type|default(None) != 'docker'"
|
|
|
|
- name: Register that this role has run
|
|
set_fact: sshd_has_run=true
|
|
when: sshd_has_run is not defined
|