ansible-sshd/tasks/main.yml
Sergey Korolev 6d0d043bab Don't fail without package manager
Atomic Host uses unsupported package manager `rpm-ostree`. So, `ansible_pkg_mgr` is `unknown` and this task will fail. `sshd` is already in base system images. Apart from this, sshd configuration is standard for Fedora/CentOS.

I'm not sure it's the right solution. May be it's better to create new boolean variable like `sshd_manage_install` and use it here in `when`.
2016-12-22 16:48:27 +03:00

63 lines
1.3 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
tags:
- sshd
- name: OS is supported
assert:
that: sshd_os_supported == True
tags:
- sshd
- name: Installed
action: >
{{ ansible_pkg_mgr }}
name="{{ item }}"
state=installed
with_items: "{{ sshd_packages }}"
when: ansible_pkg_mgr != 'unknown'
tags:
- sshd
- name: Run directory
file:
path: /var/run/sshd
state: directory
mode: 0755
when: sshd_manage_var_run
tags:
- sshd
- 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
tags:
- sshd
- name: Service enabled and running
service:
name: "{{ sshd_service }}"
enabled: true
state: running
when: sshd_manage_service
tags:
- sshd
- name: Register that this role has run
set_fact: sshd_has_run=true
when: sshd_has_run is not defined
tags:
- sshd