Skip to content

Commit

Permalink
Merge pull request #666 from bshephar/sshd-server-options
Browse files Browse the repository at this point in the history
Use private variable for sshd_options
  • Loading branch information
openshift-merge-bot[bot] authored Jun 11, 2024
2 parents d10789e + b941b4a commit 75f65b4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions roles/edpm_sshd/molecule/banners/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
- name: osp.edpm.edpm_sshd
edpm_sshd_motd_enabled: true
edpm_sshd_banner_enabled: true
edpm_sshd_banner_text: "Test banner"
12 changes: 12 additions & 0 deletions roles/edpm_sshd/molecule/banners/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Verify
hosts: all
tasks:
- name: Ensure banner is set correctly
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
line: "Banner /etc/issue"
state: present
register: banner
failed_when:
- banner is changed
2 changes: 1 addition & 1 deletion roles/edpm_sshd/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

- name: Update sshd configuration options from vars
ansible.builtin.set_fact:
edpm_sshd_server_options: |-
_edpm_sshd_server_options: |-
{% set _ = edpm_sshd_server_options.__setitem__('PasswordAuthentication', edpm_sshd_password_authentication) %}
{% if edpm_sshd_banner_enabled %}
{% set _ = edpm_sshd_server_options.__setitem__('Banner', '/etc/issue') %}
Expand Down
2 changes: 1 addition & 1 deletion roles/edpm_sshd/templates/sshd_config_block.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## {{ ansible_managed }}

{% for k, v in edpm_sshd_server_options.items() %}
{% for k, v in _edpm_sshd_server_options.items() %}
{% if (v is iterable) and (v is not string) %}
{% set vars = (v | unique) %}
{% for var in vars %}
Expand Down

0 comments on commit 75f65b4

Please sign in to comment.