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

217 líneas
6.3KB

  1. # nginx.pkg
  2. #
  3. # Manages installation of nginx from pkg.
  4. {#- Get the `tplroot` from `tpldir` #}
  5. {%- set tplroot = tpldir.split('/')[0] %}
  6. {%- from tplroot ~ "/map.jinja" import nginx, sls_block with context %}
  7. {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
  8. {%- if nginx.install_from_repo %}
  9. {% set from_official = true %}
  10. {% set from_ppa = false %}
  11. {% set from_phusionpassenger = false %}
  12. {% elif nginx.install_from_ppa %}
  13. {% set from_official = false %}
  14. {% set from_ppa = true %}
  15. {% set from_phusionpassenger = false %}
  16. {% elif nginx.install_from_phusionpassenger %}
  17. {% set from_official = false %}
  18. {% set from_ppa = false %}
  19. {% set from_phusionpassenger = true %}
  20. {% else %}
  21. {% set from_official = false %}
  22. {% set from_ppa = false %}
  23. {% set from_phusionpassenger = false %}
  24. {%- endif %}
  25. {%- set resource_repo_managed = 'file' if grains.os_family == 'Debian' else 'pkgrepo' %}
  26. nginx_install:
  27. pkg.installed:
  28. {{ sls_block(nginx.package.opts) }}
  29. {% if nginx.lookup.package is iterable and nginx.lookup.package is not string %}
  30. - pkgs:
  31. {% for pkg in nginx.lookup.package %}
  32. - {{ pkg }}
  33. {% endfor %}
  34. {% else %}
  35. - name: {{ nginx.lookup.package }}
  36. {% endif %}
  37. {% if grains.os_family == 'Debian' %}
  38. {%- if from_official %}
  39. nginx_official_repo_keyring:
  40. file.managed:
  41. - name: {{ nginx.lookup.package_repo_keyring }}
  42. - source: {{ files_switch(['nginx-archive-keyring.gpg'],
  43. lookup='nginx_official_repo_keyring'
  44. )
  45. }}
  46. - require_in:
  47. - {{ resource_repo_managed }}: nginx_official_repo
  48. {%- endif %}
  49. nginx_official_repo:
  50. file:
  51. {%- if from_official %}
  52. - managed
  53. {%- else %}
  54. - absent
  55. {%- endif %}
  56. - name: /etc/apt/sources.list.d/nginx-official-{{ grains.oscodename }}.list
  57. - contents: >
  58. deb [signed-by={{ nginx.lookup.package_repo_keyring }}]
  59. http://nginx.org/packages/{{ grains.os | lower }}/ {{ grains.oscodename }} nginx
  60. - require_in:
  61. - pkg: nginx_install
  62. - watch_in:
  63. - pkg: nginx_install
  64. {%- if grains.os not in ('Debian',) %}
  65. ## applies to Ubuntu and derivatives only #}
  66. nginx_ppa_repo:
  67. pkgrepo:
  68. {%- if from_ppa %}
  69. - managed
  70. {%- else %}
  71. - absent
  72. {%- endif %}
  73. {% if grains.os == 'Ubuntu' %}
  74. - ppa: nginx/{{ nginx.ppa_version }}
  75. {% else %}
  76. - name: deb http://ppa.launchpad.net/nginx/{{ nginx.ppa_version }}/ubuntu {{ grains.oscodename }} main
  77. - keyid: C300EE8C
  78. - keyserver: keyserver.ubuntu.com
  79. {% endif %}
  80. - require_in:
  81. - pkg: nginx_install
  82. - watch_in:
  83. - pkg: nginx_install
  84. {%- endif %}
  85. {%- if from_phusionpassenger %}
  86. nginx_phusionpassenger_repo_keyring:
  87. file.managed:
  88. - name: /usr/share/keyrings/phusionpassenger-archive-keyring.gpg
  89. - source: {{ files_switch(['phusionpassenger-archive-keyring.gpg'],
  90. lookup='nginx_phusionpassenger_repo_keyring'
  91. )
  92. }}
  93. - require_in:
  94. - {{ resource_repo_managed }}: nginx_phusionpassenger_repo
  95. # Remove the old repo file
  96. nginx_phusionpassenger_repo_remove:
  97. pkgrepo.absent:
  98. - name: deb http://nginx.org/packages/{{ grains.os |lower }}/ {{ grains.oscodename }} nginx
  99. - keyid: 561F9B9CAC40B2F7
  100. - require_in:
  101. - {{ resource_repo_managed }}: nginx_phusionpassenger_repo
  102. file.absent:
  103. - name: /etc/apt/sources.list.d/nginx-phusionpassenger-{{ grains.oscodename }}.list
  104. - require_in:
  105. - {{ resource_repo_managed }}: nginx_phusionpassenger_repo
  106. {%- endif %}
  107. nginx_phusionpassenger_repo:
  108. file:
  109. {%- if from_phusionpassenger %}
  110. - managed
  111. {%- else %}
  112. - absent
  113. {%- endif %}
  114. - name: /etc/apt/sources.list.d/phusionpassenger-official-{{ grains.oscodename }}.list
  115. - contents: >
  116. deb [signed-by={{ nginx.lookup.passenger_package_repo_keyring }}]
  117. https://oss-binaries.phusionpassenger.com/apt/passenger {{ grains.oscodename }} main
  118. - require_in:
  119. - pkg: nginx_install
  120. - watch_in:
  121. - pkg: nginx_install
  122. {% endif %}
  123. {% if grains.os_family == 'Suse' or grains.os == 'SUSE' %}
  124. nginx_zypp_repo:
  125. pkgrepo:
  126. {%- if from_official %}
  127. - managed
  128. {%- else %}
  129. - absent
  130. {%- endif %}
  131. - name: server_http
  132. - humanname: server_http
  133. - baseurl: 'http://download.opensuse.org/repositories/server:/http/openSUSE_13.2/'
  134. - enabled: True
  135. - autorefresh: True
  136. - gpgcheck: {{ nginx.lookup.gpg_check }}
  137. - gpgkey: {{ nginx.lookup.gpg_key }}
  138. - require_in:
  139. - pkg: nginx_install
  140. - watch_in:
  141. - pkg: nginx_install
  142. {% endif %}
  143. {% if grains.os_family == 'RedHat' %}
  144. {% if grains.get('osfinger', '') == 'Amazon Linux-2' %}
  145. nginx_epel_repo:
  146. pkgrepo.managed:
  147. - name: epel
  148. - humanname: Extra Packages for Enterprise Linux 7 - $basearch
  149. - mirrorlist: https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
  150. - enabled: 1
  151. - gpgcheck: 1
  152. - gpgkey: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
  153. - failovermethod: priority
  154. - require_in:
  155. - pkg: nginx_install
  156. - watch_in:
  157. - pkg: nginx_install
  158. {% endif %}
  159. nginx_yum_repo:
  160. pkgrepo:
  161. {%- if from_official %}
  162. - managed
  163. {%- else %}
  164. - absent
  165. {%- endif %}
  166. - name: nginx
  167. - humanname: nginx repo
  168. {%- if grains.os == 'CentOS' %}
  169. - baseurl: 'http://nginx.org/packages/centos/$releasever/$basearch/'
  170. {%- else %}
  171. - baseurl: 'http://nginx.org/packages/rhel/{{ nginx.lookup.rh_os_releasever }}/$basearch/'
  172. {%- endif %}
  173. - gpgcheck: {{ nginx.lookup.gpg_check }}
  174. - gpgkey: {{ nginx.lookup.gpg_key }}
  175. - enabled: True
  176. - require_in:
  177. - pkg: nginx_install
  178. - watch_in:
  179. - pkg: nginx_install
  180. nginx_phusionpassenger_yum_repo:
  181. pkgrepo:
  182. {%- if from_phusionpassenger %}
  183. - managed
  184. {%- else %}
  185. - absent
  186. {%- endif %}
  187. - name: passenger
  188. - humanname: nginx phusionpassenger repo
  189. - baseurl: 'https://oss-binaries.phusionpassenger.com/yum/passenger/el/$releasever/$basearch'
  190. - repo_gpgcheck: 1
  191. - gpgcheck: 0
  192. - gpgkey: 'https://oss-binaries.phusionpassenger.com/yum/definitions/RPM-GPG-KEY.asc'
  193. - enabled: True
  194. - sslverify: 1
  195. - sslcacert: /etc/pki/tls/certs/ca-bundle.crt
  196. - require_in:
  197. - pkg: nginx_install
  198. - watch_in:
  199. - pkg: nginx_install
  200. {% endif %}