fix(sshd.yml): standardize variable names for SSHD configuration facts and improve clarity

This commit is contained in:
2026-07-29 18:08:17 +02:00
parent b5a4edc181
commit fc9c1548c3
+13 -11
View File
@@ -5,7 +5,7 @@
- name: (sshd.yml) Set fact_sshd_pubkey_accepted_algorithms (comma separated list) - name: (sshd.yml) Set fact_sshd_pubkey_accepted_algorithms (comma separated list)
ansible.builtin.set_fact: ansible.builtin.set_fact:
fact_sshd_pubkey_accepted_algorithms: "{{ sshd_pubkey_accepted_algorithms | join(',') }}" common_fact_sshd_pubkey_accepted_algorithms: "{{ sshd_pubkey_accepted_algorithms | join(',') }}"
when: when:
- sshd_pubkey_accepted_algorithms is defined and sshd_pubkey_accepted_algorithms | length > 0 - sshd_pubkey_accepted_algorithms is defined and sshd_pubkey_accepted_algorithms | length > 0
tags: tags:
@@ -13,7 +13,7 @@
- name: (sshd.yml) Set fact_sshd_kexalgorithms (comma separated list) - name: (sshd.yml) Set fact_sshd_kexalgorithms (comma separated list)
ansible.builtin.set_fact: ansible.builtin.set_fact:
fact_sshd_kexalgorithms: "{{ sshd_kexalgorithms | join(',') }}" common_fact_sshd_kexalgorithms: "{{ sshd_kexalgorithms | join(',') }}"
when: when:
- sshd_kexalgorithms is defined and sshd_kexalgorithms | length > 0 - sshd_kexalgorithms is defined and sshd_kexalgorithms | length > 0
tags: tags:
@@ -21,7 +21,7 @@
- name: (sshd.yml) Set fact_sshd_ciphers (comma separated list) - name: (sshd.yml) Set fact_sshd_ciphers (comma separated list)
ansible.builtin.set_fact: ansible.builtin.set_fact:
fact_sshd_ciphers: "{{ sshd_ciphers | join(',') }}" common_fact_sshd_ciphers: "{{ sshd_ciphers | join(',') }}"
when: when:
- sshd_ciphers is defined and sshd_ciphers | length > 0 - sshd_ciphers is defined and sshd_ciphers | length > 0
tags: tags:
@@ -29,7 +29,7 @@
- name: (sshd.yml) Set fact_sshd_macs - name: (sshd.yml) Set fact_sshd_macs
ansible.builtin.set_fact: ansible.builtin.set_fact:
fact_sshd_macs: "{{ sshd_macs | join(',') }}" common_fact_sshd_macs: "{{ sshd_macs | join(',') }}"
when: when:
- sshd_macs is defined and sshd_macs | length > 0 - sshd_macs is defined and sshd_macs | length > 0
tags: tags:
@@ -37,7 +37,7 @@
- name: (sshd.yml) Set fact_sshd_hostkeyalgorithms (blank separated list) - name: (sshd.yml) Set fact_sshd_hostkeyalgorithms (blank separated list)
ansible.builtin.set_fact: ansible.builtin.set_fact:
fact_sshd_hostkeyalgorithms: "{{ sshd_hostkeyalgorithms | join(',') }}" common_fact_sshd_hostkeyalgorithms: "{{ sshd_hostkeyalgorithms | join(',') }}"
when: when:
- sshd_hostkeyalgorithms is defined and sshd_hostkeyalgorithms | length > 0 - sshd_hostkeyalgorithms is defined and sshd_hostkeyalgorithms | length > 0
tags: tags:
@@ -45,7 +45,7 @@
- name: (sshd.yml) Set fact_sshd_allowed_users (blank separated list) - name: (sshd.yml) Set fact_sshd_allowed_users (blank separated list)
ansible.builtin.set_fact: ansible.builtin.set_fact:
fact_sshd_allowed_users: "{{ sshd_allowed_users | join(' ') }}" common_fact_sshd_allowed_users: "{{ sshd_allowed_users | join(' ') }}"
when: when:
- sshd_allowed_users is defined and sshd_allowed_users | length > 0 - sshd_allowed_users is defined and sshd_allowed_users | length > 0
tags: tags:
@@ -58,13 +58,15 @@
- name: (sshd.yml) Check file '/etc/ssh/sshd_config.ORIG' exists - name: (sshd.yml) Check file '/etc/ssh/sshd_config.ORIG' exists
ansible.builtin.stat: ansible.builtin.stat:
path: /etc/ssh/sshd_config.ORIG path: /etc/ssh/sshd_config.ORIG
register: etc_sshd_sshd_config_ORIG register: common_etc_sshd_sshd_config_orig
tags: tags:
- sshd-config - sshd-config
- name: (sshd.yml) Backup installation version of file '/etc/ssh/sshd_config' - name: (sshd.yml) Backup installation version of file '/etc/ssh/sshd_config'
ansible.builtin.command: cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.ORIG ansible.builtin.command:
when: etc_sshd_sshd_config_ORIG.stat.exists == False cmd: cp -a /etc/ssh/sshd_config /etc/ssh/sshd_config.ORIG
creates: /etc/ssh/sshd_config.ORIG
when: common_etc_sshd_sshd_config_orig.stat.exists
tags: tags:
- sshd-config - sshd-config
@@ -76,7 +78,7 @@
group: root group: root
mode: "0644" mode: "0644"
validate: "sshd -f %s -T" validate: "sshd -f %s -T"
#backup: yes # backup: yes
notify: "Restart ssh" notify: "Restart ssh"
when: when:
- ansible_facts['distribution'] == "Ubuntu" - ansible_facts['distribution'] == "Ubuntu"
@@ -122,7 +124,7 @@
state: absent state: absent
check_mode: true check_mode: true
changed_when: false changed_when: false
register: sshd_config_sftp register: common_sshd_config_sftp
tags: tags:
- sshd-config - sshd-config