77 lines
4.0 KiB
YAML
77 lines
4.0 KiB
YAML
---
|
|
# tasks file for chainetv
|
|
- name: stat location folder
|
|
stat:
|
|
path: "{{source_location}}/dist" # required. The full path of the file/object to get the facts of.
|
|
register: location_stat
|
|
|
|
- name: install source file if not exist
|
|
git:
|
|
accept_hostkey: yes
|
|
dest: "/tmp/{{name}}" # required. The path of where the repository should be checked out. This parameter is required, unless C(clone) is set to C(no).
|
|
repo: "{{chainetv_repo}}" # required. git, SSH, or HTTP(S) protocol address of the git repository.
|
|
clone: yes # not required. If C(no), do not clone the repository if it does not exist locally
|
|
version: "{{chainetv_repo_branch}}"
|
|
when: location_stat.stat.exists == false or force_site_update == true
|
|
|
|
- name: copy source
|
|
synchronize:
|
|
dest: "{{source_location}}" # required. Remote absolute path where the file should be copied to. If I(src) is a directory, this must be a directory too. If I(dest) is a nonexistent path and if either I(dest) ends with "/" or I(src) is a directory, I(dest) is created. If I(src) and I(dest) are files, the parent directory of I(dest) isn't created: the task fails if it doesn't already exist.
|
|
src: "/tmp/{{name}}/{{backendfolder}}/" # not required. Local path to a file to copy to the remote server; can be absolute or relative. If path is a directory, it is copied recursively. In this case, if path ends with "/", only inside contents of that directory are copied to destination. Otherwise, if it does not end with "/", the directory itself with all contents is copied. This behavior is similar to Rsync.
|
|
delete: true
|
|
when: location_stat.stat.exists == false or force_site_update == true
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
become: yes
|
|
notify:
|
|
- restart nginx
|
|
- restart service
|
|
- name: check that temp folder is absent
|
|
file:
|
|
path: "/tmp/{{name}}"
|
|
state: absent
|
|
when: location_stat.stat.exists == false or force_site_update == true
|
|
|
|
- name: ensure venv folder exist
|
|
file:
|
|
name: "{{venv_location}}"
|
|
state: directory
|
|
mode: 0777
|
|
become: yes
|
|
|
|
- name: create venv
|
|
pip:
|
|
requirements: "{{source_location}}/requirements.txt"
|
|
virtualenv: "{{venv_location}}{{venv_name}}"
|
|
virtualenv_command: /usr/bin/python -m venv
|
|
|
|
|
|
- name: install gunicorn
|
|
pip:
|
|
virtualenv: "{{venv_location}}{{venv_name}}" # not required. An optional path to a I(virtualenv) directory to install into. It cannot be specified together with the 'executable' parameter (added in 2.1). If the virtualenv does not exist, it will be created before installing packages. The optional virtualenv_site_packages, virtualenv_command, and virtualenv_python options affect the creation of the virtualenv.
|
|
name: gunicorn # not required. The name of a Python library to install or the url(bzr+,hg+,git+,svn+) of the remote package.,This can be a list (since 2.2) and contain version specifiers (since 2.7).
|
|
|
|
|
|
- name: apply nginx template
|
|
template:
|
|
dest: "/etc/nginx/conf.d/{{name}}.default" # required. Location to render the template to on the remote machine.
|
|
src: "nginx/{{name}}.default.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
|
|
become: yes
|
|
notify: restart nginx
|
|
|
|
- name: apply systemd socket template
|
|
template:
|
|
dest: "/etc/systemd/system/gunicorn-{{name}}.socket" # required. Location to render the template to on the remote machine.
|
|
src: "systemd/gunicorn.socket.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
|
|
become: yes
|
|
notify:
|
|
- Reload systemd
|
|
- ensure socket is start
|
|
|
|
- name: apply systemd service template
|
|
template:
|
|
dest: "/etc/systemd/system/gunicorn-{{name}}.service" # required. Location to render the template to on the remote machine.
|
|
src: "systemd/gunicorn.service.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
|
|
become: yes
|
|
notify:
|
|
- Reload systemd
|
|
- restart service |