Added nsswitch configuration

This commit is contained in:
Gregory Ballantine 2017-05-23 15:17:51 -04:00
parent 52057edc8a
commit d38292e590
4 changed files with 57 additions and 0 deletions

4
nsswitch/defaults.yaml Normal file
View File

@ -0,0 +1,4 @@
nsswitch:
config_path: /etc/nsswitch.conf
config_mode: '0644'

View File

@ -0,0 +1,18 @@
{% from "nsswitch/map.jinja" import nsswitch_settings as nsswitch with context -%}
# /etc/nsswitch.conf
#
# Managed by Salt
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
{%- for key, value in nsswitch.config.iteritems() %}
{%- if value is list %}
{{ key }}: {{ v for v in value }}
{%- else %}
{{ key }}: {{ value }}
{%- endif %}
{%- endfor %}

9
nsswitch/init.sls Normal file
View File

@ -0,0 +1,9 @@
{% from "nsswitch/map.jinja" import nsswitch_settings as nsswitch with context %}
nsswitch_config:
file.managed:
- name: {{ nsswitch.config_path }}
- template: jinja
- source: salt://nsswitch/files/nsswitch.conf
- mode: {{ nsswitch.config_mode }}

26
nsswitch/map.jinja Normal file
View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja
{## Start with defaults from defaults.sls ##}
{% import_yaml 'nsswitch/defaults.yaml' as default_settings %}
{##
Setup variable using grains['os_family'] based logic, only add key:values here
that differ from whats in defaults.yaml
##}
{% set flavor_map = salt['grains.filter_by'](
{
},
grain='os_family',
merge=salt['pillar.get']('nsswitch:lookup')
) %}
{## Merge the flavor_map over the default settings ##}
{% do default_settings.nsswitch.update(flavor_map) %}
{## Merge in changes from the nsswitch:lookup pillar ##}
{% set nsswitch_settings = salt['pillar.get'](
'nsswitch',
default=default_settings.nsswitch,
merge=True
) %}