Saltstack Official Linux Formula
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

165 行
4.4KB

  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.enabled %}
  3. # global proxy setup
  4. {%- if system.proxy.get('pkg', {}).get('enabled', False) %}
  5. {%- if grains.os_family == 'Debian' %}
  6. /etc/apt/apt.conf.d/99proxies-salt:
  7. file.managed:
  8. - template: jinja
  9. - source: salt://linux/files/apt.conf.d_proxies
  10. - defaults:
  11. external_host: False
  12. https: {{ system.proxy.get('pkg', {}).get('https', None) | default(system.proxy.get('https', None), true) }}
  13. http: {{ system.proxy.get('pkg', {}).get('http', None) | default(system.proxy.get('http', None), true) }}
  14. ftp: {{ system.proxy.get('pkg', {}).get('ftp', None) | default(system.proxy.get('ftp', None), true) }}
  15. {%- else %}
  16. /etc/apt/apt.conf.d/99proxies-salt:
  17. file.absent
  18. {%- endif %}
  19. {%- endif %}
  20. {% set default_repos = {} %}
  21. {%- for name, repo in system.repo.iteritems() %}
  22. {%- if grains.os_family == 'Debian' %}
  23. # per repository proxy setup
  24. {%- if repo.get('proxy', {}).get('enabled', False) %}
  25. {%- set external_host = repo.proxy.get('host', None) or repo.source.split('/')[2] %}
  26. /etc/apt/apt.conf.d/99proxies-salt-{{ name }}:
  27. file.managed:
  28. - template: jinja
  29. - source: salt://linux/files/apt.conf.d_proxies
  30. - defaults:
  31. external_host: {{ external_host }}
  32. https: {{ repo.proxy.get('https', None) or system.proxy.get('pkg', {}).get('https', None) | default(system.proxy.get('https', None), True) }}
  33. http: {{ repo.proxy.get('http', None) or system.proxy.get('pkg', {}).get('http', None) | default(system.proxy.get('http', None), True) }}
  34. ftp: {{ repo.proxy.get('ftp', None) or system.proxy.get('pkg', {}).get('ftp', None) | default(system.proxy.get('ftp', None), True) }}
  35. {%- else %}
  36. /etc/apt/apt.conf.d/99proxies-salt-{{ name }}:
  37. file.absent
  38. {%- endif %}
  39. {%- if repo.pin is defined %}
  40. linux_repo_{{ name }}_pin:
  41. file.managed:
  42. - name: /etc/apt/preferences.d/{{ name }}
  43. - source: salt://linux/files/preferences_repo
  44. - template: jinja
  45. - defaults:
  46. repo_name: {{ name }}
  47. {%- else %}
  48. linux_repo_{{ name }}_pin:
  49. file.absent:
  50. - name: /etc/apt/preferences.d/{{ name }}
  51. {%- endif %}
  52. {%- if repo.get('default', False) %}
  53. {%- do default_repos.update({name: repo}) %}
  54. {%- if repo.key_url|default(False) %}
  55. linux_repo_{{ name }}_key:
  56. cmd.wait:
  57. - name: "curl -s {{ repo.key_url }} | apt-key add -"
  58. - watch:
  59. - file: default_repo_list
  60. {%- endif %}
  61. {%- else %}
  62. linux_repo_{{ name }}:
  63. pkgrepo.managed:
  64. - human_name: {{ name }}
  65. - name: {{ repo.source }}
  66. {%- if repo.architectures is defined %}
  67. - architectures: {{ repo.architectures }}
  68. {%- endif %}
  69. - file: /etc/apt/sources.list.d/{{ name }}.list
  70. {%- if repo.key_id is defined %}
  71. - keyid: {{ repo.key_id }}
  72. {%- endif %}
  73. {%- if repo.key_server is defined %}
  74. - keyserver: {{ repo.key_server }}
  75. {%- endif %}
  76. {%- if repo.key_url is defined %}
  77. - key_url: {{ repo.key_url }}
  78. {%- endif %}
  79. - consolidate: {{ repo.get('consolidate', False) }}
  80. - clean_file: {{ repo.get('clean_file', False) }}
  81. - refresh_db: {{ repo.get('refresh_db', True) }}
  82. - require:
  83. - pkg: linux_packages
  84. {%- if repo.get('proxy', {}).get('enabled', False) %}
  85. - file: /etc/apt/apt.conf.d/99proxies-salt-{{ name }}
  86. {%- endif %}
  87. {%- if system.proxy.get('pkg', {}).get('enabled', False) %}
  88. - file: /etc/apt/apt.conf.d/99proxies-salt
  89. {%- endif %}
  90. {%- endif %}
  91. {%- endif %}
  92. {%- if grains.os_family == "RedHat" %}
  93. {%- if repo.get('proxy', {}).get('enabled', False) %}
  94. # PLACEHOLDER
  95. # TODO, implement per proxy configuration for Yum
  96. {%- endif %}
  97. {%- if not repo.get('default', False) %}
  98. linux_repo_{{ name }}:
  99. pkgrepo.managed:
  100. - name: {{ name }}
  101. - humanname: {{ repo.get('humanname', name) }}
  102. {%- if repo.mirrorlist is defined %}
  103. - mirrorlist: {{ repo.mirrorlist }}
  104. {%- else %}
  105. - baseurl: {{ repo.source }}
  106. {%- endif %}
  107. - gpgcheck: {% if repo.get('gpgcheck', False) %}1{% else %}0{% endif %}
  108. {%- if repo.gpgkey is defined %}
  109. - gpgkey: {{ repo.gpgkey }}
  110. {%- endif %}
  111. - require:
  112. - pkg: linux_packages
  113. {%- endif %}
  114. {%- endif %}
  115. {%- endfor %}
  116. {%- if default_repos|length > 0 and grains.os_family == 'Debian' %}
  117. default_repo_list:
  118. file.managed:
  119. - name: /etc/apt/sources.list
  120. - source: salt://linux/files/sources.list
  121. - template: jinja
  122. - user: root
  123. - group: root
  124. - mode: 0644
  125. - defaults:
  126. default_repos: {{ default_repos }}
  127. - require:
  128. - pkg: linux_packages
  129. {%- endif %}
  130. {%- endif %}