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

repo.sls 6.0KB

9 lat temu
9 lat temu
7 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
7 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
9 lat temu
7 lat temu
9 lat temu
9 lat temu
9 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.enabled %}
  3. linux_repo_prereq_pkgs:
  4. pkg.installed:
  5. - pkgs: {{ system.pkgs }}
  6. # global proxy setup
  7. {%- if system.proxy.get('pkg', {}).get('enabled', False) %}
  8. {%- if grains.os_family == 'Debian' %}
  9. /etc/apt/apt.conf.d/99proxies-salt:
  10. file.managed:
  11. - template: jinja
  12. - source: salt://linux/files/apt.conf.d_proxies
  13. - defaults:
  14. external_host: False
  15. https: {{ system.proxy.get('pkg', {}).get('https', None) | default(system.proxy.get('https', None), true) }}
  16. http: {{ system.proxy.get('pkg', {}).get('http', None) | default(system.proxy.get('http', None), true) }}
  17. ftp: {{ system.proxy.get('pkg', {}).get('ftp', None) | default(system.proxy.get('ftp', None), true) }}
  18. {%- else %}
  19. /etc/apt/apt.conf.d/99proxies-salt:
  20. file.absent
  21. {%- endif %}
  22. {%- endif %}
  23. {% set default_repos = {} %}
  24. {%- if system.purge_repos|default(False) %}
  25. purge_sources_list_d_repos:
  26. file.directory:
  27. - name: /etc/apt/sources.list.d/
  28. - clean: True
  29. {%- endif %}
  30. {%- for name, repo in system.repo.items() %}
  31. {%- set name=repo.get('name', name) %}
  32. {%- if grains.os_family == 'Debian' %}
  33. # per repository proxy setup
  34. {%- if repo.get('proxy', {}).get('enabled', False) %}
  35. {%- set external_host = repo.proxy.get('host', None) or repo.source.split('/')[2] %}
  36. /etc/apt/apt.conf.d/99proxies-salt-{{ name }}:
  37. file.managed:
  38. - template: jinja
  39. - source: salt://linux/files/apt.conf.d_proxies
  40. - defaults:
  41. external_host: {{ external_host }}
  42. https: {{ repo.proxy.get('https', None) or system.proxy.get('pkg', {}).get('https', None) | default(system.proxy.get('https', None), True) }}
  43. http: {{ repo.proxy.get('http', None) or system.proxy.get('pkg', {}).get('http', None) | default(system.proxy.get('http', None), True) }}
  44. ftp: {{ repo.proxy.get('ftp', None) or system.proxy.get('pkg', {}).get('ftp', None) | default(system.proxy.get('ftp', None), True) }}
  45. {%- else %}
  46. /etc/apt/apt.conf.d/99proxies-salt-{{ name }}:
  47. file.absent
  48. {%- endif %}
  49. {%- if repo.pin is defined %}
  50. linux_repo_{{ name }}_pin:
  51. file.managed:
  52. - name: /etc/apt/preferences.d/{{ name }}
  53. - source: salt://linux/files/preferences_repo
  54. - template: jinja
  55. - defaults:
  56. repo_name: {{ name }}
  57. {%- else %}
  58. linux_repo_{{ name }}_pin:
  59. file.absent:
  60. - name: /etc/apt/preferences.d/{{ name }}
  61. {%- endif %}
  62. {%- if repo.get('default', False) %}
  63. {%- do default_repos.update({name: repo}) %}
  64. {%- if repo.get('key') %}
  65. linux_repo_{{ name }}_key:
  66. cmd.wait:
  67. - name: "echo '{{ repo.key }}' | apt-key add -"
  68. - watch:
  69. - file: default_repo_list
  70. {%- elif repo.key_url|default(False) %}
  71. linux_repo_{{ name }}_key:
  72. cmd.wait:
  73. - name: "curl -s {{ repo.key_url }} | apt-key add -"
  74. - watch:
  75. - file: default_repo_list
  76. {%- endif %}
  77. {%- else %}
  78. {%- if repo.get('enabled', True) %}
  79. linux_repo_{{ name }}:
  80. pkgrepo.managed:
  81. {%- if repo.ppa is defined %}
  82. - ppa: {{ repo.ppa }}
  83. {%- else %}
  84. - humanname: {{ name }}
  85. - name: {{ repo.source }}
  86. {%- if repo.architectures is defined %}
  87. - architectures: {{ repo.architectures }}
  88. {%- endif %}
  89. - file: /etc/apt/sources.list.d/{{ name }}.list
  90. - clean_file: {{ repo.clean|default(True) }}
  91. {%- if repo.key_id is defined %}
  92. - keyid: {{ repo.key_id }}
  93. {%- endif %}
  94. {%- if repo.key_server is defined %}
  95. - keyserver: {{ repo.key_server }}
  96. {%- endif %}
  97. {%- if repo.key_url is defined %}
  98. - key_url: {{ repo.key_url }}
  99. {%- endif %}
  100. - consolidate: {{ repo.get('consolidate', False) }}
  101. - clean_file: {{ repo.get('clean_file', False) }}
  102. - refresh_db: {{ repo.get('refresh_db', True) }}
  103. - require:
  104. - pkg: linux_repo_prereq_pkgs
  105. {%- if repo.get('proxy', {}).get('enabled', False) %}
  106. - file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
  107. {%- endif %}
  108. {%- if system.proxy.get('pkg', {}).get('enabled', False) %}
  109. - file: /etc/apt/apt.conf.d/99proxies-salt
  110. {%- endif %}
  111. {%- if system.purge_repos|default(False) %}
  112. - file: purge_sources_list_d_repos
  113. {%- endif %}
  114. {%- endif %}
  115. {%- else %}
  116. linux_repo_{{ name }}_absent:
  117. pkgrepo.absent:
  118. {%- if repo.ppa is defined %}
  119. - ppa: {{ repo.ppa }}
  120. {%- if repo.key_id is defined %}
  121. - keyid_ppa: {{ repo.keyid_ppa }}
  122. {%- endif %}
  123. {%- else %}
  124. - file: /etc/apt/sources.list.d/{{ name }}.list
  125. {%- if repo.key_id is defined %}
  126. - keyid: {{ repo.key_id }}
  127. {%- endif %}
  128. {%- endif %}
  129. file.absent:
  130. - name: /etc/apt/sources.list.d/{{ name }}.list
  131. {%- endif %}
  132. {%- endif %}
  133. {#- os_family Debian #}
  134. {%- endif %}
  135. {%- if grains.os_family == "RedHat" %}
  136. {%- if repo.get('enabled', True) %}
  137. {%- if repo.get('proxy', {}).get('enabled', False) %}
  138. # PLACEHOLDER
  139. # TODO, implement per proxy configuration for Yum
  140. {%- endif %}
  141. {%- if not repo.get('default', False) %}
  142. linux_repo_{{ name }}:
  143. pkgrepo.managed:
  144. - name: {{ name }}
  145. - humanname: {{ repo.get('humanname', name) }}
  146. {%- if repo.mirrorlist is defined %}
  147. - mirrorlist: {{ repo.mirrorlist }}
  148. {%- else %}
  149. - baseurl: {{ repo.source }}
  150. {%- endif %}
  151. - gpgcheck: {% if repo.get('gpgcheck', False) %}1{% else %}0{% endif %}
  152. {%- if repo.gpgkey is defined %}
  153. - gpgkey: {{ repo.gpgkey }}
  154. {%- endif %}
  155. - require:
  156. - pkg: linux_repo_prereq_pkgs
  157. {%- endif %}
  158. {#- repo.enabled is false #}
  159. {%- else %}
  160. pkgrepo.absent:
  161. - name: {{ repo.source }}
  162. {%- endif %}
  163. {#- os_family Redhat #}
  164. {%- endif %}
  165. {#- repo.items() loop #}
  166. {%- endfor %}
  167. {%- if default_repos|length > 0 and grains.os_family == 'Debian' %}
  168. default_repo_list:
  169. file.managed:
  170. - name: /etc/apt/sources.list
  171. - source: salt://linux/files/sources.list
  172. - template: jinja
  173. - user: root
  174. - group: root
  175. - mode: 0644
  176. {%- if system.purge_repos|default(False) %}
  177. - replace: True
  178. {%- endif %}
  179. - defaults:
  180. default_repos: {{ default_repos }}
  181. - require:
  182. - pkg: linux_repo_prereq_pkgs
  183. refresh_default_repo:
  184. module.wait:
  185. - name: pkg.refresh_db
  186. - watch:
  187. - file: default_repo_list
  188. {%- endif %}
  189. {%- endif %}