chainetv/tasks/main.yml

77 lines
4.0 KiB
YAML
Raw Permalink Normal View History

2019-04-25 19:59:52 +00:00
---
# tasks file for chainetv
2019-04-26 12:04:48 +00:00
- 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:
2020-03-02 20:59:21 +00:00
accept_hostkey: yes
2019-04-26 12:04:48 +00:00
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).
2020-01-19 12:41:09 +00:00
repo: "{{chainetv_repo}}" # required. git, SSH, or HTTP(S) protocol address of the git repository.
2019-04-26 12:04:48 +00:00
clone: yes # not required. If C(no), do not clone the repository if it does not exist locally
2019-04-29 14:45:31 +00:00
version: "{{chainetv_repo_branch}}"
2019-04-26 12:19:42 +00:00
when: location_stat.stat.exists == false or force_site_update == true
2019-04-26 12:04:48 +00:00
- 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.
2019-04-29 15:09:21 +00:00
delete: true
2019-04-26 12:19:42 +00:00
when: location_stat.stat.exists == false or force_site_update == true
2019-04-26 12:04:48 +00:00
delegate_to: "{{ inventory_hostname }}"
become: yes
2019-04-29 14:45:31 +00:00
notify:
- restart nginx
- restart service
2020-01-29 20:58:09 +00:00
- name: check that temp folder is absent
2019-04-26 12:04:48 +00:00
file:
path: "/tmp/{{name}}"
state: absent
2019-04-26 12:19:42 +00:00
when: location_stat.stat.exists == false or force_site_update == true
2019-04-26 12:04:48 +00:00
- name: ensure venv folder exist
file:
name: "{{venv_location}}"
state: directory
mode: 0777
2019-04-25 19:59:52 +00:00
become: yes
2019-04-26 12:04:48 +00:00
- name: create venv
pip:
2020-01-29 20:58:09 +00:00
requirements: "{{source_location}}/requirements.txt"
virtualenv: "{{venv_location}}{{venv_name}}"
virtualenv_command: /usr/bin/python -m venv
2019-04-26 12:04:48 +00:00
- 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
2019-04-26 12:19:42 +00:00
- restart service