Saltstack Official Users Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.6KB

  1. # vim: sts=2 ts=2 sw=2 et ai
  2. {# import defaults.yaml as defaults #}
  3. {% import_yaml 'users/defaults.yaml' as defaults %}
  4. {# set Os-family specific settings #}
  5. {% set users = salt['grains.filter_by'](
  6. defaults,
  7. merge=salt['grains.filter_by']({
  8. 'MacOS': {
  9. 'sudoers_dir': '/etc/sudoers.d',
  10. 'sudoers_file': '/etc/sudoers',
  11. 'googleauth_dir': '/etc/google_authenticator.d',
  12. 'shell': '/bin/bash',
  13. 'visudo_shell': '/bin/bash',
  14. 'bash_package': 'bash',
  15. 'sudo_package': 'sudo',
  16. 'googleauth_package': 'google-authenticator-libpam',
  17. },
  18. 'Debian': {
  19. 'sudoers_dir': '/etc/sudoers.d',
  20. 'sudoers_file': '/etc/sudoers',
  21. 'googleauth_dir': '/etc/google_authenticator.d',
  22. 'root_group': 'root',
  23. 'shell': '/bin/bash',
  24. 'visudo_shell': '/bin/bash',
  25. 'bash_package': 'bash',
  26. 'sudo_package': 'sudo',
  27. 'googleauth_package': 'libpam-google-authenticator',
  28. 'polkit_dir': '/etc/polkit-1/localauthority.conf.d',
  29. 'polkit_defaults': 'unix-group:sudo;'
  30. },
  31. 'RedHat': {
  32. 'sudoers_dir': '/etc/sudoers.d',
  33. 'sudoers_file': '/etc/sudoers',
  34. 'googleauth_dir': '/etc/google_authenticator.d',
  35. 'root_group': 'root',
  36. 'shell': '/bin/bash',
  37. 'visudo_shell': '/bin/bash',
  38. 'bash_package': 'bash',
  39. 'sudo_package': 'sudo',
  40. 'googleauth_package': 'google-authenticator',
  41. 'polkit_dir': '/etc/polkit-1/localauthority.conf.d',
  42. 'polkit_defaults': 'unix-group:sudo;'
  43. },
  44. 'Gentoo': {
  45. 'sudoers_dir': '/etc/sudoers.d',
  46. 'sudoers_file': '/etc/sudoers',
  47. 'googleauth_dir': '/etc/google_authenticator.d',
  48. 'root_group': 'root',
  49. 'shell': '/bin/bash',
  50. 'visudo_shell': '/bin/bash',
  51. 'bash_package': 'app-shells/bash',
  52. 'sudo_package': 'app-admin/sudo',
  53. 'googleauth_package': 'libpam-google-authenticator',
  54. },
  55. 'FreeBSD': {
  56. 'sudoers_dir': '/usr/local/etc/sudoers.d',
  57. 'sudoers_file': '/usr/local/etc/sudoers',
  58. 'googleauth_dir': '/usr/local/etc/google_authenticator.d',
  59. 'root_group': 'wheel',
  60. 'shell': '/bin/csh',
  61. 'visudo_shell': '/usr/local/bin/bash',
  62. 'bash_package': 'bash',
  63. 'sudo_package': 'sudo',
  64. 'googleauth_package': 'pam_google_authenticator',
  65. },
  66. 'OpenBSD': {
  67. 'sudoers_dir': '/etc/sudoers.d',
  68. 'sudoers_file': '/etc/sudoers',
  69. 'googleauth_dir': '/etc/google_authenticator.d',
  70. 'root_group': 'wheel',
  71. 'shell': '/bin/csh',
  72. 'visudo_shell': '/usr/local/bin/bash',
  73. 'bash_package': 'bash',
  74. 'sudo_package': 'sudo',
  75. 'googleauth_package': 'pam_google_authenticator',
  76. },
  77. 'Solaris': {
  78. 'sudoers_dir': '/opt/local/etc/sudoers.d',
  79. 'sudoers_file': '/opt/local/etc/sudoers',
  80. 'googleauth_dir': '/opt/local/etc/google_authenticator.d',
  81. 'root_group': 'root',
  82. 'shell': '/bin/bash',
  83. 'visudo_shell': '/bin/bash',
  84. 'bash_package': 'bash',
  85. 'sudo_package': 'sudo',
  86. 'googleauth_package': 'libpam-google-authenticator',
  87. },
  88. 'default': {
  89. 'sudoers_dir': '/etc/sudoers.d',
  90. 'sudoers_file': '/etc/sudoers',
  91. 'googleauth_dir': '/etc/google_authenticator.d',
  92. 'root_group': 'root',
  93. 'shell': '/bin/bash',
  94. 'visudo_shell': '/bin/bash',
  95. 'bash_package': 'bash',
  96. 'sudo_package': 'sudo',
  97. 'googleauth_package': 'libpam-google-authenticator',
  98. 'polkit_dir': '/etc/polkit-1/localauthority.conf.d',
  99. 'polkit_defaults': 'unix-group:sudo;'
  100. },
  101. }, merge=salt['pillar.get']('users-formula:lookup')),
  102. base='users',
  103. ) %}
  104. {% if grains.os == 'MacOS' %}
  105. {% set group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
  106. {% do users.update({'root_group': group,
  107. 'prime_group': group}) %}
  108. {%- endif %}