1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_sshd.git synced 2024-08-16 11:59:49 +02:00

use new ansible syntax

This commit is contained in:
L3D 2021-03-10 22:34:42 +01:00
parent 8ca50abd38
commit 1c2dc323e7
Signed by: l3d
GPG key ID: CD08445BFF4313D1
4 changed files with 24 additions and 25 deletions

View file

@ -1,7 +1,7 @@
---
- name: systemctl restart ssh
become: yes
service:
ansible.builtin.systemd:
name: "{{ sshd__service }}"
state: restarted
when: sshd__service is defined

View file

@ -3,20 +3,11 @@
ansible.builtin.include_tasks: versioncheck.yml
when: submodules_versioncheck|bool
- name: Gather the package facts
package_facts:
manager: auto
failed_when: false
- name: load sshd_service variable
ansible.builtin.include_vars: "{{ lookup('first_found', sshd__service_var_path) }}"
- name: set sshd_service variable
block:
- name: read os specific variable
include_vars: "vars/sshd_{{ ansible_distribution | lower }}.yml"
rescue:
- name: read default variable
include_vars: vars/sshd_default.yml
- include_tasks: packages.yml
- name: install packages
ansible.builtin.include_tasks: packages.yml
- name: Collect all users and groups allowed to login via ssh
set_fact:
@ -27,32 +18,33 @@
when: sshd__version_is_above_eight is not defined
block:
- name: Gather the package facts
package_facts:
ansible.builtin.package_facts:
manager: auto
- name: "get package version of {{ sshd__package }}"
debug:
ansible.builtin.debug:
msg: "{{ ansible_facts.packages[sshd__package][0].version }}"
- name: set fact sshd__version_is_above_eight
set_fact:
ansible.builtin.set_fact:
sshd__version_is_above_eight: true
when: ansible_facts.packages[sshd__package][0].version is version('8.0', '>=')
rescue:
- debug:
- ansible.builtin.debug:
msg: "Failed to detect ssh version. Set sshd__version_is_above_eight to true if you want to experience new config features from sshd version 8"
- include_tasks: keys.yml
- name: manage ssh host keys
ansible.builtin.include_tasks: keys.yml
- name: Create sshd configuration
become: yes
template:
src: sshd_config.j2
become: true
ansible.builtin.template:
src: 'templates/sshd_config.j2'
dest: '/etc/ssh/sshd_config'
owner: root
group: root
mode: 'u=rw,g=r,o=r'
validate: /usr/sbin/sshd -t -f %s
backup: yes
backup: true
notify:
- systemctl restart ssh

View file

@ -1,6 +1,6 @@
---
- name: install openssh server
become: true
package:
ansible.builtin.package:
name: "{{ sshd__package }}"
state: "{{ sshd__state }}"

View file

@ -1,3 +1,10 @@
---
playbook_version_number: 4100 # should be over ninethousand
playbook_version_number: 4101 # should be over ninethousand
playbook_version_path: 'role-sshd_chaos-bodensee_github.com.version'
sshd__service_var_path:
files:
- "sshd_{{ ansible_distribution | lower }}"
- 'sshd_default.yml'
paths:
- 'vars'