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

8 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 %}