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.

63 lines
1.6KB

  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.enabled %}
  3. linux_packages:
  4. pkg.installed:
  5. - pkgs: {{ system.pkgs }}
  6. {%- set pkgs_groups = {
  7. 'latest': [],
  8. 'purged': [],
  9. 'removed': [],
  10. 'installed': [],
  11. } %}
  12. {%- for name, package in system.package.iteritems() %}
  13. {%- if package.repo is defined or package.hold is defined or package.verify is defined %}
  14. linux_extra_package_{{ name }}:
  15. {%- if package.version is defined %}
  16. {%- if package.version == 'latest' %}
  17. pkg.latest:
  18. {%- elif package.version == 'purged' %}
  19. pkg.purged:
  20. {%- elif package.version == 'removed' %}
  21. pkg.removed:
  22. {%- else %}
  23. pkg.installed:
  24. - version: {{ package.version }}
  25. {%- endif %}
  26. {%- else %}
  27. pkg.installed:
  28. {%- endif %}
  29. - name: {{ name }}
  30. {%- if package.repo is defined %}
  31. - fromrepo: {{ package.repo }}
  32. {%- endif %}
  33. {%- if package.hold is defined %}
  34. - hold: {{ package.hold }}
  35. {%- endif %}
  36. {%- if package.verify is defined %}
  37. - skip_verify: {{ true if package.verify else false }}
  38. {%- endif %}
  39. {%- else %}
  40. {%- if package.version is not defined %}
  41. {%- do pkgs_groups['installed'].append(name) %}
  42. {%- elif package.version in ('latest', 'purged', 'removed') %}
  43. {%- do pkgs_groups[package.version].append(name) %}
  44. {%- else %}
  45. {%- do pkgs_groups['installed'].append({name: package.version}) %}
  46. {%- endif %}
  47. {%- endif %}
  48. {%- endfor %}
  49. {%- for pkgs_group, pkgs in pkgs_groups.iteritems() %}
  50. {%- if pkgs %}
  51. linux_extra_packages_{{ pkgs_group }}:
  52. pkg.{{ pkgs_group }}:
  53. - pkgs: {{ pkgs }}
  54. {%- endif %}
  55. {%- endfor %}
  56. {%- endif %}