22#
33# Manages installation of nginx from pkg.
44
5- {% from ' nginx/map.jinja' import nginx, sls_block with context % }
5+ {# - Get the `tplroot` from `tpldir` #}
6+ {%- set tplroot = tpldir.split(' /' )[0 ] %}
7+ {%- from tplroot ~ " /map.jinja" import nginx, sls_block with context % }
8+ {%- from tplroot ~ " /libtofs.jinja" import files_switch with context % }
9+
610{%- if nginx.install_from_repo % }
711 {% set from_official = true % }
812 {% set from_ppa = false % }
@@ -33,7 +37,19 @@ nginx_install:
3337 - name: {{ nginx.lookup.package }}
3438 {% endif % }
3539
36- {% if salt[' grains.get' ](' os_family' ) == ' Debian' % }
40+ {% if grains.os_family == ' Debian' % }
41+ {%- if from_official % }
42+ nginx_official_repo_keyring:
43+ file .managed:
44+ - name: {{ nginx.lookup.package_repo_keyring }}
45+ - source: {{ files_switch([' nginx-archive-keyring.gpg' ],
46+ lookup = ' nginx_official_repo_keyring'
47+ )
48+ }}
49+ - require_in:
50+ - pkgrepo: nginx_official_repo
51+ {%- endif % }
52+
3753nginx_official_repo:
3854 pkgrepo:
3955 {%- if from_official % }
@@ -42,10 +58,10 @@ nginx_official_repo:
4258 - absent
4359 {%- endif % }
4460 - humanname: nginx apt repo
45- - name: deb http: // nginx.org / packages / {{ grains[ ' os ' ].lower() }} / {{ grains[ ' oscodename ' ] }} nginx
46- - file : / etc / apt / sources.list.d / nginx - official - {{ grains[ ' oscodename ' ] }}.list
47- - keyid: ABF5BD827BD9BF62
48- - keyserver: keyserver.ubuntu.com
61+ - name: > -
62+ deb [signed - by= {{ nginx.lookup.package_repo_keyring }}]
63+ http: // nginx.org / packages / {{ grains.os | lower }} / {{ grains.oscodename }} nginx
64+ - file : / etc / apt / sources.list.d / nginx - official - {{ grains.oscodename }}.list
4965 - require_in:
5066 - pkg: nginx_install
5167 - watch_in:
@@ -60,10 +76,10 @@ nginx_ppa_repo:
6076 {%- else % }
6177 - absent
6278 {%- endif % }
63- {% if salt[ ' grains.get ' ]( ' os ' ) == ' Ubuntu' % }
79+ {% if grains.os == ' Ubuntu' % }
6480 - ppa: nginx/ {{ nginx.ppa_version }}
6581 {% else % }
66- - name: deb http:// ppa.launchpad.net/ nginx/ {{ nginx.ppa_version }}/ ubuntu {{ grains[ ' oscodename' ] }} main
82+ - name: deb http:// ppa.launchpad.net/ nginx/ {{ nginx.ppa_version }}/ ubuntu {{ grains. oscodename }} main
6783 - keyid: C300EE8C
6884 - keyserver: keyserver.ubuntu.com
6985 {% endif % }
@@ -73,6 +89,30 @@ nginx_ppa_repo:
7389 - pkg: nginx_install
7490 {%- endif % }
7591
92+ {%- if from_phusionpassenger % }
93+ nginx_phusionpassenger_repo_keyring:
94+ file .managed:
95+ - name: / usr/ share/ keyrings/ phusionpassenger- archive- keyring.gpg
96+ - source: {{ files_switch([' phusionpassenger-archive-keyring.gpg' ],
97+ lookup = ' nginx_phusionpassenger_repo_keyring'
98+ )
99+ }}
100+ - require_in:
101+ - pkgrepo: nginx_phusionpassenger_repo
102+
103+ # Remove the old repo file
104+ nginx_phusionpassenger_repo_remove:
105+ pkgrepo.absent:
106+ - name: deb http:// nginx.org/ packages/ {{ grains.os | lower }}/ {{ grains.oscodename }} nginx
107+ - keyid: 561F9B9CAC40B2F7
108+ - require_in:
109+ - pkgrepo: nginx_phusionpassenger_repo
110+ file .absent:
111+ - name: / etc/ apt/ sources.list.d/ nginx- phusionpassenger- {{ grains.oscodename }}.list
112+ - require_in:
113+ - pkgrepo: nginx_phusionpassenger_repo
114+ {%- endif % }
115+
76116nginx_phusionpassenger_repo:
77117 pkgrepo:
78118 {%- if from_phusionpassenger % }
@@ -81,17 +121,17 @@ nginx_phusionpassenger_repo:
81121 - absent
82122 {%- endif % }
83123 - humanname: nginx phusionpassenger repo
84- - name: deb https: // oss - binaries.phusionpassenger.com / apt / passenger {{ grains[ ' oscodename ' ] }} main
85- - file : / etc / apt / sources.list.d / nginx - phusionpassenger - {{ grains[ ' oscodename ' ] }}.list
86- - keyid: 561F9B9CAC40B2F7
87- - keyserver: keyserver.ubuntu.com
124+ - name: > -
125+ deb [signed - by= {{ nginx.lookup.passenger_package_repo_keyring }}]
126+ https: // oss - binaries.phusionpassenger.com / apt / passenger {{ grains.oscodename }} main
127+ - file : / etc / apt / sources.list.d / phusionpassenger - official - {{ grains.oscodename }}.list
88128 - require_in:
89129 - pkg: nginx_install
90130 - watch_in:
91131 - pkg: nginx_install
92132{% endif % }
93133
94- {% if salt[ ' grains.get ' ]( ' os_family' ) == ' Suse' or salt[ ' grains.get ' ]( ' os ' ) == ' SUSE' % }
134+ {% if grains.os_family == ' Suse' or grains.os == ' SUSE' % }
95135nginx_zypp_repo:
96136 pkgrepo:
97137 {%- if from_official % }
@@ -112,8 +152,8 @@ nginx_zypp_repo:
112152 - pkg: nginx_install
113153{% endif % }
114154
115- {% if salt[ ' grains.get ' ]( ' os_family' ) == ' RedHat' % }
116- {% if salt[ ' grains.get' ] (' osfinger' , ' ' ) in [ ' Amazon Linux-2' ] % }
155+ {% if grains.os_family == ' RedHat' % }
156+ {% if grains.get(' osfinger' , ' ' ) == ' Amazon Linux-2' % }
117157nginx_epel_repo:
118158 pkgrepo.managed:
119159 - name: epel
@@ -138,7 +178,7 @@ nginx_yum_repo:
138178 {%- endif % }
139179 - name: nginx
140180 - humanname: nginx repo
141- {%- if salt[ ' grains.get ' ]( ' os ' ) == ' CentOS' % }
181+ {%- if grains.os == ' CentOS' % }
142182 - baseurl: ' http://nginx.org/packages/centos/$releasever/$basearch/'
143183 {%- else % }
144184 - baseurl: ' http://nginx.org/packages/rhel/{{ nginx.lookup.rh_os_releasever }} /$basearch/'
0 commit comments