From e4270d3e9dabe3f6cae600a0a352125b8fd19eaa Mon Sep 17 00:00:00 2001 From: Florent CARLI Date: Tue, 1 Oct 2024 11:17:51 +0200 Subject: [PATCH] ptpstatus: deal with when timemaster or ptp is not used Signed-off-by: Florent CARLI --- roles/debian_hypervisor/tasks/main.yml | 76 ++++++++++--------- .../ptpstatus/ptpstatus_script/ptpstatus.sh | 2 + 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/roles/debian_hypervisor/tasks/main.yml b/roles/debian_hypervisor/tasks/main.yml index ae410e072..119595f2c 100644 --- a/roles/debian_hypervisor/tasks/main.yml +++ b/roles/debian_hypervisor/tasks/main.yml @@ -214,44 +214,46 @@ name: ovs-vswitchd when: ovsvswitchd.changed +- name: ptp/vsock when ptp is enabled + block: + - name: Copy ptp_status executable files + ansible.builtin.copy: + src: ../src/debian/ptpstatus/ptpstatus_script/ptpstatus.sh + dest: /usr/local/bin/ptpstatus.sh + mode: '0755' + - name: Copy ptp_vsock executable files + ansible.builtin.copy: + src: ptp_vsock.py + dest: /usr/local/bin/ptp_vsock.py + mode: '0755' -- name: Copy ptp_status executable files - ansible.builtin.copy: - src: ../src/debian/ptpstatus/ptpstatus_script/ptpstatus.sh - dest: /usr/local/bin/ptpstatus.sh - mode: '0755' -- name: Copy ptp_vsock executable files - ansible.builtin.copy: - src: ptp_vsock.py - dest: /usr/local/bin/ptp_vsock.py - mode: '0755' - -- name: Copy ptp_status.service - ansible.builtin.copy: - src: ../src/debian/ptpstatus/ptpstatus.service - dest: /etc/systemd/system/ptpstatus.service - mode: '0644' - register: ptpstatus -- name: Copy ptp_vsock.service - ansible.builtin.copy: - src: ptp_vsock.service - dest: /etc/systemd/system/ptp_vsock.service - mode: '0644' - register: ptpvsock -- name: daemon-reload ptp status - ansible.builtin.service: - daemon_reload: yes - when: ptpstatus.changed or ptpvsock.changed -- name: enable ptpstatus.service - ansible.builtin.systemd: - name: ptpstatus.service - enabled: yes - state: started -- name: enable ptp_vsock.service - ansible.builtin.systemd: - name: ptp_vsock.service - enabled: yes - state: started + - name: Copy ptp_status.service + ansible.builtin.copy: + src: ../src/debian/ptpstatus/ptpstatus.service + dest: /etc/systemd/system/ptpstatus.service + mode: '0644' + register: ptpstatus + - name: Copy ptp_vsock.service + ansible.builtin.copy: + src: ptp_vsock.service + dest: /etc/systemd/system/ptp_vsock.service + mode: '0644' + register: ptpvsock + - name: daemon-reload ptp status + ansible.builtin.service: + daemon_reload: yes + when: ptpstatus.changed or ptpvsock.changed + - name: enable ptpstatus.service + ansible.builtin.systemd: + name: ptpstatus.service + enabled: yes + state: started + - name: enable ptp_vsock.service + ansible.builtin.systemd: + name: ptp_vsock.service + enabled: yes + state: started + when: ptp_interface is defined - name: Create conntrackd.service.d directory file: diff --git a/src/debian/ptpstatus/ptpstatus_script/ptpstatus.sh b/src/debian/ptpstatus/ptpstatus_script/ptpstatus.sh index a5dd79ff9..33ef9d62c 100755 --- a/src/debian/ptpstatus/ptpstatus_script/ptpstatus.sh +++ b/src/debian/ptpstatus/ptpstatus_script/ptpstatus.sh @@ -506,6 +506,8 @@ function getPtpStatus() { if [[ -S /var/run/timemaster/ptp4l.0.socket ]]; then PMC_SOCKET_OPTION="-s /var/run/timemaster/ptp4l.0.socket" + else + PMC_SOCKET_OPTION="" fi local _pmcOutput="$( \