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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. {%- from "linux/map.jinja" import auth with context %}
  2. {%- if auth.enabled %}
  3. {%- if auth.get('ldap', {}).get('enabled', False) %}
  4. {%- from "linux/map.jinja" import ldap with context %}
  5. {%- if grains.os_family == 'Debian' %}
  6. linux_auth_ldap_debconf_package:
  7. pkg.installed:
  8. - pkgs: [ 'debconf-utils' ]
  9. linux_auth_debconf_libnss-ldapd:
  10. debconf.set:
  11. - name: libnss-ldapd
  12. - data:
  13. libnss-ldapd/nsswitch:
  14. type: 'multiselect'
  15. value: 'group, passwd, shadow'
  16. libnss-ldapd/clean_nsswitch:
  17. type: 'boolean'
  18. value: 'false'
  19. - require_in:
  20. - pkg: linux_auth_ldap_packages
  21. - require:
  22. - pkg: linux_auth_ldap_debconf_package
  23. linux_auth_debconf_libpam-ldapd:
  24. debconf.set:
  25. - name: libpam-ldapd
  26. - data:
  27. libpam-ldapd/enable_shadow:
  28. type: 'boolean'
  29. value: 'true'
  30. {#- Setup mkhomedir and ldap PAM profiles #}
  31. linux_auth_mkhomedir_config:
  32. file.managed:
  33. - name: /usr/share/pam-configs/mkhomedir
  34. - source: salt://linux/files/mkhomedir
  35. - require:
  36. - pkg: linux_auth_ldap_packages
  37. linux_auth_pam_add_profile:
  38. file.managed:
  39. - name: /usr/local/bin/pam-add-profile
  40. - source: salt://linux/files/pam-add-profile
  41. - mode: 755
  42. linux_auth_pam_add_profiles:
  43. cmd.run:
  44. - name: /usr/local/bin/pam-add-profile ldap mkhomedir
  45. - unless: "debconf-get-selections | grep libpam-runtime/profiles | grep mkhomedir | grep ldap"
  46. - watch:
  47. - file: linux_auth_mkhomedir_config
  48. - require:
  49. - file: linux_auth_pam_add_profile
  50. - pkg: linux_auth_ldap_packages
  51. {%- elif grains.os_family == 'RedHat' %}
  52. linux_auth_config:
  53. cmd.run:
  54. - name: "authconfig --enableldap --enableldapauth --enablemkhomedir --update"
  55. - require:
  56. - pkg: linux_auth_ldap_packages
  57. {%- else %}
  58. linux_auth_nsswitch_config_file:
  59. file.managed:
  60. - name: /etc/nsswitch.conf
  61. - source: salt://linux/files/nsswitch.conf
  62. - template: jinja
  63. - mode: 644
  64. - require:
  65. - pkg: linux_auth_ldap_packages
  66. - watch_in:
  67. - service: linux_auth_nslcd_service
  68. {%- endif %}
  69. linux_auth_ldap_packages:
  70. pkg.installed:
  71. - pkgs: {{ ldap.pkgs }}
  72. linux_auth_nslcd_config_file:
  73. file.managed:
  74. - name: /etc/nslcd.conf
  75. - source: salt://linux/files/nslcd.conf
  76. - template: jinja
  77. - mode: 600
  78. - require:
  79. - pkg: linux_auth_ldap_packages
  80. - watch_in:
  81. - service: linux_auth_nslcd_service
  82. linux_auth_nslcd_service:
  83. service.running:
  84. - enable: true
  85. - name: nslcd
  86. {%- endif %}
  87. {%- endif %}