Saltstack Official Apt Formula
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

80 lines
2.5KB

  1. {% from "apt/map.jinja" import apt as apt_map with context %}
  2. {% set apt = pillar.get('apt', {}) %}
  3. {% set remove_sources_list = apt.get('remove_sources_list', apt_map.remove_sources_list) %}
  4. {% set clean_sources_list_d = apt.get('clean_sources_list_d', apt_map.clean_sources_list_d) %}
  5. {% set sources_list_dir = apt.get('sources_list_dir', apt_map.sources_list_dir) %}
  6. {% set repositories = apt.get('repositories', apt_map.repositories) %}
  7. {% set default_url = apt.get('default_url', apt_map.default_url) %}
  8. {% set keyring_package = apt.get('keyring_package', apt_map.default_keyring_package) %}
  9. {{ keyring_package }}:
  10. pkg.installed
  11. /etc/apt/sources.list:
  12. file.managed:
  13. - mode: '0644'
  14. - user: root
  15. - group: root
  16. {% if remove_sources_list %}
  17. - contents: ''
  18. - contents_newline: False
  19. {% else %}
  20. - replace: False
  21. {% endif %}
  22. {{ sources_list_dir }}:
  23. file.directory:
  24. - mode: '0755'
  25. - user: root
  26. - group: root
  27. - clean: {{ clean_sources_list_d }}
  28. {% for repo, args in repositories.items() %}
  29. {% set r_opts = '' %}
  30. {%- set r_arch = 'arch=' ~ args.arch|join(',') if args.arch is defined else '' %}
  31. {% if args.opts is defined %}
  32. {% if args.opts is string %}
  33. {% set r_opts = args.opts %}
  34. {% else %}
  35. {% set r_opts_list = [] %}
  36. {%- for k, v in args.opts.items() %}
  37. {% do r_opts_list.append(k ~ '=' ~ v) %}
  38. {%- endfor %}
  39. {% set r_opts = r_opts_list|join(' ') %}
  40. {% endif %}
  41. {% endif %}
  42. {% if r_arch != '' or r_opts != '' %}
  43. {% set r_options = '[' ~ r_arch ~ ' ' ~ r_opts ~ ' ]' %}
  44. {% else %}
  45. {% set r_options = '' %}
  46. {% endif %}
  47. {%- set r_url = args.url or default_url %}
  48. {%- set r_distro = args.distro or 'stable' %}
  49. {%- set r_comps = args.comps|default(['main'])|join(' ') %}
  50. {%- set r_keyserver = args.keyserver if args.keyserver is defined else apt_map.default_keyserver %}
  51. {%- for type in args.type|d(['binary']) %}
  52. {%- set r_type = 'deb-src' if type == 'source' else 'deb' %}
  53. {{ r_type }} {{ repo }}:
  54. pkgrepo.managed:
  55. - name: {{ r_type }} {{ r_options }} {{ r_url }} {{ r_distro }} {{ r_comps }}
  56. - file: {{ sources_list_dir }}/{{ repo }}-{{ type }}.list
  57. {# You can use either keyid+keyserver or key_url. If both are provided
  58. the latter will be used. #}
  59. {% if args.key_url is defined %}
  60. - key_url: {{ args.key_url }}
  61. {% elif args.keyid is defined %}
  62. - keyid: {{ args.keyid }}
  63. - keyserver: {{ r_keyserver }}
  64. {% endif %}
  65. - clean_file: true
  66. {%- endfor %}
  67. {% endfor %}