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.

58 lines
1.1KB

  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.enabled %}
  3. {%- if grains.os_family == 'RedHat' %}
  4. {#- update-motd is not available in RedHat, so support only static motd #}
  5. /etc/motd:
  6. file.managed:
  7. - contents_pillar: linux:system:motd
  8. {%- else %}
  9. {%- if grains.os == 'Ubuntu' %}
  10. package_update_motd:
  11. pkg.installed:
  12. - name: update-motd
  13. - require_in:
  14. - file: /etc/update-motd.d
  15. {%- endif %}
  16. /etc/update-motd.d:
  17. file.directory:
  18. - clean: true
  19. {%- if grains.oscodename == "jessie" %}
  20. motd_fix_pam_sshd:
  21. file.replace:
  22. - name: /etc/pam.d/sshd
  23. - pattern: "/run/motd.dynamic"
  24. - repl: "/run/motd"
  25. {%- endif %}
  26. /etc/motd:
  27. file.absent
  28. {%- for motd in system.motd %}
  29. {%- set motd_index = loop.index %}
  30. {%- for name, value in motd.items() %}
  31. motd_{{ motd_index }}_{{ name }}:
  32. file.managed:
  33. - name: /etc/update-motd.d/5{{ motd_index }}-{{ name }}
  34. - source: salt://linux/files/motd.sh
  35. - template: jinja
  36. - mode: 755
  37. - require:
  38. - file: /etc/update-motd.d
  39. - defaults:
  40. index: {{ motd_index }}
  41. motd_name: {{ name }}
  42. {%- endfor %}
  43. {%- endfor %}
  44. {%- endif %}
  45. {%- endif %}