From 02715055b760aa2cfdc4401cb0edf4c254c39c9f Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Tue, 7 Dec 2021 13:48:39 -0500 Subject: [PATCH] move gallery install tasks to new file --- roles/gallery/tasks/install.yml | 72 +++++++++++++++++++++++++++++++ roles/gallery/tasks/main.yml | 76 ++------------------------------- 2 files changed, 75 insertions(+), 73 deletions(-) create mode 100644 roles/gallery/tasks/install.yml diff --git a/roles/gallery/tasks/install.yml b/roles/gallery/tasks/install.yml new file mode 100644 index 0000000..16ec012 --- /dev/null +++ b/roles/gallery/tasks/install.yml @@ -0,0 +1,72 @@ +--- +- 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 + +- name: test if gallery is already installed + find: + paths: "{{ folder }}" + pattern: README + register: check_installed + +- set_fact: + install_gallery: "{{ check_installed.matched == 0 }}" + +- name: install block + when: install_gallery + 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/tasks/main.yml b/roles/gallery/tasks/main.yml index c66ea7e..5af6e97 100644 --- a/roles/gallery/tasks/main.yml +++ b/roles/gallery/tasks/main.yml @@ -1,21 +1,7 @@ --- -- 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: +- name: install gallery + import_tasks: install.yml + vars: git_repo: "https://gitlab.com/cinnaboot/gallery.git" docroot: /var/www/localhost/htdocs folder: '{{ docroot }}/gallery' @@ -23,59 +9,3 @@ web_user: lighttpd web_group: lighttpd proxy_port: 3031 - block: - - name: test if gallery is already installed - find: - paths: "{{ folder }}" - pattern: README - register: check_installed - - - set_fact: - install_gallery: "{{ check_installed.matched == 0 }}" - - - name: install block - when: install_gallery - 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 -