chainetv/tasks/main.yml

76 lines
3.8 KiB
YAML
Raw 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:
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: "{{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
when: location_stat.stat.exists == false
- name: compile client source
shell: "/tmp/{{name}}/deploy_client.sh"
when: location_stat.stat.exists == false
- 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.
when: location_stat.stat.exists == false
delegate_to: "{{ inventory_hostname }}"
become: yes
- name:
file:
path: "/tmp/{{name}}"
state: absent
when: location_stat.stat.exists == false
- 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:
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