From 6bee691284c3f40568e18385ace74d5c6d7825f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Berthaud-M=C3=BCller?= Date: Fri, 30 Jul 2021 12:36:02 +0200 Subject: [PATCH] test --- roles/knot/tasks/main.yml | 17 ++++++++++++----- roles/knot/templates/knot.conf.j2 | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/roles/knot/tasks/main.yml b/roles/knot/tasks/main.yml index f7aa584..302fc5a 100644 --- a/roles/knot/tasks/main.yml +++ b/roles/knot/tasks/main.yml @@ -16,17 +16,24 @@ - name: Generate tsig become: yes - ansible.builtin.shell: keymgr -t {{ key_name }} > /etc/knot/{{ key_name }}.key - args: - creates: /etc/knot/{{ key_name }}.key - when: "inventory_hostname in groups.primary" + ansible.builtin.shell: + cmd: "keymgr -t {{ key_name }} > /etc/knot/{{ key_name }}.key" + creates: "/etc/knot/{{ key_name }}.key" + run_once: True - name: Fetch key become: yes ansible.builtin.slurp: src: /etc/knot/{{ key_name }}.key register: tsig_key - when: "inventory_hostname in groups.primary" + run_once: True + +- name: Populate key to all host + set_facts: + tsig_key_content: {{ tsig_key['content'] | b64decode }} + run_once: True + with_items: "{{ play_hosts }}" + delegate_to: "{{ item }}" - name: Deploy conf become: yes diff --git a/roles/knot/templates/knot.conf.j2 b/roles/knot/templates/knot.conf.j2 index 576ca3c..8901739 100644 --- a/roles/knot/templates/knot.conf.j2 +++ b/roles/knot/templates/knot.conf.j2 @@ -7,7 +7,7 @@ log: - target: syslog any: info -{{ tsig_key.content | b64decode }} +{{ tsig_key_content }} remote: {% for host in groups.all %}