freepbx: Install self developed yealink packages
This commit is contained in:
parent
4f1790d815
commit
e3a79a0307
19
roles/freepbx/defaults/main.yml
Normal file
19
roles/freepbx/defaults/main.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
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_phonebook: gogs@git.binary-kitchen.de:noby/voip-yealink-phonebook.git
|
||||||
|
repo_xml_browser: gogs@git.binary-kitchen.de:noby/voip-yealink-xml-browser.git
|
||||||
|
|
||||||
|
path_yealink_provisioning: /tftpboot/yealink
|
||||||
|
path_yealink_phonebook: /var/www/html/yealink_phonebook
|
||||||
|
path_yealink_xml_browser: /opt/yealink_xml_browser
|
||||||
|
|
||||||
|
composer_path: "{{ path_yealink_phonebook }}/composer"
|
||||||
|
composer_keep_updated: false
|
||||||
|
composer_version: ''
|
||||||
|
composer_version_branch: '--2'
|
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-xml-browser
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: yealink-xml-browser
|
||||||
|
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"
|
18
roles/freepbx/tasks/main.yml
Normal file
18
roles/freepbx/tasks/main.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- 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: Include provisioning tasks
|
||||||
|
ansible.builtin.include_tasks: yealink_provisioning.yml
|
||||||
|
|
||||||
|
- name: Include phonebook tasks
|
||||||
|
ansible.builtin.include_tasks: yealink_phonebook.yml
|
||||||
|
|
||||||
|
- name: Include XML-Browser tasks
|
||||||
|
ansible.builtin.include_tasks: yealink_xml_browser.yml
|
74
roles/freepbx/tasks/yealink_phonebook.yml
Normal file
74
roles/freepbx/tasks/yealink_phonebook.yml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Check if requested version parameters are valid
|
||||||
|
fail:
|
||||||
|
msg: You cannot request a specific version AND keep the composer up to date.
|
||||||
|
Set either composer_version or composer_keep_updated, but not both.
|
||||||
|
when: composer_version != '' and composer_keep_updated
|
||||||
|
|
||||||
|
- name: Set php_executable variable to a default if not defined.
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
php_executable: php
|
||||||
|
when: php_executable is not defined
|
||||||
|
|
||||||
|
- name: Safe Directory
|
||||||
|
command: git config --global --add safe.directory {{ path_yealink_phonebook }}
|
||||||
|
check_mode: no
|
||||||
|
|
||||||
|
- name: Clone Phonebook generation script
|
||||||
|
ansible.builtin.git: # noqa: latest
|
||||||
|
repo: "{{ repo_phonebook }}"
|
||||||
|
dest: "{{ path_yealink_phonebook }}"
|
||||||
|
force: true
|
||||||
|
accept_hostkey: true
|
||||||
|
key_file: "{{ deploy_key_file }}"
|
||||||
|
|
||||||
|
- name: Change directory owner
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ path_yealink_phonebook }}"
|
||||||
|
recurse: yes
|
||||||
|
owner: "{{ asterisk_user }}"
|
||||||
|
group: "{{ asterisk_group }}"
|
||||||
|
|
||||||
|
- name: Check if Composer is installed.
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ composer_path }}"
|
||||||
|
register: composer_bin
|
||||||
|
|
||||||
|
- name: Get Composer installer signature.
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: https://composer.github.io/installer.sig
|
||||||
|
return_content: true
|
||||||
|
check_mode: false
|
||||||
|
register: composer_installer_signature
|
||||||
|
when: not composer_bin.stat.exists
|
||||||
|
|
||||||
|
- name: Download Composer installer.
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: https://getcomposer.org/installer
|
||||||
|
dest: /tmp/composer-installer.php
|
||||||
|
mode: "0755"
|
||||||
|
checksum: "sha384:{{ composer_installer_signature.content }}"
|
||||||
|
when: not composer_bin.stat.exists
|
||||||
|
|
||||||
|
- name: Run Composer installer.
|
||||||
|
ansible.builtin.command: >
|
||||||
|
{{ php_executable }} composer-installer.php {% if composer_version_branch %} {{ composer_version_branch }}{% elif composer_version %} --version={{ composer_version }}{% endif %}
|
||||||
|
chdir=/tmp
|
||||||
|
when: not composer_bin.stat.exists
|
||||||
|
become: true
|
||||||
|
become_user: asterisk
|
||||||
|
|
||||||
|
- name: Move Composer into globally-accessible location.
|
||||||
|
ansible.builtin.command: >
|
||||||
|
mv /tmp/composer.phar {{ composer_path }}
|
||||||
|
creates={{ composer_path }}
|
||||||
|
when: not composer_bin.stat.exists
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
community.general.composer:
|
||||||
|
command: update
|
||||||
|
composer_executable: "{{ composer_path }}"
|
||||||
|
working_dir: "{{ path_yealink_phonebook }}"
|
||||||
|
become: true
|
||||||
|
become_user: asterisk
|
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 }}"
|
32
roles/freepbx/tasks/yealink_xml_browser.yml
Normal file
32
roles/freepbx/tasks/yealink_xml_browser.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: "python3-venv"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Clone Yealink XML-Browser
|
||||||
|
ansible.builtin.git: # noqa: latest
|
||||||
|
repo: "{{ repo_xml_browser }}"
|
||||||
|
dest: "{{ path_yealink_xml_browser }}"
|
||||||
|
force: true
|
||||||
|
accept_hostkey: true
|
||||||
|
key_file: "{{ deploy_key_file }}"
|
||||||
|
|
||||||
|
- name: Install specified python requirements in indicated (virtualenv)
|
||||||
|
ansible.builtin.pip:
|
||||||
|
requirements: "{{ path_yealink_xml_browser }}/requirements.txt"
|
||||||
|
virtualenv: "{{ path_yealink_xml_browser }}/.venv"
|
||||||
|
virtualenv_command: 'python3 -m venv'
|
||||||
|
|
||||||
|
- name: Install systemd unit
|
||||||
|
template: src=yealink-xml-browser.service.j2 dest=/lib/systemd/system/yealink-xml-browser.service
|
||||||
|
notify:
|
||||||
|
- Reload systemd
|
||||||
|
- Restart yealink-xml-browser
|
||||||
|
|
||||||
|
- name: Enable yealink-xml-browser
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: yealink-xml-browser
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
17
roles/freepbx/templates/yealink-xml-browser.service.j2
Normal file
17
roles/freepbx/templates/yealink-xml-browser.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_xml_browser }}/.venv/bin"
|
||||||
|
WorkingDirectory={{ path_yealink_xml_browser }}
|
||||||
|
ExecStart={{ path_yealink_xml_browser }}/.venv/bin/python3 {{ path_yealink_xml_browser }}/main.py
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user