From 7336d32402d3018fcde3e9d04e66f0d2acd2c500 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Mon, 6 Jan 2025 12:44:07 +0100 Subject: [PATCH] Update epics config with systemd timer --- tasks/epics_setup.yaml | 46 ++++++++++++++++++++++++++++++++++++++++++ tasks/main.yaml | 11 ++-------- 2 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 tasks/epics_setup.yaml diff --git a/tasks/epics_setup.yaml b/tasks/epics_setup.yaml new file mode 100644 index 0000000..58d5055 --- /dev/null +++ b/tasks/epics_setup.yaml @@ -0,0 +1,46 @@ +--- +- name: EPICS setup + become: true + vars: + service_name: epics_setup + + block: + - name: Create systemd service file + ansible.builtin.copy: + dest: /etc/systemd/system/{{ service_name }}.service + content: | + [Unit] + Description=Update epics_contexts.yml and gfa_12_epics.sh from gfa-global-profile + + [Service] + Type=oneshot + ExecStart=/usr/bin/curl -o /etc/epics_contexts.yml https://git.psi.ch/gfa_rpms/gfa-global-profile/-/raw/master/src/etc/epics_contexts.yml + ExecStart=/usr/bin/curl -o /etc/profile.d/gfa_12_epics.sh https://git.psi.ch/gfa_rpms/gfa-global-profile/-/raw/master/src/etc/profile.d/gfa_12_epics.sh + User=root + + - name: Trigger epics_setup service + ansible.builtin.systemd_service: + name: "{{ service_name }}.service" + state: started + daemon_reload: true + + - name: Create systemd timer file + ansible.builtin.copy: + dest: /etc/systemd/system/{{ service_name }}.timer + content: | + [Unit] + Description=Timer to update epics_contexts.yml and gfa_12_epics.sh from gfa-global-profile + + [Timer] + OnCalendar=daily + Persistent=true + + [Install] + WantedBy=timers.target + + - name: Enable and start systemd timer + ansible.builtin.systemd_service: + name: "{{ service_name }}.timer" + enabled: yes + state: started + daemon_reload: true diff --git a/tasks/main.yaml b/tasks/main.yaml index e75b0fb..6aa2184 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -20,15 +20,8 @@ - tmux state: latest -- name: Download epics_contexts.yml - ansible.builtin.uri: - url: https://git.psi.ch/gfa_rpms/gfa-global-profile/-/raw/master/src/etc/epics_contexts.yml - dest: /etc - -- name: Download gfa_12_epics.sh - ansible.builtin.uri: - url: https://git.psi.ch/gfa_rpms/gfa-global-profile/-/raw/master/src/etc/profile.d/gfa_12_epics.sh - dest: /etc/profile.d +- name: EPICS setup + include_tasks: epics_setup.yaml - name: Create a folder for BEC deployment become_user: "{{ bec_user }}"