Added laradev state and bbs server
This commit is contained in:
parent
88f233134d
commit
ba8201f6a9
17 changed files with 2163 additions and 0 deletions
|
@ -9,3 +9,4 @@ include:
|
||||||
- roles.ca
|
- roles.ca
|
||||||
- roles.database
|
- roles.database
|
||||||
- roles.services
|
- roles.services
|
||||||
|
- roles.laradev
|
||||||
|
|
5
pillars/roles/laradev/bbs.sls
Normal file
5
pillars/roles/laradev/bbs.sls
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
laradev:
|
||||||
|
bbs:
|
||||||
|
repo: "https://git.actcur.com/bowens/web.git"
|
||||||
|
path: "/usr/share/webapps/bbs"
|
||||||
|
prefix: ""
|
13
pillars/roles/laradev/init.sls
Normal file
13
pillars/roles/laradev/init.sls
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{% set states = salt['cp.list_states'](saltenv) %}
|
||||||
|
include:
|
||||||
|
- roles.laradev.none
|
||||||
|
|
||||||
|
{%- if grains['roles'] is defined -%}
|
||||||
|
{%- if grains['roles'] is not none -%}
|
||||||
|
{%- for role in grains['roles'] %}
|
||||||
|
{%- if 'pillars.roles.laradev.'+role in states %}
|
||||||
|
- roles.laradev.{{ role }}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endif -%}
|
0
pillars/roles/laradev/none.sls
Normal file
0
pillars/roles/laradev/none.sls
Normal file
13
pillars/roles/nginx/bbs.sls
Normal file
13
pillars/roles/nginx/bbs.sls
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
nginx:
|
||||||
|
bbs:
|
||||||
|
auth: none
|
||||||
|
https:
|
||||||
|
port: 8000
|
||||||
|
prot: http
|
||||||
|
|
||||||
|
portal:
|
||||||
|
Dev:
|
||||||
|
bbs:
|
||||||
|
name: BBS Web Site - Dev
|
||||||
|
summary: New Bowens Bus Service web site
|
||||||
|
public: false
|
1
pillars/servers/env/server/bbs.sls
vendored
Normal file
1
pillars/servers/env/server/bbs.sls
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
env: prod
|
1
pillars/servers/env/server/project.sls
vendored
Normal file
1
pillars/servers/env/server/project.sls
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
env: prod
|
3
pillars/servers/maintainer/server/bbs.sls
Normal file
3
pillars/servers/maintainer/server/bbs.sls
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
maintainer:
|
||||||
|
- masaufuku
|
||||||
|
|
3
pillars/servers/maintainer/server/project.sls
Normal file
3
pillars/servers/maintainer/server/project.sls
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
maintainer:
|
||||||
|
- masaufuku
|
||||||
|
|
9
pillars/servers/roles/server/bbs.sls
Normal file
9
pillars/servers/roles/server/bbs.sls
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
grains:
|
||||||
|
roles:
|
||||||
|
- server
|
||||||
|
- ssh
|
||||||
|
- nrpe
|
||||||
|
- saltminion
|
||||||
|
- laradev
|
||||||
|
- bbs
|
||||||
|
- nginx-proxy
|
6
pillars/servers/roles/server/project.sls
Normal file
6
pillars/servers/roles/server/project.sls
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
grains:
|
||||||
|
roles:
|
||||||
|
- server
|
||||||
|
- ssh
|
||||||
|
- nrpe
|
||||||
|
- saltminion
|
10
states/roles/maintain/laradev/git_branches.service
Normal file
10
states/roles/maintain/laradev/git_branches.service
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Fetches all branches for specific projects
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=no
|
||||||
|
ExecStart=/bin/bash /root/scripts/git_branches.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
31
states/roles/maintain/laradev/git_branches.sh
Normal file
31
states/roles/maintain/laradev/git_branches.sh
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
mkdir -p "/usr/share/webapps/laradev"
|
||||||
|
chown http:http /srv/http
|
||||||
|
{% if pillar['laradev'] is defined %}
|
||||||
|
{%- for project in pillar['laradev'] %}
|
||||||
|
{%- set repo = pillar['laradev'][project]['repo'] -%}
|
||||||
|
{%- set path = pillar['laradev'][project]['path'] -%}
|
||||||
|
{%- set prefix = pillar['laradev'][project]['prefix'] -%}
|
||||||
|
mkdir -p "{{ path }}"
|
||||||
|
branches=`git ls-remote {{repo}} | grep -o -P "(?<=refs/heads/).*"`
|
||||||
|
for branch in $branches; do
|
||||||
|
#clone new branch if necessary
|
||||||
|
if [ ! -d "{{path}}/$branch" ];then
|
||||||
|
git clone -b $branch {{ repo }} "{{path}}/$branch"
|
||||||
|
ln -s "{{path}}/$branch/public" "/usr/share/webapps/laradev/{{prefix}}$branch"
|
||||||
|
chown http:http -R "{{path}}/$branch"
|
||||||
|
cd "{{path}}/$branch"
|
||||||
|
su -s /bin/bash http -c "composer install"
|
||||||
|
cp .env.example .env
|
||||||
|
sed -i "s/DB_DATABASE=homestead/DB_DATABASE=laradev_$prefix$branch/" .env
|
||||||
|
sed -i "s/DB_USERNAME=homestead/DB_USERNAME=laradev/" .env
|
||||||
|
php artisan key:generate
|
||||||
|
fi
|
||||||
|
#update to latest commit, dropping all local changes
|
||||||
|
cd "{{path}}/$branch"
|
||||||
|
git fetch --all
|
||||||
|
git reset --hard origin/$branch
|
||||||
|
php artisan migrate
|
||||||
|
chown http:http -R "{{path}}/$branch"
|
||||||
|
done
|
||||||
|
{%- endfor -%}
|
||||||
|
{% endif %}
|
9
states/roles/maintain/laradev/git_branches.timer
Normal file
9
states/roles/maintain/laradev/git_branches.timer
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Runs git_branches every 10 seconds
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*:*:0/10
|
||||||
|
Unit=git_branches.service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
84
states/roles/maintain/laradev/init.sls
Normal file
84
states/roles/maintain/laradev/init.sls
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
laradev-php:
|
||||||
|
pkg.installed:
|
||||||
|
- name: php
|
||||||
|
laradev-composer:
|
||||||
|
pkg.installed:
|
||||||
|
- name: composer
|
||||||
|
laradev-php-fpm:
|
||||||
|
pkg.installed:
|
||||||
|
- name: php-fpm
|
||||||
|
service.running:
|
||||||
|
- name: php-fpm
|
||||||
|
- enable: true
|
||||||
|
- watch:
|
||||||
|
- file: /etc/php/php.ini
|
||||||
|
|
||||||
|
laradev-mysql:
|
||||||
|
pkg.installed:
|
||||||
|
- name: mariadb
|
||||||
|
laradev-mysql-python:
|
||||||
|
pkg.installed:
|
||||||
|
- name: mysql-python
|
||||||
|
laradev-init-mysql:
|
||||||
|
cmd.run:
|
||||||
|
- name: mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
|
||||||
|
- unless: 'test -e /var/lib/mysql/mysql'
|
||||||
|
laradev-mysql-service:
|
||||||
|
service.running:
|
||||||
|
- name: mysqld
|
||||||
|
- enable: true
|
||||||
|
|
||||||
|
#create laradev user
|
||||||
|
laradev-user:
|
||||||
|
mysql_user.present:
|
||||||
|
- name: laradev
|
||||||
|
- host: "localhost"
|
||||||
|
- password: "secret"
|
||||||
|
- connection_user: root
|
||||||
|
|
||||||
|
/etc/nginx/conf.d/laradev.conf:
|
||||||
|
file.managed:
|
||||||
|
- source: salt://roles/maintain/laradev/nginx.conf
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
- makedirs: true
|
||||||
|
- template: jinja
|
||||||
|
/etc/php/php.ini:
|
||||||
|
file.managed:
|
||||||
|
- source: salt://roles/maintain/laradev/php.ini
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
|
||||||
|
/root/scripts/git_branches.sh:
|
||||||
|
file.managed:
|
||||||
|
- source: salt://roles/maintain/laradev/git_branches.sh
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
- template: jinja
|
||||||
|
|
||||||
|
"/lib/systemd/system/git_branches.service":
|
||||||
|
file.managed:
|
||||||
|
- source: salt://roles/maintain/laradev/git_branches.service
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
|
||||||
|
"/lib/systemd/system/git_branches.timer":
|
||||||
|
file.managed:
|
||||||
|
- source: salt://roles/maintain/laradev/git_branches.timer
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
|
||||||
|
"git_branches-reload":
|
||||||
|
module.run:
|
||||||
|
- name: service.systemctl_reload
|
||||||
|
- onchanges:
|
||||||
|
- file: /lib/systemd/system/*
|
||||||
|
|
||||||
|
"git_branches.timer":
|
||||||
|
service.running:
|
||||||
|
- enable: true
|
44
states/roles/maintain/laradev/nginx.conf
Normal file
44
states/roles/maintain/laradev/nginx.conf
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
server {
|
||||||
|
listen *:8000;
|
||||||
|
server_name {{ grains['fqdn'] }};
|
||||||
|
|
||||||
|
root /usr/share/webapps/laradev; #Path of laradev symlink directory - should contain symlinks to public folder for each branch of the project
|
||||||
|
index index.php;
|
||||||
|
access_log /var/log/nginx/laradev_access.log;
|
||||||
|
error_log /var/log/nginx/laradev_error.log;
|
||||||
|
|
||||||
|
location = /favicon.ico {
|
||||||
|
log_not_found off;
|
||||||
|
access_log off;
|
||||||
|
expires max;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\. {
|
||||||
|
deny all;
|
||||||
|
access_log off;
|
||||||
|
log_not_found off;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \..*/.*\.php$ {
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!-d $request_filename) {
|
||||||
|
rewrite ^/(.+)/$ /$1 permanent;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $1 $uri $uri/ /index.php$is_args$args;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/(.*)/index\.php(.*)$ {
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include /etc/nginx/fastcgi_params;
|
||||||
|
try_files $uri =404;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
|
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
|
||||||
|
fastcgi_param SCRIPT_FILENAME /usr/share/webapps/laradev/$1/index.php;
|
||||||
|
fastcgi_param LARADEV_CONFIGDIR /etc/laradev; #Not strictly needed
|
||||||
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
|
}
|
||||||
|
}
|
1930
states/roles/maintain/laradev/php.ini
Normal file
1930
states/roles/maintain/laradev/php.ini
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue