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

77 lines
2.3KB

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