From 909cc137ad4556cce2e96116e2ee314024e3d991 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 3 Dec 2024 18:14:01 -0500 Subject: [PATCH] Organize and tag roles --- asterisk.yml | 6 ++-- roles/asterisk/tasks/configure_asterisk.yml | 25 ++++++++++++++ roles/asterisk/tasks/main.yml | 33 ++++--------------- .../tasks/configure_provisioning.yml | 17 ++++++++++ roles/phone-provisioning/tasks/main.yml | 29 +++++----------- 5 files changed, 62 insertions(+), 48 deletions(-) create mode 100644 roles/asterisk/tasks/configure_asterisk.yml create mode 100644 roles/phone-provisioning/tasks/configure_provisioning.yml diff --git a/asterisk.yml b/asterisk.yml index 56507cb..c190622 100644 --- a/asterisk.yml +++ b/asterisk.yml @@ -2,5 +2,7 @@ hosts: asterisk become: true roles: - - asterisk - - phone-provisioning + - role: asterisk + tags: asterisk + - role: phone-provisioning + tags: provisioning diff --git a/roles/asterisk/tasks/configure_asterisk.yml b/roles/asterisk/tasks/configure_asterisk.yml new file mode 100644 index 0000000..6d8d973 --- /dev/null +++ b/roles/asterisk/tasks/configure_asterisk.yml @@ -0,0 +1,25 @@ +- name: Configure extensions + template: + src: extensions.conf.j2 + dest: /etc/asterisk/extensions.conf + notify: reload dialplan +- name: Configure SIP clients + template: + src: pjsip.conf.j2 + dest: /etc/asterisk/pjsip.conf + notify: reload sip +- name: Configure mailboxes + template: + src: voicemail.conf.j2 + dest: /etc/asterisk/voicemail.conf + notify: reload voicemail +- name: Configure HTTP interface + template: + src: http.conf.j2 + dest: /etc/asterisk/http.conf + notify: reload core +- name: Configure ARI interface + template: + src: ari.conf.j2 + dest: /etc/asterisk/ari.conf + notify: reload core diff --git a/roles/asterisk/tasks/main.yml b/roles/asterisk/tasks/main.yml index 67865cd..c03a26a 100644 --- a/roles/asterisk/tasks/main.yml +++ b/roles/asterisk/tasks/main.yml @@ -1,27 +1,8 @@ -- name: Configure extensions - template: - src: extensions.conf.j2 - dest: /etc/asterisk/extensions.conf - notify: reload dialplan -- name: Configure SIP clients - template: - src: pjsip.conf.j2 - dest: /etc/asterisk/pjsip.conf - notify: reload sip -- name: Configure mailboxes - template: - src: voicemail.conf.j2 - dest: /etc/asterisk/voicemail.conf - notify: reload voicemail -- name: Configure HTTP interface - template: - src: http.conf.j2 - dest: /etc/asterisk/http.conf - notify: reload core -- name: Configure ARI interface - template: - src: ari.conf.j2 - dest: /etc/asterisk/ari.conf - notify: reload core -- ansible.builtin.include_tasks: +- name: Configure Asterisk + tags: asterisk-configuration + ansible.builtin.include_tasks: + file: configure_asterisk.yml +- name: Install Voicemail API + tags: voicemail-api + ansible.builtin.include_tasks: file: install_voicemail_api.yml diff --git a/roles/phone-provisioning/tasks/configure_provisioning.yml b/roles/phone-provisioning/tasks/configure_provisioning.yml new file mode 100644 index 0000000..a95697b --- /dev/null +++ b/roles/phone-provisioning/tasks/configure_provisioning.yml @@ -0,0 +1,17 @@ +- name: Configure TFTP provisioning server + ansible.builtin.lineinfile: + path: /etc/default/tftpd-hpa + regexp: '^TFTP_DIRECTORY=' + line: TFTP_DIRECTORY="/var/lib/tftpboot" + notify: restart tftpd +- name: Configure HTTP provisioning server + ansible.builtin.template: + src: 001-tftpboot.conf.j2 + dest: /etc/apache2/sites-available/001-tftpboot.conf + notify: reload apache2 +- name: Enable HTTP provisioning server + ansible.builtin.file: + src: /etc/apache2/sites-available/001-tftpboot.conf + dest: /etc/apache2/sites-enabled/001-tftpboot.conf + state: link + notify: reload apache2 diff --git a/roles/phone-provisioning/tasks/main.yml b/roles/phone-provisioning/tasks/main.yml index 21a31a2..9c04825 100644 --- a/roles/phone-provisioning/tasks/main.yml +++ b/roles/phone-provisioning/tasks/main.yml @@ -1,25 +1,14 @@ -- ansible.builtin.include_tasks: +- name: Install Apache2 + ansible.builtin.include_tasks: file: install_apache2.yml -- ansible.builtin.include_tasks: +- name: Install TFTPd + ansible.builtin.include_tasks: file: install_tftpd.yml -- name: Copy phone files +- name: Copy phone provisioning files + tags: phone-configuration ansible.builtin.copy: src: tftpboot/ dest: /var/lib/tftpboot/ -- name: Configure TFTP provisioning server - ansible.builtin.lineinfile: - path: /etc/default/tftpd-hpa - regexp: '^TFTP_DIRECTORY=' - line: TFTP_DIRECTORY="/var/lib/tftpboot" - notify: restart tftpd -- name: Configure HTTP provisioning server - ansible.builtin.template: - src: 001-tftpboot.conf.j2 - dest: /etc/apache2/sites-available/001-tftpboot.conf - notify: reload apache2 -- name: Enable HTTP provisioning server - ansible.builtin.file: - src: /etc/apache2/sites-available/001-tftpboot.conf - dest: /etc/apache2/sites-enabled/001-tftpboot.conf - state: link - notify: reload apache2 +- name: Configure and enable phone provisioning + ansible.builtin.include_tasks: + file: configure_provisioning.yml