From 22c8f7e106a06304c5226ea1c968467f4a73509b Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Sat, 31 May 2014 19:14:00 +0800 Subject: [PATCH 1/2] Specify package names of bash and sudo according to grains --- users/map.jinja | 6 ++++++ users/sudo.sls | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/users/map.jinja b/users/map.jinja index 1faa751..35962f6 100644 --- a/users/map.jinja +++ b/users/map.jinja @@ -5,17 +5,23 @@ 'sudoers_file': '/etc/sudoers', 'root_group': 'root', 'visudo_shell': '/bin/bash', + 'bash_package': 'bash', + 'sudo_package': 'sudo', }, 'FreeBSD': { 'sudoers_dir': '/usr/local/etc/sudoers.d/', 'sudoers_file': '/usr/local/etc/sudoers', 'root_group': 'wheel', 'visudo_shell': '/usr/local/bin/bash', + 'bash_package': 'bash', + 'sudo_package': 'sudo', }, 'default': { 'sudoers_dir': '/etc/sudoers.d/', 'sudoers_file': '/etc/sudoers', 'root_group': 'root', 'visudo_shell': '/bin/bash', + 'bash_package': 'bash', + 'sudo_package': 'sudo', }, }, merge=salt['pillar.get']('users:lookup')) %} diff --git a/users/sudo.sls b/users/sudo.sls index 459b247..5d852c9 100644 --- a/users/sudo.sls +++ b/users/sudo.sls @@ -1,19 +1,21 @@ # vim: sts=2 ts=2 sw=2 et ai {% from "users/map.jinja" import users with context %} -#Support bash in FreeBSD -bash: - pkg: - - installed +# Ensure availability of bash +bash-package: + pkg.installed: + - name: {{ users.bash_package }} -sudo: - group: - - present +sudo-group: + group.present: + - name: sudo - system: True - pkg: - - installed + +sudo-package: + pkg.installed: + - name: {{ users.sudo_package }} - require: - - group: sudo + - group: sudo-group - file: {{ users.sudoers_dir }} {{ users.sudoers_dir }}: @@ -24,7 +26,7 @@ sudoer-defaults: file.append: - name: {{ users.sudoers_file }} - require: - - pkg: sudo + - pkg: sudo-package - text: - Defaults env_reset - Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" From 6d0baa244a70914da70a89757089336b8cf576a5 Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Sat, 31 May 2014 19:15:03 +0800 Subject: [PATCH 2/2] Add Gentoo support --- users/map.jinja | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/users/map.jinja b/users/map.jinja index 35962f6..7a0c0d3 100644 --- a/users/map.jinja +++ b/users/map.jinja @@ -8,6 +8,14 @@ 'bash_package': 'bash', 'sudo_package': 'sudo', }, + 'Gentoo': { + 'sudoers_dir': '/etc/sudoers.d/', + 'sudoers_file': '/etc/sudoers', + 'root_group': 'root', + 'visudo_shell': '/bin/bash', + 'bash_package': 'app-shells/bash', + 'sudo_package': 'app-admin/sudo', + }, 'FreeBSD': { 'sudoers_dir': '/usr/local/etc/sudoers.d/', 'sudoers_file': '/usr/local/etc/sudoers',