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

197 lines
4.0 KiB
YAML

- name: Workaround ansible switch between users
file:
path: "/tmp/ansible/"
mode: 0777
state: directory
- name: Install dependencies
package:
name:
- redis
- ejabberd
#- gunicorn
#- uwsgi-plugin-python
- python-pip
- python-virtualenv
- ffmpeg #important v4
#- python-gevent-websocket
- base-devel
- yay
- 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}}"
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
state: directory
loop:
- .
- live
- videos
- live-rec
- images
- live-adapt
- stream-thumb
- name: Nginx
systemd:
name: nginx
state: started
enabled: yes
- name: Database
include_tasks: db_postgresql.yml
when: osp_db_type == "postgresql"
- name: Clone OSP repository
git:
repo: "{{ osp_git_root }}"
dest: "/opt/osp/"
version: "{{ osp_git_commit }}"
- name: Install python requirements
pip:
requirements: /opt/osp/setup/requirements.txt
virtualenv: /opt/osp-venv
- name: Create cache directory
file:
path: /var/cache/osp
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
state: directory
- name: Create logging directory
file:
path: /var/log/osp
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
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"
dest: "/opt/osp/conf/config.py"
state: link
- name: Create logging directory
file:
path: /opt/osp
owner: "{{ osp_http_user }}"
group: "{{ osp_http_group }}"
recurse: yes
- name: Init Database
become: yes
become_user: http
command: python3 manage.py db init
args:
chdir: /opt/osp/
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
- 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