From 05d18b4c8c20bf660763678ce0adf289e804fcb6 Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Mon, 16 Dec 2024 20:19:46 +0000 Subject: [PATCH] feat: adapt start/stop uploaders for multi user setup Since there is a one-to-one mapping between an `antX` user and an uploader service, the number of uploader instances is determined by how many users there are. --- resources/ansible/start_uploaders.yml | 11 ++++++++--- resources/ansible/stop_uploaders.yml | 14 +++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/resources/ansible/start_uploaders.yml b/resources/ansible/start_uploaders.yml index 1a2e5eb1..43ab38d9 100644 --- a/resources/ansible/start_uploaders.yml +++ b/resources/ansible/start_uploaders.yml @@ -3,10 +3,15 @@ hosts: all become: True tasks: - - name: stop all autonomi uploader service + - name: get list of ant users + ansible.builtin.shell: "getent passwd | grep '^ant[0-9]\\+:' | cut -d: -f1" + register: ant_users + changed_when: false + + - name: start all ant uploader services ansible.builtin.systemd: - name: "ant_uploader_{{ item }}" + name: "ant_uploader_{{ item | regex_replace('ant([0-9]+)', '\\1') }}" state: started enabled: yes become: true - loop: "{{ range(1, ant_uploader_instances | int + 1) | list }}" + loop: "{{ ant_users.stdout_lines }}" diff --git a/resources/ansible/stop_uploaders.yml b/resources/ansible/stop_uploaders.yml index e10d2e2e..c30876c0 100644 --- a/resources/ansible/stop_uploaders.yml +++ b/resources/ansible/stop_uploaders.yml @@ -1,13 +1,17 @@ --- -- name: ensure the safe uploader service is stopped +- name: ensure the ant uploader service is stopped hosts: all become: True tasks: - - name: stop all autonomi uploader service + - name: get list of ant users + ansible.builtin.shell: "getent passwd | grep '^ant[0-9]\\+:' | cut -d: -f1" + register: ant_users + changed_when: false + + - name: stop all ant uploader services ansible.builtin.systemd: - name: "ant_uploader_{{ item }}" + name: "ant_uploader_{{ item | regex_replace('ant([0-9]+)', '\\1') }}" state: stopped enabled: yes become: true - loop: "{{ range(1, ant_uploader_instances | int + 1) | list }}" - ignore_errors: "{{ skip_err | default(false) }}" + loop: "{{ ant_users.stdout_lines }}" \ No newline at end of file