From 141f3c083fcbbdd348376832eb03d66cca23990b Mon Sep 17 00:00:00 2001 From: Lilian Roller Date: Tue, 17 Mar 2020 15:39:07 +0100 Subject: [PATCH] optimize sshd_service var --- tasks/main.yml | 24 ++++++++++++------------ vars/archlinux.yml | 2 +- vars/centos.yml | 2 +- vars/default.yml | 2 +- vars/fedora.yml | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index da66e83..4211bc4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,20 +1,20 @@ --- +- name: combine sshd variable + set_fact: + sshd: "{{ _sshd|combine(sshd, recursive=True) }}" + - include_tasks: versioncheck.yml when: submodules_versioncheck|bool -- name: register os-specific variables - include_vars: vars/default.yml - when: - - ansible_distribution != 'Fedora' - - ansible_distribution != 'Archlinux' - - ansible_distribution != 'CentOS' +- name: set sshd_service variable + block: + - name: read os specific variable + include_vars: "vars/{{ ansible_distribution | lower }}.yml" + rescue: + - name: read default variable + include_vars: vars/default.yml -- name: register os-specific variables - include_vars: "vars/{{ ansible_distribution | lower }}.yml" - when: - - ansible_distribution == 'Fedora' - - ansible_distribution == 'Archlinux' - - ansible_distribution == 'CentOS' +- pause: - name: Collect all users and groups allowed to login via ssh set_fact: diff --git a/vars/archlinux.yml b/vars/archlinux.yml index 164876b..a24e2b4 100644 --- a/vars/archlinux.yml +++ b/vars/archlinux.yml @@ -1,2 +1,2 @@ --- -ssh_service: sshd +sshd_service: sshd diff --git a/vars/centos.yml b/vars/centos.yml index 164876b..a24e2b4 100644 --- a/vars/centos.yml +++ b/vars/centos.yml @@ -1,2 +1,2 @@ --- -ssh_service: sshd +sshd_service: sshd diff --git a/vars/default.yml b/vars/default.yml index 199a5d8..2cb66f3 100644 --- a/vars/default.yml +++ b/vars/default.yml @@ -1,2 +1,2 @@ --- -ssh_service: ssh +sshd_service: ssh diff --git a/vars/fedora.yml b/vars/fedora.yml index 164876b..a24e2b4 100644 --- a/vars/fedora.yml +++ b/vars/fedora.yml @@ -1,2 +1,2 @@ --- -ssh_service: sshd +sshd_service: sshd