Saltstack Official Users Formula
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

46 lines
1.6KB

  1. # vim: sts=2 ts=2 sw=2 et ai
  2. {%- from "users/map.jinja" import users with context %}
  3. {%- if not grains['os_family'] in ['RedHat', 'Suse'] %}
  4. users_googleauth-package:
  5. pkg.installed:
  6. - name: {{ users.googleauth_package }}
  7. - require:
  8. - file: {{ users.googleauth_dir }}
  9. users_{{ users.googleauth_dir }}:
  10. file.directory:
  11. - name: {{ users.googleauth_dir }}
  12. - user: root
  13. - group: {{ users.root_group }}
  14. - mode: '0600'
  15. {%- for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
  16. {%- if 'google_auth' in user %}
  17. {%- for svc in user['google_auth'] %}
  18. {%- if user.get('google_2fa', True) %}
  19. {%- set repl = '{0} {1} {2} {3} {4}{5}/{6}_{7} {8}\\n{9}'.format(
  20. 'auth',
  21. '[success=done new_authtok_reqd=done default=die]',
  22. 'pam_google_authenticator.so',
  23. 'user=root',
  24. 'secret=',
  25. users.googleauth_dir,
  26. '${USER}',
  27. svc,
  28. 'echo_verification_code',
  29. '@include common-auth',
  30. ) %}
  31. users_googleauth-pam-{{ svc }}-{{ name }}:
  32. file.replace:
  33. - name: /etc/pam.d/{{ svc }}
  34. - pattern: "^@include common-auth"
  35. - repl: "{{ repl }}"
  36. - unless: grep pam_google_authenticator.so /etc/pam.d/{{ svc }}
  37. - backup: .bak
  38. {%- endif %}
  39. {%- endfor %}
  40. {%- endif %}
  41. {%- endfor %}
  42. {%- endif %}