Skip to content

Commit 193ff7e

Browse files
authored
Merge pull request #164 from sticky-note/feat/tofs
feat(TOFS): ssh sshd configs known_host and banner
2 parents 14966e9 + f6dbca3 commit 193ff7e

File tree

12 files changed

+613
-18
lines changed

12 files changed

+613
-18
lines changed

docs/TOFS_pattern.rst

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

openssh/banner.sls

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
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 using the `if` below #}
15+
- source: {{ openssh.banner_src if '://' in openssh.banner_src
16+
else files_switch( [openssh.banner_src],
17+
'sshd_banner'
18+
) }}
1319
- template: jinja
14-
{% endif %}
20+
{%- endif %}

openssh/config.sls

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
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
58
6-
{% if sshd_config %}
9+
{%- if sshd_config %}
710
sshd_config:
811
file.managed:
912
- name: {{ openssh.sshd_config }}
10-
- source: {{ openssh.sshd_config_src }}
13+
{#- Preserve backward compatibility using the `if` below #}
14+
- source: {{ openssh.sshd_config_src if '://' in openssh.sshd_config_src
15+
else files_switch( [openssh.sshd_config_src],
16+
'sshd_config'
17+
) }}
1118
- template: jinja
1219
- user: {{ openssh.sshd_config_user }}
1320
- group: {{ openssh.sshd_config_group }}
@@ -18,21 +25,25 @@ sshd_config:
1825
{%- endif %}
1926
- watch_in:
2027
- service: {{ openssh.service }}
21-
{% endif %}
28+
{%- endif %}
2229
23-
{% if ssh_config %}
30+
{%- if ssh_config %}
2431
ssh_config:
2532
file.managed:
2633
- name: {{ openssh.ssh_config }}
27-
- source: {{ openssh.ssh_config_src }}
34+
{#- Preserve backward compatibility using the `if` below #}
35+
- source: {{ openssh.ssh_config_src if '://' in openssh.ssh_config_src
36+
else files_switch( [openssh.ssh_config_src],
37+
'ssh_config'
38+
) }}
2839
- template: jinja
2940
- user: {{ openssh.ssh_config_user }}
3041
- group: {{ openssh.ssh_config_group }}
3142
- mode: {{ openssh.ssh_config_mode }}
3243
{%- if openssh.ssh_config_backup %}
3344
- backup: minion
3445
{%- endif %}
35-
{% endif %}
46+
{%- endif %}
3647
3748
{%- for keyType in openssh['host_key_algos'].split(',') %}
3849
{%- set keyFile = "/etc/ssh/ssh_host_" ~ keyType ~ "_key" %}
@@ -121,4 +132,4 @@ ssh_host_{{ keyType }}_key.pub:
121132
- file: sshd_config
122133
- watch_in:
123134
- service: {{ openssh.service }}
124-
{% endif %}
135+
{%- endif %}

openssh/defaults.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ 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
20+
ssh_known_hosts_src: ssh_known_hosts # Default TOFS source filename
2021
dig_pkg: dnsutils
2122
ssh_moduli: /etc/ssh/moduli
2223
root_group: root
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( [openssh.ssh_known_hosts_src],
14+
'manage ssh_known_hosts file'
15+
) }}
1216
- template: jinja
1317
- user: root
1418
- group: {{ openssh.ssh_config_group }}

0 commit comments

Comments
 (0)