freepbx: Cleanup and only use flask based application

This commit is contained in:
Thomas Basler 2024-11-30 12:51:55 +01:00
parent 288a23b412
commit 1c902b5a90
7 changed files with 62 additions and 125 deletions

View File

@ -6,14 +6,7 @@ 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
repo_utilities: 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'
path_yealink_utilities: /opt/yealink_utilities

View File

@ -4,7 +4,7 @@
ansible.builtin.systemd:
daemon_reload: true
- name: Restart yealink-xml-browser
- name: Restart yealink-utilities
ansible.builtin.service:
name: yealink-xml-browser
name: yealink-utilities
state: restarted

View File

@ -11,8 +11,5 @@
- 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
- name: Include XML-Utilities tasks
ansible.builtin.include_tasks: yealink_utilities.yml

View File

@ -1,74 +0,0 @@
---
- 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

View 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

View File

@ -1,32 +0,0 @@
---
- 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

View File

@ -8,9 +8,9 @@ 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
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]