From: Thorsten Date: Sat, 18 Jul 2026 11:09:25 +0000 (+0200) Subject: Fix NATS provisioning for hosts where the bot user lacks passwordless sudo X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=1361f8926185217cae7666dffc848bd9370cfddb;p=urlbot-v3.git Fix NATS provisioning for hosts where the bot user lacks passwordless sudo nats_server.yml's tasks use become: true, which worked fine on munin (the "pi" user has passwordless sudo) but hung waiting for a sudo password prompt on aero2k.de, where "jabberbot" doesn't - discovered deploying NATS there for the first time. Moved "provision local nats server" into deploy.yml's first play, which already connects as root directly (no become needed at all), instead of the second play that connects as botuser. Also switched from a raw include_tasks path to include_role(tasks_from: nats_server), since a bare include_tasks doesn't pull in the role's defaults/main.yml (nats_version was undefined otherwise) while include_role does regardless of which tasks file is requested. Co-Authored-By: Claude Sonnet 5 --- diff --git a/deploy/deploy.yml b/deploy/deploy.yml index fb39a0b..0047589 100644 --- a/deploy/deploy.yml +++ b/deploy/deploy.yml @@ -1,26 +1,39 @@ --- - hosts: bots remote_user: root + become: true tasks: - name: create user for bot user: - # default name - name: jabberbot + name: "{{ botuser }}" comment: "Account for the urlbot" shell: /bin/bash + when: manage_botuser | default(true) + - name: local user can log in with ssh key - authorized_key: user=jabberbot key="{{ lookup('file', item) }}" + authorized_key: user="{{ botuser }}" key="{{ lookup('file', item) }}" with_fileglob: - "~/.ssh/*.pub" + when: manage_botuser | default(true) - name: ensure venv module is installed apt: - name: python3-venv + name: + - git + - python3-venv + - python3-dev + - build-essential + - libleveldb-dev + - libxslt1.1 state: present + - name: provision local nats server + include_role: + name: urlbot + tasks_from: nats_server + when: broker_backend == 'nats' and nats_local | default(false) + - hosts: bots - vars: - botuser: jabberbot remote_user: "{{ botuser }}" roles: - urlbot diff --git a/deploy/roles/urlbot/tasks/main.yml b/deploy/roles/urlbot/tasks/main.yml index a172846..84895fe 100644 --- a/deploy/roles/urlbot/tasks/main.yml +++ b/deploy/roles/urlbot/tasks/main.yml @@ -1,9 +1,5 @@ --- -- name: provision local nats server - include_tasks: nats_server.yml - when: broker_backend == 'nats' and nats_local | default(false) - - name: setup virtualenv for the chatbot shell: cmd: "python3 -m venv {{ venv_chatbot }}"