Saltstack Official Linux Formula
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

hace 9 años
hace 7 años
hace 7 años
hace 7 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 7 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 9 años
hace 7 años
hace 9 años
hace 9 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.enabled %}
  3. {% if system.pkgs %}
  4. linux_repo_prereq_pkgs:
  5. pkg.installed:
  6. - pkgs: {{ system.pkgs | json }}
  7. {%- endif %}
  8. # global proxy setup
  9. {%- if grains.os_family == 'Debian' %}
  10. {%- if system.proxy.get('pkg', {}).get('enabled', False) %}
  11. /etc/apt/apt.conf.d/99proxies-salt:
  12. file.managed:
  13. - template: jinja
  14. - source: salt://linux/files/apt.conf.d_proxies
  15. - defaults:
  16. external_host: False
  17. https: {{ system.proxy.get('pkg', {}).get('https', None) | default(system.proxy.get('https', None), true) }}
  18. http: {{ system.proxy.get('pkg', {}).get('http', None) | default(system.proxy.get('http', None), true) }}
  19. ftp: {{ system.proxy.get('pkg', {}).get('ftp', None) | default(system.proxy.get('ftp', None), true) }}
  20. {%- else %}
  21. /etc/apt/apt.conf.d/99proxies-salt:
  22. file.absent
  23. {%- endif %}
  24. {%- else %}
  25. # Implement grobal proxy configiration for non-debian OS.
  26. {%- endif %}
  27. {% set default_repos = {} %}
  28. {%- if system.purge_repos|default(False) %}
  29. purge_sources_list_d_repos:
  30. file.directory:
  31. - name: /etc/apt/sources.list.d/
  32. - clean: True
  33. {%- endif %}
  34. {%- for name, repo in system.repo.items() | sort %}
  35. {%- set name=repo.get('name', name) %}
  36. {%- if grains.os_family == 'Debian' %}
  37. # per repository proxy setup
  38. {%- if repo.get('proxy', {}).get('enabled', False) %}
  39. {%- set external_host = repo.proxy.get('host', None) or repo.source.split('/')[2] %}
  40. /etc/apt/apt.conf.d/99proxies-salt-{{ name }}:
  41. file.managed:
  42. - template: jinja
  43. - source: salt://linux/files/apt.conf.d_proxies
  44. - defaults:
  45. external_host: {{ external_host }}
  46. https: {{ repo.proxy.get('https', None) or system.proxy.get('pkg', {}).get('https', None) | default(system.proxy.get('https', None), True) }}
  47. http: {{ repo.proxy.get('http', None) or system.proxy.get('pkg', {}).get('http', None) | default(system.proxy.get('http', None), True) }}
  48. ftp: {{ repo.proxy.get('ftp', None) or system.proxy.get('pkg', {}).get('ftp', None) | default(system.proxy.get('ftp', None), True) }}
  49. {%- else %}
  50. /etc/apt/apt.conf.d/99proxies-salt-{{ name }}:
  51. file.absent
  52. {%- endif %}
  53. {%- if repo.pin is defined or repo.pinning is defined %}
  54. linux_repo_{{ name }}_pin:
  55. file.managed:
  56. - name: /etc/apt/preferences.d/{{ name }}
  57. - source: salt://linux/files/preferences_repo
  58. - template: jinja
  59. - defaults:
  60. repo_name: {{ name }}
  61. {%- else %}
  62. linux_repo_{{ name }}_pin:
  63. file.absent:
  64. - name: /etc/apt/preferences.d/{{ name }}
  65. {%- endif %}
  66. {%- if repo.get('key') %}
  67. linux_repo_{{ name }}_key:
  68. {% set repo_key = salt['hashutil.base64_b64encode'](repo.key) %}
  69. cmd.run:
  70. - name: "echo '{{ repo_key }}' | base64 -d | apt-key add -"
  71. - require_in:
  72. {%- if repo.get('default', False) %}
  73. - file: default_repo_list
  74. {% else %}
  75. - pkgrepo: linux_repo_{{ name }}
  76. {% endif %}
  77. {# key_url fetch by curl when salt <2017.7, higher version of salt has
  78. fixed bug for using a proxy_host/port specified at minion.conf
  79. NOTE: curl/cmd.run usage to fetch gpg key has limited functionality behind proxy.
  80. Environments with salt >= 2017.7 should use key_url specified at
  81. pkgrepo.manage state (which uses properly configured http_host at
  82. minion.conf). Older versions of salt require to have proxy set at
  83. ENV and curl way to fetch gpg key here can have a sense for backward
  84. compatibility. Be aware that as of salt 2018.3 no_proxy option is
  85. not implemented at all.
  86. #}
  87. {%- elif repo.key_url|default(False) and grains['saltversioninfo'] < [2017, 7] and not repo.key_url.startswith('salt://') %}
  88. linux_repo_{{ name }}_key:
  89. cmd.run:
  90. - name: "curl -sL {{ repo.key_url }} | apt-key add -"
  91. - require_in:
  92. {%- if repo.get('default', False) %}
  93. - file: default_repo_list
  94. {% else %}
  95. - pkgrepo: linux_repo_{{ name }}
  96. {% endif %}
  97. {%- endif %}
  98. {%- if repo.get('default', False) %}
  99. {%- do default_repos.update({name: repo}) %}
  100. {%- else %}
  101. {%- if repo.get('enabled', True) %}
  102. linux_repo_{{ name }}:
  103. pkgrepo.managed:
  104. - refresh_db: False
  105. - require_in:
  106. - refresh_db
  107. {%- if repo.ppa is defined %}
  108. - ppa: {{ repo.ppa }}
  109. {%- else %}
  110. - humanname: {{ name }}
  111. - name: {{ repo.source }}
  112. {%- if repo.architectures is defined %}
  113. - architectures: {{ repo.architectures }}
  114. {%- endif %}
  115. - file: /etc/apt/sources.list.d/{{ name }}.list
  116. - clean_file: {{ repo.get('clean_file', True) }}
  117. {%- if repo.key_id is defined %}
  118. - keyid: {{ repo.key_id }}
  119. {%- endif %}
  120. {%- if repo.key_server is defined %}
  121. - keyserver: {{ repo.key_server }}
  122. {%- endif %}
  123. {%- if repo.key_url is defined and (grains['saltversioninfo'] >= [2017, 7] or repo.key_url.startswith('salt://')) %}
  124. - key_url: {{ repo.key_url }}
  125. {%- endif %}
  126. {#
  127. Disable apt-key usage when salt version is at least 3005, and the user provides
  128. 'signed-by=' in their source, and we're on a newer version of Debian or Ubuntu.
  129. apt-key is deprecated, see the following for more context:
  130. https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pkgrepo.html#apt-key-deprecated
  131. #}
  132. {%- if grains['saltversioninfo'] >= [3005, 0] and
  133. 'signed-by=' in repo.source and
  134. (
  135. (grains['os'] == 'Debian' and grains['osrelease_info'] >= (11,)) or
  136. (grains['os'] == 'Ubuntu' and grains['osrelease_info'] >= (22, 4))
  137. )
  138. %}
  139. - aptkey: False
  140. {%- endif %}
  141. - consolidate: {{ repo.get('consolidate', False) }}
  142. - require:
  143. - file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
  144. - file: /etc/apt/apt.conf.d/99proxies-salt
  145. {%- if system.purge_repos|default(False) %}
  146. - file: purge_sources_list_d_repos
  147. {%- endif %}
  148. {%- endif %}
  149. {%- else %}
  150. linux_repo_{{ name }}:
  151. pkgrepo.absent:
  152. - refresh_db: False
  153. - require:
  154. - file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
  155. - require_in:
  156. - refresh_db
  157. {%- if repo.ppa is defined %}
  158. - ppa: {{ repo.ppa }}
  159. {%- if repo.key_id is defined %}
  160. - keyid_ppa: {{ repo.keyid_ppa }}
  161. {%- endif %}
  162. {%- else %}
  163. - file: /etc/apt/sources.list.d/{{ name }}.list
  164. {%- if repo.key_id is defined %}
  165. - keyid: {{ repo.key_id }}
  166. {%- endif %}
  167. {%- endif %}
  168. {%- endif %}
  169. {%- endif %}
  170. {%- endif %}
  171. {%- if grains.os_family == "RedHat" %}
  172. {%- if repo.get('enabled', True) %}
  173. {%- if repo.get('proxy', {}).get('enabled', False) %}
  174. # PLACEHOLDER
  175. # TODO, implement per proxy configuration for Yum
  176. {%- endif %}
  177. {%- if not repo.get('default', False) %}
  178. linux_repo_{{ name }}:
  179. pkgrepo.managed:
  180. - refresh_db: False
  181. - require_in:
  182. - refresh_db
  183. - name: {{ name }}
  184. - humanname: {{ repo.get('humanname', name) }}
  185. {%- if repo.mirrorlist is defined %}
  186. - mirrorlist: {{ repo.mirrorlist }}
  187. {%- else %}
  188. - baseurl: {{ repo.source }}
  189. {%- endif %}
  190. - gpgcheck: {% if repo.get('gpgcheck', False) %}1{% else %}0{% endif %}
  191. {%- if repo.gpgkey is defined %}
  192. - gpgkey: {{ repo.gpgkey }}
  193. {%- endif %}
  194. {%- endif %}
  195. {%- else %}
  196. pkgrepo.absent:
  197. - refresh_db: False
  198. - require_in:
  199. - refresh_db
  200. - name: {{ repo.source }}
  201. {%- endif %}
  202. {%- endif %}
  203. {%- endfor %}
  204. {%- if default_repos|length > 0 and grains.os_family == 'Debian' %}
  205. default_repo_list:
  206. file.managed:
  207. - name: /etc/apt/sources.list
  208. - source: salt://linux/files/sources.list
  209. - template: jinja
  210. - user: root
  211. - group: root
  212. - mode: 0644
  213. {%- if system.purge_repos|default(False) %}
  214. - replace: True
  215. {%- endif %}
  216. - defaults:
  217. default_repos: {{ default_repos }}
  218. {%- endif %}
  219. refresh_db:
  220. {%- if system.get('refresh_repos_meta', True) %}
  221. module.run:
  222. {%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
  223. - pkg.refresh_db: []
  224. {%- else %}
  225. - name: pkg.refresh_db
  226. {% endif %}
  227. {%- else %}
  228. test.succeed_without_changes
  229. {%- endif %}
  230. {%- endif %}