diff --git a/all.yml b/all.yml index 73052c3..0ba329d 100644 --- a/all.yml +++ b/all.yml @@ -23,7 +23,7 @@ - hosts: gallery tags: containers, gallery - roles: [flask] + roles: [gallery] - hosts: gitweb tags: containers, gitweb diff --git a/roles/gallery/tasks/main.yml b/roles/gallery/tasks/main.yml new file mode 100644 index 0000000..951d81e --- /dev/null +++ b/roles/gallery/tasks/main.yml @@ -0,0 +1,69 @@ +--- +- name: install packages + apk: + name: + - build-base + - git + - jpeg-dev + - lighttpd + - python3-dev + - py3-pip + - py3-setuptools + - py3-virtualenv + - uwsgi + - uwsgi-python3 + - zlib-dev + state: installed + +- vars: + git_repo: "https://gitlab.com/cinnaboot/gallery.git" + docroot: /var/www/localhost/htdocs + folder: '{{ docroot }}/gallery' + flask_entry: gallery + web_user: lighttpd + web_group: lighttpd + proxy_port: 3031 + block: + - name: add mod_scgi.conf include to lighttpd.conf + lineinfile: + path: /etc/lighttpd/lighttpd.conf + line: 'include "mod_scgi.conf"' + insertafter: "{{ '# {{{ includes' }}" + + - name: copy mod_scgi.conf template + template: + src: templates/mod_scgi.conf.j2 + dest: /etc/lighttpd/mod_scgi.conf + + - name: copy uwsgi config + template: + src: "templates/gallery.ini.j2" + dest: "/etc/uwsgi/conf.d/gallery.ini" + owner: uwsgi + group: uwsgi + + - name: clone application repo + git: + repo: '{{ git_repo }}' + dest: '{{ folder }}' + + - name: install application dependencies + pip: + virtualenv: '{{ folder }}/venv' + requirements: '{{ folder }}/requirements.txt' + + - name: chown application to uwsgi user + command: 'chown -R uwsgi:uwsgi {{ folder }}' + + - name: start and enable lighttpd service + service: + name: lighttpd + state: restarted + enabled: yes + + - name: start and enable uwsgi service + service: + name: uwsgi + state: restarted + enabled: yes + diff --git a/roles/gallery/templates/gallery.ini.j2 b/roles/gallery/templates/gallery.ini.j2 new file mode 100644 index 0000000..d2ee904 --- /dev/null +++ b/roles/gallery/templates/gallery.ini.j2 @@ -0,0 +1,12 @@ + +[uwsgi] +socket = 127.0.0.1:3031 +plugins = python3 +chdir = /var/www/localhost/htdocs/gallery +wsgi-file = wsgi.py +callable = app +venv = /var/www/localhost/htdocs/gallery/venv + +#touch-reload = /var/www/localhost/htdocs/pvdb/instance/reload +#static-map = /movie_dir=/var/www/localhost/htdocs/pvdb/instance/movie_dir +#py-auto-reload = 1 diff --git a/roles/gallery/templates/mod_scgi.conf.j2 b/roles/gallery/templates/mod_scgi.conf.j2 new file mode 100644 index 0000000..296a8b9 --- /dev/null +++ b/roles/gallery/templates/mod_scgi.conf.j2 @@ -0,0 +1,8 @@ + +server.modules += ( "mod_scgi" ) +scgi.protocol = "uwsgi" +scgi.server = ( + "/gallery" => (( "host" => "127.0.0.1", "port" => 3031, "check-local" => "disable" )), +) +#alias.url += ( "/image_cache" => "/var/www/localhost/htdocs/pvdb/instance/image_cache" ) +