Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
php5 fcgi example (salt state + template config file)
username: tony
fullname: Tony N
mysql-version: 5.5
mysql-root-pw: root
{%- if grains['os'] == 'MacOS' %}
etc_dir: /opt/local/etc/
var_dir: /opt/local/var/
logs_dir: /opt/local/var/log/
{%- else %}
etc_dir: /etc/
var_dir: /var/
logs_dir: /var/log/
{%- endif %}
www_dir: /srv/www/
include:
- webserver
- lang.php.composer
- www.nginx
- databases.mysql
- deploy.ssh_unfuddle
wengu_nginx:
file.recurse:
- name: {{ pillar['etc_dir'] }}nginx
- source: salt://projects/wengu/etc/nginx
- user: root
- group: root
- file_mode: 644
- dir_mode: 644
- makedirs: True
- template: jinja
- include_empty: True
- recurse:
- user
- group
- require:
- pkg: nginx
wengu_dir:
file.directory:
- name: {{ pillar['www_dir'] }}wengu
- user: www-data
- group: www-data
- mode: 775
- makedirs: True
- require:
- file: {{ pillar['www_dir'] }}
wengu_legacy:
git.latest:
- name: git@github.com:wengu/wengu-php.git
- target: {{ pillar['www_dir'] }}wengu/legacy
- require:
- file: wengu_dir
host.present:
- name: wengu
- ip: 127.0.0.1
file.symlink:
- name: {{ pillar['etc_dir'] }}nginx/sites-enabled/wengu/legacy.conf
- target: {{ pillar['etc_dir'] }}nginx/sites-available/wengu/legacy.conf
- require:
- file: wengu_nginx
mysql_database.present:
- name: wengu
- require:
- service: mysql-server
#- pkg: mysql-client
- file: /etc/salt/minion.d/mysql.conf
#- file: /etc/mysql
cmd.run:
- name: 'mysql -uroot -p"{{ pillar['mysql-root-pw'] }}" wengu < ./wengu.sql'
- cwd: {{ pillar['www_dir'] }}wengu/legacy/scripts
- only_if: echo '' | mysql -uroot -e "SHOW TABLES IN wengu"
- require:
- git: wengu_legacy
- mysql_database: wengu_legacy
- module.run: mysql-root
wengu_legacy_config:
file.symlink:
- name: {{ pillar['www_dir'] }}wengu/legacy/files/config/db.php
- target: {{ pillar['www_dir'] }}wengu/legacy/files/config/devel/db.php
- require:
- git: wengu_legacy
server {
listen 80;
server_name wengu;
access_log {{ pillar['logs_dir'] }}nginx/wengu.legacy.access.log;
error_log {{ pillar['logs_dir'] }}nginx/wengu.legacy.error.log;
root {{ pillar['www_dir'] }}wengu/legacy;
index wengu.php;
location / {
root {{ pillar['www_dir'] }}wengu/legacy;
index wengu.php;
if (-f $request_filename) {
# translated into "if the request is an existing file, break (do nothing)"
break;
}
if (-d $request_filename) {
# translated into "if the request is an existing directory, break (do nothing)"
break;
}
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index wengu.php;
fastcgi_param SCRIPT_FILENAME {{ pillar['www_dir'] }}wengu/legacy/$fastcgi_script_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment