Skip to content

Commit 329ef01

Browse files
authored
Use Block in file
Try and match format of Rocky 9
1 parent cb833b1 commit 329ef01

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ansible/roles/sshd/tasks/configure.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
- name: Grab facts to determine distribution
2+
setup:
3+
14
- name: Ensure drop in directory exists
25
file:
36
path: /etc/ssh/sshd_config.d/*.conf
@@ -8,16 +11,19 @@
811
become: true
912

1013
- name: Ensure drop in directory is included
11-
lineinfile:
14+
blockinfile:
1215
dest: /etc/ssh/sshd_config
13-
regexp: "^Include /etc/ssh/sshd_config.d/*.conf"
14-
line: "Include /etc/ssh/sshd_config.d/*.conf"
16+
content: |
17+
# To modify the system-wide sshd configuration, create a *.conf file under
18+
# /etc/ssh/sshd_config.d/ which will be automatically included below
19+
Include /etc/ssh/sshd_config.d/*.conf
1520
state: present
16-
insertbefore: "BOF"
21+
insertafter: "# default value."
1722
validate: sshd -t -f %s
1823
notify:
1924
- Restart sshd
2025
become: true
26+
when: ansible_facts.distribution_major_version == '8'
2127

2228
- name: Template sshd configuration
2329
# NB: If parameters are defined multiple times the first value wins;

0 commit comments

Comments
 (0)