Saltstack Official Linux 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.

101 lines
2.3KB

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