Saltstack Official Apt Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

92 lines
2.8KB

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