From e9a2316184eb3f47dbd15d7868f929da1cc27c94 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Thu, 7 May 2020 15:47:06 +0200 Subject: [PATCH] configure local workers with settings from buildbot-worker role --- defaults/main.yaml | 2 ++ templates/buildbot/master.cfg.j2 | 8 ++++++++ vars/main.yaml | 2 ++ 3 files changed, 12 insertions(+) diff --git a/defaults/main.yaml b/defaults/main.yaml index 81ec2b6..42a992a 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -6,6 +6,8 @@ buildbot_db_pass: "{{ ansible_local.buildbot.database_password }}" buildbot_server_name: "{{ inventory_hostname }}" +buildbot_workers: "{ {% for name in _buildbot_worker_names %} \"{{name}}\": {\"password\":\"{{ansible_local['buildbot_worker_'+name].worker_password}}\"} {% endfor %} }" buildbot_builders: {} buildbot_hello_world_example: true +buildbot_local_worker: true diff --git a/templates/buildbot/master.cfg.j2 b/templates/buildbot/master.cfg.j2 index 87728e4..87654f2 100644 --- a/templates/buildbot/master.cfg.j2 +++ b/templates/buildbot/master.cfg.j2 @@ -40,7 +40,15 @@ c['db'] = { # Local Worker +{% if buildbot_local_worker %} c['workers'].append(worker.LocalWorker("local-worker")) +{% endif %} + +# Ansible Defined Workers +{% for worker_name in buildbot_workers.keys() %} +{% set worker = buildbot_workers[worker_name] %} +c['workers'].append(worker.Worker('{{worker_name}}', '{{worker.password}}')) +{% endfor %} # Hello World Example {% if buildbot_hello_world_example %} diff --git a/vars/main.yaml b/vars/main.yaml index 21a9fc4..c03c93e 100644 --- a/vars/main.yaml +++ b/vars/main.yaml @@ -2,6 +2,8 @@ _local_facts: database_password: "{% if not ansible_local.buildbot.database_password is defined %}{{ lookup('password', '/dev/null length=16 chars=ascii_letters') }}{% else %}{{ ansible_local.buildbot.database_password }}{% endif %}" +_buildbot_worker_names: "{{ ansible_local.keys() | map('regex_search', '^buildbot_worker_(.*)$') | select('string') | map('regex_replace', '^buildbot_worker_(.*)$', '\\1') | list }}" + buildbot_database_url: "postgresql://{{buildbot_db_user}}:{{buildbot_db_pass}}@localhost:5432/{{buildbot_db_name}}" buildbot_nginx_vhosts: