forked from cisti/infra
up1 role up&running
This commit is contained in:
parent
401a96010b
commit
8047bcb9d0
7 changed files with 116 additions and 36 deletions
|
@ -1,36 +0,0 @@
|
|||
---
|
||||
- name: Install lufi deps
|
||||
apt:
|
||||
pkg:
|
||||
git
|
||||
build-essential
|
||||
libssl-dev
|
||||
libio-socket-ssl-perl
|
||||
liblwp-protocol-https-perl
|
||||
zlib1g-dev
|
||||
|
||||
- name: Install Carton
|
||||
cpanm: name=Carton
|
||||
|
||||
- name: ensure lufi user is present
|
||||
user:
|
||||
name: "lufi"
|
||||
home: "/srv/lufi"
|
||||
shell: "/bin/bash"
|
||||
state: present
|
||||
|
||||
|
||||
- name: Clone lufi repo
|
||||
git:
|
||||
repo: git clone https://framagit.org/fiat-tux/hat-softwares/lufi.git
|
||||
dest: /srv/lufi/lufi
|
||||
become: true
|
||||
become_user: lufi
|
||||
|
||||
- name: Install lufi
|
||||
shell: carton install --deployment --without=test --without=postgresql --without=mysql
|
||||
args:
|
||||
chdir: /srv/lufi/lufi
|
||||
|
||||
|
||||
|
5
roles/up1/defaults/main.yml
Normal file
5
roles/up1/defaults/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
api_key: "{{lookup('password', './.pass/up1_api_key')}}"
|
||||
maximum_file_size: 500000000
|
||||
port: 31337
|
||||
footer: <a href="https://github.com/Upload/Up1" target="_blank">Source Code</a> - <a href="mailto:info@cisti.org" id="contact" target="_blank">Contact</a>
|
15
roles/up1/meta/main.yml
Normal file
15
roles/up1/meta/main.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
dependencies:
|
||||
|
||||
# install nodejs
|
||||
- role: nodejs
|
||||
|
||||
# install caddy and configure it as reverse proxy
|
||||
- role: caddy
|
||||
vars:
|
||||
caddy_config: |
|
||||
{{hostname}}
|
||||
encode gzip
|
||||
reverse_proxy /api/* 127.0.0.1:31337
|
||||
root * /srv/up1/up1/client
|
||||
file_server
|
53
roles/up1/tasks/main.yml
Normal file
53
roles/up1/tasks/main.yml
Normal file
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
|
||||
- name: ensure lufi user is present
|
||||
user:
|
||||
name: "up1"
|
||||
home: "/srv/up1"
|
||||
shell: "/bin/bash"
|
||||
state: present
|
||||
|
||||
- name: Clone up1 repo
|
||||
git:
|
||||
repo: https://github.com/Upload/Up1
|
||||
dest: /srv/up1/up1
|
||||
become: true
|
||||
become_user: up1
|
||||
|
||||
- name: copy server settings
|
||||
template:
|
||||
src: server.conf.j2
|
||||
dest: /srv/up1/up1/server/server.conf
|
||||
owner: up1
|
||||
group: up1
|
||||
mode: 0600
|
||||
|
||||
- name: copy client settings
|
||||
template:
|
||||
src: config.js.j2
|
||||
dest: /srv/up1/up1/client/config.js
|
||||
owner: up1
|
||||
group: up1
|
||||
mode: 0600
|
||||
|
||||
- name: Install up1 deps
|
||||
become: true
|
||||
become_user: up1
|
||||
npm:
|
||||
path: /srv/up1/up1/server
|
||||
|
||||
|
||||
- name: NODE | Install pm2
|
||||
npm:
|
||||
name: pm2
|
||||
global: yes
|
||||
production: yes
|
||||
state: present
|
||||
|
||||
- name: NODE | Start APP
|
||||
become: true
|
||||
become_user: up1
|
||||
shell: pm2 start server.js --name server
|
||||
args:
|
||||
chdir: /srv/up1/up1/server
|
||||
ignore_errors: yes
|
4
roles/up1/templates/config.js.j2
Normal file
4
roles/up1/templates/config.js.j2
Normal file
|
@ -0,0 +1,4 @@
|
|||
upload.config.server = '' // Empty if the webapp is in the same place as the server
|
||||
// upload.config.server = 'https://yourserver.com/' // If the webapp is separated from the server - remember the trailing slash
|
||||
upload.config.api_key = '{{ api_key }}' // Should be the same as the server, used for uploading
|
||||
upload.config.footer = '{{ footer }}'
|
29
roles/up1/templates/server.conf.j2
Normal file
29
roles/up1/templates/server.conf.j2
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"api_key": "{{ api_key }}",
|
||||
"delete_key": "",
|
||||
"maximum_file_size": {{ maximum_file_size }},
|
||||
|
||||
"path": {
|
||||
"i": "../i",
|
||||
"client": "../client"
|
||||
},
|
||||
|
||||
"http": {
|
||||
"enabled": true,
|
||||
"listen": "127.0.0.1:{{ port }}"
|
||||
},
|
||||
|
||||
"https": {
|
||||
"enabled": false,
|
||||
"listen": ":443",
|
||||
"cert": "./cert.pem",
|
||||
"key": "./key.pem"
|
||||
},
|
||||
|
||||
"cloudflare-cache-invalidate": {
|
||||
"enabled": false,
|
||||
"token": "Cloudflare API token here",
|
||||
"email": "Cloudflare login email here",
|
||||
"domain": "Domain to invalidate cache on"
|
||||
}
|
||||
}
|
10
up1.playbook.yml
Normal file
10
up1.playbook.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
|
||||
- name: "Testing up1 role"
|
||||
hosts: localhost
|
||||
become: true
|
||||
roles:
|
||||
- role: common
|
||||
- role: up1
|
||||
vars:
|
||||
hostname: :8000
|
Loading…
Reference in a new issue