Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3754787
D1947.id4926.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D1947.id4926.diff
View Options
diff --git a/pillar/webserver/sites.sls b/pillar/webserver/sites.sls
--- a/pillar/webserver/sites.sls
+++ b/pillar/webserver/sites.sls
@@ -69,6 +69,10 @@
prod:
command: /usr/local/sbin/php-fpm
+ # PHP 5.6, installed through php-builder unit
+ legacy:
+ command: /opt/php/php56/sbin/php-fpm
+
web_php_sites:
# Nasqueron members
mediawiki.dereckson.be:
@@ -118,7 +122,7 @@
user: web-org-espacewin-www
source: wwwroot/espace-win.org/www
target: /var/wwwroot/espace-win.org/www
- php-fpm: prod
+ php-fpm: legacy
www51.espace-win.org:
domain: espace-win.org
diff --git a/roles/webserver-legacy/php-sites/cleanup.sls b/roles/webserver-legacy/php-sites/cleanup.sls
new file mode 100644
--- /dev/null
+++ b/roles/webserver-legacy/php-sites/cleanup.sls
@@ -0,0 +1,40 @@
+#!py
+
+# -------------------------------------------------------------
+# Salt — Provision PHP websites — php-fpm pools
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Description: When a site is declared to be served by
+# an instance, pools from other instances
+# should be deleted if they exist.
+#
+# That allows to move pools among instances.
+# -------------------------------------------------------------
+
+def get_etc_dir():
+ if __grains__['os'] == 'FreeBSD':
+ return "/usr/local/etc"
+
+ return "/etc"
+
+
+def files_to_delete_if_they_exist():
+ files = []
+ etc_dir = get_etc_dir()
+ for instance in __pillar__['php_fpm_instances']:
+ files.extend([etc_dir + "/php-fpm.d/" + instance + "-pools/" + site['user'] + ".conf"
+ for _, site in __pillar__['web_php_sites'].items()
+ if site['php-fpm'] != instance])
+
+ return files
+
+
+def run():
+ config = {}
+
+ # Task: delete php-fpm stale files
+ for file in files_to_delete_if_they_exist():
+ config[file] = {"file.absent": []}
+
+ return config
diff --git a/roles/webserver-legacy/php-sites/files/rc/php-fpm b/roles/webserver-legacy/php-sites/files/rc/php-fpm
--- a/roles/webserver-legacy/php-sites/files/rc/php-fpm
+++ b/roles/webserver-legacy/php-sites/files/rc/php-fpm
@@ -89,6 +89,7 @@
fi
command=${php_fpm_command}
+command_args="--fpm-config ${php_fpm_conf}"
pidfile="${php_fpm_pidfile}"
required_files="${php_fpm_conf}"
diff --git a/roles/webserver-legacy/php-sites/init.sls b/roles/webserver-legacy/php-sites/init.sls
--- a/roles/webserver-legacy/php-sites/init.sls
+++ b/roles/webserver-legacy/php-sites/init.sls
@@ -10,3 +10,4 @@
- .files
- .php
- .php-fpm
+ - .cleanup
diff --git a/roles/webserver-legacy/php-sites/php-fpm.sls b/roles/webserver-legacy/php-sites/php-fpm.sls
--- a/roles/webserver-legacy/php-sites/php-fpm.sls
+++ b/roles/webserver-legacy/php-sites/php-fpm.sls
@@ -34,7 +34,7 @@
php-fpm_pool_{{ site['user'] }}:
file.managed:
- - name: {{ dirs.etc }}/php-fpm.d/prod-pools/{{ site['user'] }}.conf
+ - name: {{ dirs.etc }}/php-fpm.d/{{ site['php-fpm'] }}-pools/{{ site['user'] }}.conf
- source: salt://roles/webserver-legacy/php-sites/files/php-fpm-pool.conf
- template: jinja
- context:
diff --git a/roles/webserver-legacy/php-sites/php.sls b/roles/webserver-legacy/php-sites/php.sls
--- a/roles/webserver-legacy/php-sites/php.sls
+++ b/roles/webserver-legacy/php-sites/php.sls
@@ -15,6 +15,12 @@
file.managed:
- source: salt://roles/webserver-legacy/php-sites/files/php.ini
+{% for build in pillar['php_custom_builds'] %}
+/opt/php/{{ build }}/lib/php.ini:
+ file.managed:
+ - source: salt://roles/webserver-legacy/php-sites/files/php.ini
+{% endfor %}
+
# -------------------------------------------------------------
# Sessions directories
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/utils/dump-py-state.py b/utils/dump-py-state.py
--- a/utils/dump-py-state.py
+++ b/utils/dump-py-state.py
@@ -12,6 +12,7 @@
import os
+import subprocess
import sys
import yaml
@@ -44,6 +45,16 @@
return pillar
+# -------------------------------------------------------------
+# Grains helper
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def system(args):
+ result = subprocess.run(args, stdout=subprocess.PIPE)
+ return result.stdout.decode('utf-8').strip()
+
+
# -------------------------------------------------------------
# Source code helper
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -81,4 +92,8 @@
exit(ex.errno)
__pillar__ = load_pillar("pillar")
+ __grains__ = {
+ 'os': system(["uname", "-o"])
+ }
+
exec(source_code)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 09:53 (9 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2252377
Default Alt Text
D1947.id4926.diff (4 KB)
Attached To
Mode
D1947: Deploy a legacy pool for PHP 5.6 applications in webserver-legacy role
Attached
Detach File
Event Timeline
Log In to Comment