Skip to content

Commit db67ce6

Browse files
authored
Merge pull request #186 from baby-gnu/feature/v4-map.jinja
feat(map): update to v4 and add config.get lookup from multiple roots
2 parents a8cd737 + a0af21a commit db67ce6

39 files changed

Lines changed: 494 additions & 121 deletions

openssh/_mapdata/init.sls

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,16 @@
33
---
44
{#- Get the `tplroot` from `tpldir` #}
55
{%- set tplroot = tpldir.split('/')[0] %}
6-
{%- from tplroot ~ "/map.jinja" import openssh with context %}
7-
{%- from tplroot ~ "/map.jinja" import ssh_config with context %}
8-
{%- from tplroot ~ "/map.jinja" import sshd_config with context %}
6+
{%- from tplroot ~ "/map.jinja" import mapdata with context %}
97
108
{%- set output_file = '/tmp/salt_mapdata_dump.yaml' %}
11-
{%- set map = {
12-
'openssh': openssh,
13-
'ssh_config': ssh_config,
14-
'sshd_config': sshd_config,
15-
} %}
169
17-
{%- do salt['log.debug']( map | yaml(False) ) %}
10+
{%- do salt['log.debug']( mapdata | yaml(False) ) %}
1811
1912
{{ tplroot }}-mapdata-dump:
2013
file.managed:
2114
- name: {{ output_file }}
2215
- source: salt://{{ tplroot }}/_mapdata/_mapdata.jinja
2316
- template: jinja
2417
- context:
25-
map: {{ map | yaml }}
18+
map: {{ mapdata | yaml }}

openssh/auth.sls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929

3030
include:
3131
- openssh
32-
{%- from "openssh/map.jinja" import openssh, sshd_config with context -%}
32+
{%- from "openssh/map.jinja" import mapdata with context -%}
33+
{%- set openssh = mapdata.openssh %}
34+
{%- set sshd_config = mapdata.sshd_config %}
35+
3336
{%- set auth = openssh.get('auth', {}) -%}
3437
{%- for identifier,keys in auth.items() -%}
3538
{%- for key in keys -%}

openssh/auth_map.sls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
include:
22
- openssh
33

4-
{% from "openssh/map.jinja" import openssh, sshd_config with context -%}
4+
{% from "openssh/map.jinja" import mapdata with context -%}
5+
{%- set openssh = mapdata.openssh %}
6+
{%- set sshd_config = mapdata.sshd_config %}
57
{%- set authorized_keys_file = sshd_config.get("AuthorizedKeysFile", None) %}
68
79
{%- for store, config in openssh.get("auth_map", {}).items() %}

openssh/banner.sls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{%- set tplroot = tpldir.split('/')[0] %}
2-
{%- from tplroot ~ "/map.jinja" import openssh with context %}
2+
{%- from tplroot ~ "/map.jinja" import mapdata with context %}
33
{%- from tplroot ~ "/libtofs.jinja" import files_switch %}
4+
{%- set openssh = mapdata.openssh %}
45
56
include:
67
- openssh

openssh/client.sls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{% from "openssh/map.jinja" import openssh with context %}
1+
{% from "openssh/map.jinja" import mapdata with context %}
2+
{%- set openssh = mapdata.openssh %}
23
34
openssh_client:
45
pkg.installed:

openssh/config.sls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{%- set tplroot = tpldir.split('/')[0] %}
2-
{%- from tplroot ~ "/map.jinja" import openssh, ssh_config, sshd_config with context %}
2+
{%- from tplroot ~ "/map.jinja" import mapdata with context %}
33
{%- from tplroot ~ "/libtofs.jinja" import files_switch %}
4+
{%- set openssh = mapdata.openssh %}
5+
{%- set sshd_config = mapdata.sshd_config %}
6+
{%- set ssh_config = mapdata.ssh_config %}
47
58
69
include:

openssh/config_ini.sls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{%- from "openssh/map.jinja" import openssh, sshd_config with context %}
1+
{%- from "openssh/map.jinja" import mapdata with context %}
2+
{%- set openssh = mapdata.openssh %}
3+
{%- set sshd_config = mapdata.sshd_config %}
24
35
include:
46
- openssh

openssh/init.sls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{% from "openssh/map.jinja" import openssh with context %}
1+
{% from "openssh/map.jinja" import mapdata with context %}
2+
{%- set openssh = mapdata.openssh %}
23
34
openssh:
45
{% if openssh.server is defined %}

openssh/known_hosts.sls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{%- set tplroot = tpldir.split('/')[0] %}
2-
{%- from tplroot ~ "/map.jinja" import openssh with context %}
2+
{%- from tplroot ~ "/map.jinja" import mapdata with context %}
33
{%- from tplroot ~ "/libtofs.jinja" import files_switch %}
4+
{%- set openssh = mapdata.openssh %}
45
56
ensure dig is available:
67
pkg.installed:

openssh/libsaltcli.jinja

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=jinja
3+
4+
{#- Get the relevant values from the `opts` dict #}
5+
{%- set opts_cli = opts.get('__cli', '') %}
6+
{%- set opts_masteropts_cli = opts | traverse('__master_opts__:__cli', '') %}
7+
8+
{#- Determine the type of salt command being run #}
9+
{%- if opts_cli == 'salt-minion' %}
10+
{%- set cli = 'minion' %}
11+
{%- elif opts_cli == 'salt-call' %}
12+
{%- set cli = 'ssh' if opts_masteropts_cli in ('salt-ssh', 'salt-master') else 'local' %}
13+
{%- else %}
14+
{%- set cli = 'unknown' %}
15+
{%- endif %}
16+
{%- do salt['log.debug']('[libsaltcli] the salt command type has been identified to be: ' ~ cli) %}

0 commit comments

Comments
 (0)