1
0
Fork 0
mirror of synced 2024-12-21 05:31:09 -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: include:
- sudoers - sudoers
@ -9,7 +9,7 @@ include:
{{ included_file }}: {{ included_file }}:
file.managed: file.managed:
- user: root - user: root
- group: {{ pkgs.get('group', 'root') }} - group: {{ sudoers.get('group', 'root') }}
- mode: 440 - mode: 440
- template: jinja - template: jinja
- source: salt://sudoers/files/sudoers - source: salt://sudoers/files/sudoers
@ -17,5 +17,5 @@ include:
included: True included: True
sudoers: {{ spec }} sudoers: {{ spec }}
- require: - require:
- file: {{ pkgs.get('config-path', '/etc') }}/sudoers - file: {{ sudoers.get('config-path', '/etc') }}/sudoers
{% endfor %} {% 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: sudo:
pkg.installed: pkg.installed:
- name: {{ pkgs.sudo }} - name: {{ sudoers.pkg }}
{{ pkgs.get('config-path', '/etc') }}/sudoers: {{ sudoers.get('config-path', '/etc') }}/sudoers:
file.managed: file.managed:
- user: root - user: root
- group: {{ pkgs.get('group', 'root') }} - group: {{ sudoers.get('group', 'root') }}
- mode: 440 - mode: 440
- template: jinja - template: jinja
- source: salt://sudoers/files/sudoers - 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 %}