Skip to content

Commit a47596f

Browse files
author
nb
committed
feat(TOFS): ssh sshd configs known_host and banner
1 parent 14966e9 commit a47596f

File tree

12 files changed

+615
-13
lines changed

12 files changed

+615
-13
lines changed

docs/TOFS_pattern.rst

Lines changed: 443 additions & 0 deletions
Large diffs are not rendered by default.

openssh/banner.sls

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
{% from "openssh/map.jinja" import openssh with context %}
1+
{% set tplroot = tpldir.split('/')[0] %}
2+
{% from tplroot ~ "/map.jinja" import openssh with context %}
3+
{% from tplroot ~ "/libtofs.jinja" import files_switch %}
24
35
include:
46
- openssh
57
68
sshd_banner:
79
file.managed:
810
- name: {{ openssh.banner }}
9-
{% if openssh.banner_string is defined %}
11+
{% if openssh.banner_string is defined %}
1012
- contents: {{ openssh.banner_string | yaml }}
11-
{% else %}
12-
- source: {{ openssh.banner_src }}
13+
{% else %}
14+
# Preserve backward compatibility
15+
- source: {{ openssh.banner_src
16+
if '://' in openssh.banner_src
17+
else files_switch( [openssh.banner_src],
18+
'sshd_banner_file_managed'
19+
) }}
1320
- template: jinja
14-
{% endif %}
21+
{% endif %}

openssh/config.sls

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
{% from "openssh/map.jinja" import openssh, ssh_config, sshd_config with context %}
1+
{% set tplroot = tpldir.split('/')[0] %}
2+
{% from tplroot ~ "/map.jinja" import openssh, ssh_config, sshd_config with context %}
3+
{% from tplroot ~ "/libtofs.jinja" import files_switch %}
4+
25
36
include:
47
- openssh
@@ -7,7 +10,12 @@ include:
710
sshd_config:
811
file.managed:
912
- name: {{ openssh.sshd_config }}
10-
- source: {{ openssh.sshd_config_src }}
13+
# Preserve backward compatibility
14+
- source: {{ openssh.sshd_config_src
15+
if '://' in openssh.sshd_config_src
16+
else files_switch( [openssh.sshd_config_src],
17+
'sshd_config_file_managed'
18+
) }}
1119
- template: jinja
1220
- user: {{ openssh.sshd_config_user }}
1321
- group: {{ openssh.sshd_config_group }}
@@ -24,7 +32,12 @@ sshd_config:
2432
ssh_config:
2533
file.managed:
2634
- name: {{ openssh.ssh_config }}
27-
- source: {{ openssh.ssh_config_src }}
35+
# Preserve backward compatibility
36+
- source: {{ openssh.ssh_config_src
37+
if '://' in openssh.ssh_config_src
38+
else files_switch( [openssh.ssh_config_src],
39+
'ssh_config_file_managed'
40+
) }}
2841
- template: jinja
2942
- user: {{ openssh.ssh_config_user }}
3043
- group: {{ openssh.ssh_config_group }}

openssh/defaults.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ default:
33
sshd_enable: True
44
sshd_binary: /usr/sbin/sshd
55
sshd_config: /etc/ssh/sshd_config
6-
sshd_config_src: salt://openssh/files/sshd_config
6+
sshd_config_src: sshd_config # Default TOFS source filename
77
sshd_config_user: root
88
sshd_config_group: root
99
sshd_config_mode: '644'
1010
sshd_config_backup: True
1111
ssh_config: /etc/ssh/ssh_config
12-
ssh_config_src: salt://openssh/files/ssh_config
12+
ssh_config_src: ssh_config # Default TOFS source filename
1313
ssh_config_user: root
1414
ssh_config_group: root
1515
ssh_config_mode: '644'
1616
ssh_config_backup: True
1717
banner: /etc/ssh/banner
18-
banner_src: salt://openssh/files/banner
18+
banner_src: banner # Default TOFS source filename
1919
ssh_known_hosts: /etc/ssh/ssh_known_hosts
2020
dig_pkg: dnsutils
2121
ssh_moduli: /etc/ssh/moduli
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

openssh/known_hosts.sls

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{% from "openssh/map.jinja" import openssh with context %}
1+
{% set tplroot = tpldir.split('/')[0] %}
2+
{% from tplroot ~ "/map.jinja" import openssh with context %}
3+
{% from tplroot ~ "/libtofs.jinja" import files_switch %}
24
35
ensure dig is available:
46
pkg.installed:
@@ -8,7 +10,9 @@ ensure dig is available:
810
manage ssh_known_hosts file:
911
file.managed:
1012
- name: {{ openssh.ssh_known_hosts }}
11-
- source: salt://openssh/files/ssh_known_hosts
13+
- source: {{ files_switch( ['ssh_known_hosts'],
14+
'ssh_known_hosts_file_managed'
15+
) }}
1216
- template: jinja
1317
- user: root
1418
- group: {{ openssh.ssh_config_group }}

0 commit comments

Comments
 (0)