Saltstack Official Nginx Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

175 lines
5.0KB

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