You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
2.6 KiB
141 lines
2.6 KiB
- name: set cdr_cfg
|
|
set_fact:
|
|
cdr_cfg: "{{ cdr_default_config | d({}) | combine(cdr_config | d({}), recursive=true) }}"
|
|
|
|
|
|
- name: install dependencies
|
|
include_tasks: tasks/install_packages.yml
|
|
vars:
|
|
package:
|
|
- nodejs
|
|
- npm
|
|
|
|
|
|
- name: add extra cname record
|
|
include_role:
|
|
name: ns
|
|
vars:
|
|
function: add_records
|
|
ns_add_default_record: no
|
|
ns_records:
|
|
- name: cdr
|
|
type: CNAME
|
|
value: "{{ host_fqdn }}"
|
|
when: "inventory_hostname != 'cdr'"
|
|
|
|
|
|
- name: create user and group
|
|
include_tasks: tasks/create_user.yml
|
|
vars:
|
|
user:
|
|
name: "{{ cdr_user }}"
|
|
group: "{{ cdr_group }}"
|
|
dir: "{{ cdr_dir }}"
|
|
notify: restart cdr
|
|
|
|
|
|
- name: ensure cdr dir exists
|
|
file:
|
|
path: "{{ cdr_dir }}"
|
|
state: directory
|
|
owner: "{{ cdr_user }}"
|
|
group: "{{ cdr_group }}"
|
|
|
|
|
|
- name: ensure recordings dir exists
|
|
file:
|
|
path: "{{ cdr_cfg.record_dir }}"
|
|
state: directory
|
|
|
|
|
|
- name: get source-mark status
|
|
stat:
|
|
path: "{{ cdr_dir }}/source-mark"
|
|
register: source_mark
|
|
|
|
|
|
- name: pause if source-mark is missing
|
|
pause:
|
|
prompt: source-mark is missing, source code has to be manually uploaded
|
|
when: source_mark.stat.exists == false
|
|
|
|
|
|
- name: create source-mark
|
|
file:
|
|
path: "{{ cdr_dir }}/source-mark"
|
|
state: touch
|
|
modification_time: preserve
|
|
access_time: preserve
|
|
|
|
|
|
- name: template env file
|
|
template:
|
|
src: env.j2
|
|
dest: "{{ cdr_dir }}/.env"
|
|
force: yes
|
|
owner: "{{ cdr_user }}"
|
|
group: "{{ cdr_group }}"
|
|
lstrip_blocks: yes
|
|
notify: restart cdr
|
|
|
|
|
|
- name: ensure app script has executable bit set
|
|
file:
|
|
path: "{{ cdr_dir }}/app.js"
|
|
mode: "+x"
|
|
|
|
|
|
- name: install npm dependencies
|
|
npm:
|
|
path: "{{ cdr_dir }}"
|
|
no_optional: yes
|
|
ignore_scripts: yes
|
|
production: yes
|
|
become: yes
|
|
become_user: "{{ cdr_user }}"
|
|
become_method: su
|
|
become_flags: '-s /bin/ash'
|
|
notify: restart cdr
|
|
changed_when: no
|
|
|
|
|
|
- name: template init script
|
|
template:
|
|
src: init.j2
|
|
dest: /etc/init.d/cdr
|
|
force: yes
|
|
mode: "+x"
|
|
notify: restart cdr
|
|
|
|
|
|
- name: install and configure nginx
|
|
include_role:
|
|
name: nginx
|
|
vars:
|
|
nginx:
|
|
servers:
|
|
- conf: nginx_server
|
|
override_server_name: cdr
|
|
certs: "{{ host_tls }}"
|
|
domains:
|
|
- "cdr.{{ host_tld }}"
|
|
|
|
|
|
- name: flush handlers
|
|
meta: flush_handlers
|
|
|
|
|
|
- name: add directories to backup plan
|
|
include_role:
|
|
name: backup
|
|
vars:
|
|
function: add
|
|
backup_items:
|
|
- "{{ cdr_dir }}"
|
|
|
|
|
|
- name: enable and start cdr
|
|
service:
|
|
name: cdr
|
|
enabled: yes
|
|
state: started
|
|
|