5 changed files with 89 additions and 10 deletions
@ -1,28 +1,27 @@ |
|||||||
--- |
--- |
||||||
- hosts: lxd_host |
- hosts: lxd_host |
||||||
tags: container_install |
tags: container_install |
||||||
roles: |
roles: [lxd_host] |
||||||
- lxd_host |
|
||||||
|
|
||||||
- hosts: haproxy |
- hosts: haproxy |
||||||
tags: containers, haproxy |
tags: containers, haproxy |
||||||
roles: |
roles: [haproxy] |
||||||
- haproxy |
|
||||||
|
|
||||||
- hosts: |
- hosts: |
||||||
- dokuwiki |
- dokuwiki |
||||||
- freshrss |
- freshrss |
||||||
- gitweb |
- gitweb |
||||||
tags: containers, webserver |
tags: containers, webserver |
||||||
roles: |
roles: [webserver] |
||||||
- webserver |
|
||||||
|
|
||||||
- hosts: freshrss |
- hosts: freshrss |
||||||
tags: containers, freshrss |
tags: containers, freshrss |
||||||
roles: |
roles: [freshrss] |
||||||
- freshrss |
|
||||||
|
|
||||||
- hosts: dokuwiki |
- hosts: dokuwiki |
||||||
tags: containers, dokuwiki |
tags: containers, dokuwiki |
||||||
roles: |
roles: [dokuwiki] |
||||||
- dokuwiki |
|
||||||
|
- hosts: gallery |
||||||
|
tags: containers, gallery |
||||||
|
roles: [flask] |
||||||
|
|||||||
@ -0,0 +1,54 @@ |
|||||||
|
--- |
||||||
|
- name: install packages |
||||||
|
apk: |
||||||
|
name: |
||||||
|
- lighttpd |
||||||
|
- py3-flask |
||||||
|
- py3-gunicorn |
||||||
|
state: installed |
||||||
|
|
||||||
|
- vars: |
||||||
|
web_user: lighttpd |
||||||
|
web_group: lighttpd |
||||||
|
docroot: /var/www/localhost/htdocs |
||||||
|
flask_entry: app.py |
||||||
|
lighttpd_conf: /etc/lighttpd/lighttpd.conf |
||||||
|
proxy_port: 3031 |
||||||
|
|
||||||
|
block: |
||||||
|
- name: add mod_proxy.conf include to lighttpd.conf |
||||||
|
lineinfile: |
||||||
|
path: "{{ lighttpd_conf }}" |
||||||
|
line: 'include "mod_proxy.conf"' |
||||||
|
insertafter: "{{ '# {{{ includes' }}" |
||||||
|
|
||||||
|
- name: copy mod_proxy.conf template |
||||||
|
template: |
||||||
|
src: templates/mod_proxy.conf.j2 |
||||||
|
dest: /etc/lighttpd/mod_proxy.conf |
||||||
|
|
||||||
|
- name: copy dummy app template |
||||||
|
template: |
||||||
|
src: "templates/{{ flask_entry }}.j2" |
||||||
|
dest: "{{ docroot }}/{{ flask_entry }}" |
||||||
|
mode: 0644 |
||||||
|
owner: "{{ web_user }}" |
||||||
|
group: "{{ web_group }}" |
||||||
|
|
||||||
|
- name: copy gunicorn-flask openrc init script |
||||||
|
template: |
||||||
|
src: "templates/flask_init.j2" |
||||||
|
dest: "/etc/init.d/flask" |
||||||
|
mode: 0755 |
||||||
|
|
||||||
|
- name: start and enable custom flask service |
||||||
|
service: |
||||||
|
name: flask |
||||||
|
enabled: yes |
||||||
|
state: restarted |
||||||
|
|
||||||
|
- name: start and enable lighttpd service |
||||||
|
service: |
||||||
|
name: lighttpd |
||||||
|
enabled: yes |
||||||
|
state: restarted |
||||||
@ -0,0 +1,9 @@ |
|||||||
|
|
||||||
|
from flask import Flask |
||||||
|
app = Flask(__name__) |
||||||
|
|
||||||
|
@app.route("/{{ ansible_facts['hostname'] }}") |
||||||
|
@app.route("/{{ ansible_facts['hostname'] }}/") |
||||||
|
def hello_world(): |
||||||
|
return 'Hello World!' |
||||||
|
|
||||||
@ -0,0 +1,8 @@ |
|||||||
|
#!/sbin/openrc-run |
||||||
|
|
||||||
|
command="/usr/bin/gunicorn" |
||||||
|
pidfile="/run/${RC_SVCNAME}.pid" |
||||||
|
command_args="-w 4 -b 127.0.0.1:{{ proxy_port }} --chdir {{ docroot }} \ |
||||||
|
-u {{ web_user }} -g {{ web_group }} app:app" |
||||||
|
command_args_background="--daemon -p ${pidfile}" |
||||||
|
|
||||||
Loading…
Reference in new issue