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

93 lines
2.7KB

  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. {{ r_type }} {{ repo }}:
  55. pkgrepo.managed:
  56. - name: {{ r_type }} {{ r_options }} {{ r_url }} {{ r_distro }} {{ r_comps }}
  57. - file: {{ sources_list_dir }}/{{ repo }}-{{ type }}.list
  58. {# You can use either keyid+keyserver or key_url. If both are provided
  59. the latter will be used. #}
  60. {% if args.key_url is defined %}
  61. - key_url: {{ args.key_url }}
  62. {% elif args.key_text is defined %}
  63. - key_text: {{ args.key_text }}
  64. {% elif args.keyid is defined %}
  65. - keyid: {{ args.keyid }}
  66. - keyserver: {{ r_keyserver }}
  67. {% endif %}
  68. - clean_file: true
  69. - refresh: False
  70. - refresh_db: False
  71. - onchanges_in:
  72. - module: apt.refresh_db
  73. {%- endfor %}
  74. {% endfor %}
  75. {% if repositories %}
  76. apt.refresh_db:
  77. module.run:
  78. - name: pkg.refresh_db
  79. {% endif %}