Saltstack Official Apt Formula
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

8 anos atrás
8 anos atrás
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 %}