1
0
Fork 0
mirror of synced 2024-12-22 06:31:06 -05:00

Merge pull request #20 from aboe76/pillar_lookup_map

Pillar lookup map
This commit is contained in:
Nitin Madhok 2015-01-02 04:26:13 +05:30
commit a191934544
4 changed files with 21 additions and 26 deletions

View file

@ -1,4 +1,4 @@
{% from "sudoers/package-map.jinja" import pkgs with context %}
{% from "sudoers/map.jinja" import sudoers with context %}
include:
- sudoers
@ -9,7 +9,7 @@ include:
{{ included_file }}:
file.managed:
- user: root
- group: {{ pkgs.get('group', 'root') }}
- group: {{ sudoers.get('group', 'root') }}
- mode: 440
- template: jinja
- source: salt://sudoers/files/sudoers
@ -17,5 +17,5 @@ include:
included: True
sudoers: {{ spec }}
- require:
- file: {{ pkgs.get('config-path', '/etc') }}/sudoers
- file: {{ sudoers.get('config-path', '/etc') }}/sudoers
{% endfor %}

View file

@ -1,13 +1,13 @@
{% from "sudoers/package-map.jinja" import pkgs with context %}
{% from "sudoers/map.jinja" import sudoers with context %}
sudo:
pkg.installed:
- name: {{ pkgs.sudo }}
- name: {{ sudoers.pkg }}
{{ pkgs.get('config-path', '/etc') }}/sudoers:
{{ sudoers.get('config-path', '/etc') }}/sudoers:
file.managed:
- user: root
- group: {{ pkgs.get('group', 'root') }}
- group: {{ sudoers.get('group', 'root') }}
- mode: 440
- template: jinja
- source: salt://sudoers/files/sudoers

14
sudoers/map.jinja Normal file
View file

@ -0,0 +1,14 @@
{% set sudoers = salt['grains.filter_by']({
'Debian': {'pkg': 'sudo'},
'Ubuntu': {'pkg': 'sudo'},
'CentOS': {'pkg': 'sudo'},
'Fedora': {'pkg': 'sudo'},
'RedHat': {'pkg': 'sudo'},
'Amazon': {'pkg': 'sudo'},
'Gentoo': {'pkg': 'app-admin/sudo'},
'Mint': {'pkg': 'sudo'},
'Arch': {'pkg': 'sudo'},
'FreeBSD': {'pkg': 'sudo',
'config-path': '/usr/local/etc',
'group': 'wheel'},
}, merge=salt['pillar.get']('sudoers:lookup')) %}

View file

@ -1,19 +0,0 @@
{% set package_table = {
'Debian': {'sudo': 'sudo'},
'Ubuntu': {'sudo': 'sudo'},
'CentOS': {'sudo': 'sudo'},
'Fedora': {'sudo': 'sudo'},
'RedHat': {'sudo': 'sudo'},
'Amazon': {'sudo': 'sudo'},
'Gentoo': {'sudo': 'app-admin/sudo'},
'Mint': {'sudo': 'sudo'},
'FreeBSD': {'sudo': 'sudo',
'config-path': '/usr/local/etc',
'group': 'wheel'}
} %}
{% if 'package_table' in pillar %}
{% set pkgs = pillar['package_table'] %}
{% elif grains['os'] in package_table %}
{% set pkgs = package_table[grains['os']] %}
{% endif %}