Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
9bb9ebfcce | |||
1c902b5a90 | |||
288a23b412 |
12
roles/freepbx/defaults/main.yml
Normal file
12
roles/freepbx/defaults/main.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
deploy_key_file: /root/.ssh/id_git_deploy_rsa
|
||||||
|
|
||||||
|
asterisk_user: asterisk
|
||||||
|
asterisk_group: asterisk
|
||||||
|
|
||||||
|
repo_provisioning: gogs@git.binary-kitchen.de:noby/voip-yealink-provisioning.git
|
||||||
|
repo_utilities: gogs@git.binary-kitchen.de:noby/voip-yealink-xml-browser.git
|
||||||
|
|
||||||
|
path_yealink_provisioning: /tftpboot/yealink
|
||||||
|
path_yealink_utilities: /opt/yealink_utilities
|
10
roles/freepbx/handlers/main.yml
Normal file
10
roles/freepbx/handlers/main.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Reload systemd
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Restart yealink-utilities
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: yealink-utilities
|
||||||
|
state: restarted
|
8
roles/freepbx/meta/main.yml
Normal file
8
roles/freepbx/meta/main.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: Thomas Basler
|
||||||
|
description: Install FreePBX extensions
|
||||||
|
license: None
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
min_ansible_version: "2.4"
|
20
roles/freepbx/tasks/main.yml
Normal file
20
roles/freepbx/tasks/main.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Generate an OpenSSH keypair for gitea deploy usage
|
||||||
|
community.crypto.openssh_keypair:
|
||||||
|
path: "{{ deploy_key_file }}"
|
||||||
|
|
||||||
|
- name: Wait for confirmation
|
||||||
|
ansible.builtin.pause:
|
||||||
|
prompt: Please confirm that you've distributed the public key to all repositories! Press return to continue. Press Ctrl+c and then "a" to abort
|
||||||
|
|
||||||
|
- name: Install required packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- php-ldap
|
||||||
|
|
||||||
|
- name: Include provisioning tasks
|
||||||
|
ansible.builtin.include_tasks: yealink_provisioning.yml
|
||||||
|
|
||||||
|
- name: Include XML-Utilities tasks
|
||||||
|
ansible.builtin.include_tasks: yealink_utilities.yml
|
9
roles/freepbx/tasks/yealink_provisioning.yml
Normal file
9
roles/freepbx/tasks/yealink_provisioning.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Clone Yealink Provisioning data
|
||||||
|
ansible.builtin.git: # noqa: latest
|
||||||
|
repo: "{{ repo_provisioning }}"
|
||||||
|
dest: "{{ path_yealink_provisioning }}"
|
||||||
|
force: true
|
||||||
|
accept_hostkey: true
|
||||||
|
key_file: "{{ deploy_key_file }}"
|
53
roles/freepbx/tasks/yealink_utilities.yml
Normal file
53
roles/freepbx/tasks/yealink_utilities.yml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: "python3-venv"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Check if .gitignore contains "{{ path_yealink_utilities }}"
|
||||||
|
ansible.builtin.command: grep "directory = {{ path_yealink_utilities }}" /root/.gitconfig
|
||||||
|
register: gitignore_check
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: "Patch /root/.gitconfig"
|
||||||
|
ansible.builtin.command: |-
|
||||||
|
git config --global --add safe.directory {{ path_yealink_utilities }}
|
||||||
|
when: gitignore_check.rc != 0
|
||||||
|
|
||||||
|
- name: Clone Yealink Utilities
|
||||||
|
ansible.builtin.git: # noqa: latest
|
||||||
|
repo: "{{ repo_utilities }}"
|
||||||
|
dest: "{{ path_yealink_utilities }}"
|
||||||
|
force: true
|
||||||
|
accept_hostkey: true
|
||||||
|
key_file: "{{ deploy_key_file }}"
|
||||||
|
|
||||||
|
- name: Ensure directory permissions
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ path_yealink_utilities }}"
|
||||||
|
state: directory
|
||||||
|
recurse: true
|
||||||
|
owner: "{{ asterisk_user }}"
|
||||||
|
group: "{{ asterisk_group }}"
|
||||||
|
|
||||||
|
- name: Install specified python requirements in indicated (virtualenv)
|
||||||
|
ansible.builtin.pip:
|
||||||
|
requirements: "{{ path_yealink_utilities }}/requirements.txt"
|
||||||
|
virtualenv: "{{ path_yealink_utilities }}/.venv"
|
||||||
|
virtualenv_command: 'python3 -m venv'
|
||||||
|
|
||||||
|
- name: Install systemd unit
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: yealink-utilities.service.j2
|
||||||
|
dest: /etc/systemd/system/yealink-utilities.service
|
||||||
|
mode: "0644"
|
||||||
|
notify:
|
||||||
|
- Reload systemd
|
||||||
|
- Restart yealink-utilities
|
||||||
|
|
||||||
|
- name: Enable yealink-utilities
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: yealink-utilities
|
||||||
|
state: started
|
||||||
|
enabled: true
|
17
roles/freepbx/templates/yealink-utilities.service.j2
Normal file
17
roles/freepbx/templates/yealink-utilities.service.j2
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Yealink XML-Browser
|
||||||
|
After=syslog.target
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
RestartSec=2s
|
||||||
|
Type=simple
|
||||||
|
User={{ asterisk_user }}
|
||||||
|
Group={{ asterisk_group }}
|
||||||
|
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:{{ path_yealink_utilities }}/.venv/bin"
|
||||||
|
WorkingDirectory={{ path_yealink_utilities }}
|
||||||
|
ExecStart={{ path_yealink_utilities }}/.venv/bin/python3 {{ path_yealink_utilities }}/run.py
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user