Saltstack Official Users Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

32 行
1.1KB

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