ansible-role-openstreamingp.../tasks/main.yml

202 lines
4.1 KiB
YAML
Raw Normal View History

2020-11-12 11:41:52 +01:00
- name: Workaround ansible switch between users
file:
path: "/tmp/ansible/"
mode: 0777
state: directory
2020-11-12 11:41:52 +01:00
- name: Install dependencies
package:
name:
- redis
- ejabberd
#- gunicorn
#- uwsgi-plugin-python
- python-pip
- python-virtualenv
- ffmpeg #important v4
#- python-gevent-websocket
- base-devel
- yay
2020-11-14 11:38:04 +01:00
- python-requests # ejabberd auth
2020-11-12 11:41:52 +01:00
- name: Create AUR User for build
user:
name: aur_builder
- name: Add sudo permission to aur user
lineinfile:
path: /etc/sudoers.d/11-install-aur_builder
line: 'aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman'
create: yes
validate: 'visudo -cf %s'
- name: Install nginx with rtmp
become: yes
become_user: aur_builder
aur:
name: nginx-rtmp-sergey-git
- name: Configure redis
notify: restart redis
lineinfile:
path: /etc/redis.conf
regexp: '^appendfsync'
line: "appendfsync no"
- name: Start redis
systemd:
name: redis
state: started
enabled: yes
- name: Configure ejabberd
notify: restart ejabberd
template:
src: ejabberd.yml
dest: /etc/ejabberd/ejabberd.yml
- name: Start ejabberd
systemd:
name: ejabberd
state: started
enabled: yes
- name: Check if ejabberd account exists
become: yes
become_user: jabber
command: ejabberdctl check_account admin localhost
register: jabber_admin
changed_when: False
failed_when: 'jabber_admin.rc >= 2'
- name: Register ejabberd Adminuser
become: yes
become_user: jabber
when: jabber_admin.rc == 1
command: ejabberdctl register admin localhost "{{ osp_ejabberd_password }}"
- name: Set password of ejabber admin
become: yes
become_user: jabber
when: jabber_admin.rc == 0
command: ejabberdctl change_password admin localhost "{{ osp_ejabberd_password }}"
- name: Configure NGINX
notify: reload nginx
template:
src: "{{ item }}"
dest: "/etc/nginx/{{ item }}"
loop:
- nginx.conf
- osp-rtmp.conf
- osp-socketio.conf
- osp-redirects.conf
- name: Create www directory
file:
path: "{{osp_http_path }}/{{item}}"
2020-11-13 22:02:44 +01:00
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
2020-11-12 11:41:52 +01:00
state: directory
loop:
- .
- live
- videos
- live-rec
- images
- live-adapt
- stream-thumb
- name: Nginx
systemd:
name: nginx
state: started
enabled: yes
2020-11-13 22:02:44 +01:00
- name: Database
include_tasks: db_postgresql.yml
when: osp_db_type == "postgresql"
2020-11-12 11:41:52 +01:00
2020-11-20 18:05:07 +01:00
- name: Database
include_tasks: db_mysql.yml
when: osp_db_type == "mysql"
2020-11-12 11:41:52 +01:00
- name: Clone OSP repository
git:
repo: "{{ osp_git_root }}"
2020-11-12 22:02:15 +01:00
dest: "/opt/osp/"
2020-11-12 11:41:52 +01:00
version: "{{ osp_git_commit }}"
- name: Install python requirements
pip:
2020-11-12 22:02:15 +01:00
requirements: /opt/osp/setup/requirements.txt
2020-11-12 11:41:52 +01:00
virtualenv: /opt/osp-venv
- name: Create cache directory
file:
path: /var/cache/osp
2020-11-13 22:02:44 +01:00
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
2020-11-12 11:41:52 +01:00
state: directory
- name: Create logging directory
file:
path: /var/log/osp
2020-11-13 22:02:44 +01:00
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
2020-11-12 11:41:52 +01:00
state: directory
- name: Configure osp
notify: restart osp
template:
src: "config.py.dist"
dest: "/etc/osp.conf"
- name: Configure supply
notify: restart osp
file:
src: "/etc/osp.conf"
2020-11-12 22:02:15 +01:00
dest: "/opt/osp/conf/config.py"
2020-11-12 11:41:52 +01:00
state: link
- name: Create logging directory
file:
path: /opt/osp
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
recurse: yes
2020-11-12 11:41:52 +01:00
- name: Init Database
become: yes
become_user: http
2020-11-12 11:41:52 +01:00
command: python3 manage.py db init
args:
2020-11-12 22:02:15 +01:00
chdir: /opt/osp/
2020-11-13 22:02:44 +01:00
creates: /opt/osp/migrations
environment:
VIRTUAL_ENV: /opt/osp-venv
PATH: /opt/osp-venv/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
- name: Permissions for database
file:
path: "/opt/osp/db"
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
recurse: yes
2020-11-12 11:41:52 +01:00
- name: Install services files and workers
notify: restart osp
template:
src: "{{item}}"
dest: "/etc/systemd/system/{{item}}"
loop:
- osp-worker@.service
- osp.target
- name: Start OSP
systemd:
name: osp.target
state: started
enabled: yes