supysonic/tasks/main.yml

96 lines
5.1 KiB
YAML
Raw Normal View History

2019-05-13 17:00:10 +00:00
---
2020-01-13 19:04:49 +00:00
# tasks file for supysonic
2019-05-13 17:00:10 +00:00
2020-09-06 20:16:56 +00:00
- name: select specific Database tasks
include_tasks: "database_{{supysonic_DB_type}}.yml"
2019-05-13 17:00:10 +00:00
- name: stat location folder
stat:
2021-07-17 08:25:41 +00:00
path: "{{source_location}}/{{supysonic_name}}" # required. The full path of the file/object to get the facts of.
2019-05-13 17:00:10 +00:00
register: location_stat
- name: install source file if not exist
git:
2021-07-17 08:25:41 +00:00
dest: "{{source_location}}/{{supysonic_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: "{{supysonic_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: "{{supysonic_repo_branch}}"
2019-05-13 17:00:10 +00:00
become: yes
when: location_stat.stat.exists == false or supysonic_force_site_update == true
2019-08-18 15:34:44 +00:00
notify:
2019-11-17 16:12:24 +00:00
- restart supysonic service
2021-07-17 08:25:41 +00:00
2019-05-13 17:00:10 +00:00
- name: create folder in var
file:
path: "/var/{{supysonic_name}}" # required. Path to the file being managed.
state: directory # not required. choices: absent;directory;file;hard;link;touch. If C(directory), all intermediate subdirectories will be created if they do not exist. Since Ansible 1.7 they will be created with the supplied permissions. If C(file), the file will NOT be created if it does not exist; see the C(touch) value or the M(copy) or M(template) module if you want that behavior. If C(link), the symbolic link will be created or changed. Use C(hard) for hardlinks. If C(absent), directories will be recursively deleted, and files or symlinks will be unlinked. Note that C(absent) will not cause C(file) to fail if the C(path) does not exist as the state did not change. If C(touch) (new in 1.4), an empty file will be created if the C(path) does not exist, while an existing file or directory will receive updated file access and modification times (similar to the way `touch` works from the command line).
become: yes
- name: ensure venv folder exist
file:
name: "{{venv_location}}"
state: directory
mode: 0777
become: yes
- name: create venv
pip:
2021-07-17 08:25:41 +00:00
name: "file://{{source_location}}/{{supysonic_name}}"
2019-05-13 17:00:10 +00:00
virtualenv: "{{venv_location}}{{supysonic_venv_name}}"
virtualenv_command: /usr/bin/python -m venv
2021-07-17 08:25:41 +00:00
become: yes
2019-05-13 17:00:10 +00:00
- name: install sql client
pip:
virtualenv: "{{venv_location}}{{supysonic_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.
2021-07-17 08:25:41 +00:00
name:
- pymysql
2020-09-06 20:16:56 +00:00
- psycopg2
2021-07-17 08:25:41 +00:00
become: yes
2019-11-17 16:12:24 +00:00
- name: apply config template
2019-05-13 17:00:10 +00:00
template:
2021-07-17 08:25:41 +00:00
dest: "/etc/supysonic" # required. Location to render the template to on the remote machine.
src: "supysonic.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
2019-05-13 17:00:10 +00:00
become: yes
notify:
2019-11-17 16:12:24 +00:00
- restart supysonic service
- restart daemon service
2019-05-13 17:00:10 +00:00
- name: install gunicorn
2021-07-17 08:25:41 +00:00
become: yes
2019-05-13 17:00:10 +00:00
pip:
2019-11-17 16:12:24 +00:00
virtualenv: "{{venv_location}}{{supysonic_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).
2019-05-13 17:00:10 +00:00
- name: apply systemd service template
template:
2021-07-17 08:25:41 +00:00
dest: "/etc/systemd/system/gunicorn-{{supysonic_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.
2019-05-13 17:00:10 +00:00
become: yes
notify:
2019-11-17 16:12:24 +00:00
- Reload systemd
- restart supysonic service
- name: apply systemd daemon template
template:
2021-07-17 08:25:41 +00:00
dest: "/etc/systemd/system/{{supysonic_name}}-daemon.service" # required. Location to render the template to on the remote machine.
src: "systemd/supysonic-daemon.service.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
2019-11-17 16:12:24 +00:00
become: yes
notify:
- Reload systemd
- restart daemon service
2021-07-17 08:25:41 +00:00
- name: enable daemon service
2019-11-17 16:12:24 +00:00
systemd:
2020-01-13 19:04:49 +00:00
name: "{{supysonic_name}}-daemon.service" # not required. Name of the service. When using in a chroot environment you always need to specify the full name i.e. (crond.service).
2019-11-17 16:12:24 +00:00
enabled: true
2020-01-13 19:04:49 +00:00
state: started
2021-07-17 08:25:41 +00:00
become: yes
2019-05-14 08:24:24 +00:00
2021-07-17 08:25:41 +00:00
- name: enable supysonic service
2019-05-14 08:24:24 +00:00
systemd:
name: "gunicorn-{{supysonic_name}}.service" # not required. Name of the service. When using in a chroot environment you always need to specify the full name i.e. (crond.service).
enabled: true
2020-01-13 19:04:49 +00:00
state: started
2021-07-17 08:25:41 +00:00
become: yes