Saltstack Official Linux Formula
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 9 gadiem
pirms 9 gadiem
pirms 7 gadiem
pirms 7 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 7 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 7 gadiem
pirms 9 gadiem
pirms 9 gadiem
pirms 9 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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('key') %} {# 2 #}
  63. linux_repo_{{ name }}_key:
  64. cmd.run:
  65. - name: |
  66. echo "{{ repo.key | indent(12) }}" | apt-key add -
  67. - require_in:
  68. {%- if repo.get('default', False) %}
  69. - file: default_repo_list
  70. {% else %}
  71. - pkgrepo: linux_repo_{{ name }}
  72. {% endif %}
  73. {# key_url fetch by curl when salt <2017.7, higher version of salt has fixed bug for using a proxy_host/port specified at minion.conf #}
  74. {#
  75. NOTE: curl/cmd.run usage to fetch gpg key has limited functionality behind proxy. Environments with salt >= 2017.7 should use
  76. key_url specified at pkgrepo.manage state (which uses properly configured http_host at minion.conf). Older versions of
  77. salt require to have proxy set at ENV and curl way to fetch gpg key here can have a sense for backward compatibility.
  78. Be aware that as of salt 2018.3 no_proxy option is not implemented at all.
  79. #}
  80. {%- elif repo.key_url|default(False) and grains['saltversioninfo'] < [2017, 7] and not repo.key_url.startswith('salt://') %}
  81. linux_repo_{{ name }}_key:
  82. cmd.run:
  83. - name: "curl -sL {{ repo.key_url }} | apt-key add -"
  84. - require_in:
  85. {%- if repo.get('default', False) %}
  86. - file: default_repo_list
  87. {% else %}
  88. - pkgrepo: linux_repo_{{ name }}
  89. {% endif %}
  90. {%- endif %} {# 2 #}
  91. {%- if repo.get('default', False) %} {# 1 #}
  92. {%- do default_repos.update({name: repo}) %} {# for 'default' repos #}
  93. {%- else %} {# for all others repos #}
  94. {%- if repo.get('enabled', True) %}
  95. linux_repo_{{ name }}:
  96. pkgrepo.managed:
  97. {%- if repo.ppa is defined %}
  98. - ppa: {{ repo.ppa }}
  99. {%- else %}
  100. - humanname: {{ name }}
  101. - name: {{ repo.source }}
  102. {%- if repo.architectures is defined %}
  103. - architectures: {{ repo.architectures }}
  104. {%- endif %}
  105. - file: /etc/apt/sources.list.d/{{ name }}.list
  106. - clean_file: {{ repo.clean|default(True) }}
  107. {%- if repo.key_id is defined %}
  108. - keyid: {{ repo.key_id }}
  109. {%- endif %}
  110. {%- if repo.key_server is defined %}
  111. - keyserver: {{ repo.key_server }}
  112. {%- endif %}
  113. {%- if repo.key_url is defined and (grains['saltversioninfo'] >= [2017, 7] or repo.key_url.startswith('salt://')) %}
  114. - key_url: {{ repo.key_url }}
  115. {%- endif %}
  116. - consolidate: {{ repo.get('consolidate', False) }}
  117. - clean_file: {{ repo.get('clean_file', False) }}
  118. - refresh_db: {{ repo.get('refresh_db', True) }}
  119. - require:
  120. - pkg: linux_repo_prereq_pkgs
  121. {%- if repo.get('proxy', {}).get('enabled', False) %}
  122. - file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
  123. {%- endif %}
  124. {%- if system.proxy.get('pkg', {}).get('enabled', False) %}
  125. - file: /etc/apt/apt.conf.d/99proxies-salt
  126. {%- endif %}
  127. {%- if system.purge_repos|default(False) %}
  128. - file: purge_sources_list_d_repos
  129. {%- endif %}
  130. {%- endif %}
  131. {%- else %}
  132. linux_repo_{{ name }}_absent:
  133. pkgrepo.absent:
  134. {%- if repo.ppa is defined %}
  135. - ppa: {{ repo.ppa }}
  136. {%- if repo.key_id is defined %}
  137. - keyid_ppa: {{ repo.keyid_ppa }}
  138. {%- endif %}
  139. {%- else %}
  140. - file: /etc/apt/sources.list.d/{{ name }}.list
  141. {%- if repo.key_id is defined %}
  142. - keyid: {{ repo.key_id }}
  143. {%- endif %}
  144. {%- endif %}
  145. file.absent:
  146. - name: /etc/apt/sources.list.d/{{ name }}.list
  147. {%- endif %}
  148. {%- endif %} {# 1 #}
  149. {#- os_family Debian #}
  150. {%- endif %}
  151. {%- if grains.os_family == "RedHat" %}
  152. {%- if repo.get('enabled', True) %}
  153. {%- if repo.get('proxy', {}).get('enabled', False) %}
  154. # PLACEHOLDER
  155. # TODO, implement per proxy configuration for Yum
  156. {%- endif %}
  157. {%- if not repo.get('default', False) %}
  158. linux_repo_{{ name }}:
  159. pkgrepo.managed:
  160. - name: {{ name }}
  161. - humanname: {{ repo.get('humanname', name) }}
  162. {%- if repo.mirrorlist is defined %}
  163. - mirrorlist: {{ repo.mirrorlist }}
  164. {%- else %}
  165. - baseurl: {{ repo.source }}
  166. {%- endif %}
  167. - gpgcheck: {% if repo.get('gpgcheck', False) %}1{% else %}0{% endif %}
  168. {%- if repo.gpgkey is defined %}
  169. - gpgkey: {{ repo.gpgkey }}
  170. {%- endif %}
  171. - require:
  172. - pkg: linux_repo_prereq_pkgs
  173. {%- endif %}
  174. {#- repo.enabled is false #}
  175. {%- else %}
  176. pkgrepo.absent:
  177. - name: {{ repo.source }}
  178. {%- endif %}
  179. {#- os_family Redhat #}
  180. {%- endif %}
  181. {#- repo.items() loop #}
  182. {%- endfor %}
  183. {%- if default_repos|length > 0 and grains.os_family == 'Debian' %}
  184. default_repo_list:
  185. file.managed:
  186. - name: /etc/apt/sources.list
  187. - source: salt://linux/files/sources.list
  188. - template: jinja
  189. - user: root
  190. - group: root
  191. - mode: 0644
  192. {%- if system.purge_repos|default(False) %}
  193. - replace: True
  194. {%- endif %}
  195. - defaults:
  196. default_repos: {{ default_repos }}
  197. - require:
  198. - pkg: linux_repo_prereq_pkgs
  199. refresh_default_repo:
  200. module.wait:
  201. - name: pkg.refresh_db
  202. - watch:
  203. - file: default_repo_list
  204. {%- endif %}
  205. {%- endif %}