From 2b31dddd8dbba39c73da0ce20c93b64b8d155a91 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Thu, 16 Jan 2020 16:52:33 +0100 Subject: [PATCH] new local fact scheme --- defaults/main.yml | 2 +- tasks/local_facts.yaml | 8 +++++--- vars/main.yml | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 5fbacda..3e273b3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -16,4 +16,4 @@ gitea_admin_email: admin@example.com gitea_db_name: gitea gitea_db_user: gitea -gitea_db_pass: "{{ ansible_local.gitea.database_password }}" +gitea_db_pass: "{{ ansible_local[role_name].database_password }}" diff --git a/tasks/local_facts.yaml b/tasks/local_facts.yaml index f1b8c2a..206666e 100644 --- a/tasks/local_facts.yaml +++ b/tasks/local_facts.yaml @@ -5,10 +5,12 @@ path: /etc/ansible/facts.d state: directory -- name: set ansible local fact for gitea +- name: set ansible local fact copy: - content: "{{_gitea_local_facts|to_json}}" - dest: /etc/ansible/facts.d/gitea.fact + content: "{{_local_facts|to_json}}" + dest: /etc/ansible/facts.d/{{role_name}}.fact + register: _local_facts_set - name: Gathering Facts setup: + when: _local_facts_set.changed diff --git a/vars/main.yml b/vars/main.yml index fa2d3c4..67feae5 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,5 +1,5 @@ -_gitea_local_facts: - database_password: "{% if not ansible_local.gitea.database_password is defined %}{{ lookup('password', '/dev/null length=16 chars=ascii_letters') }}{% else %}{{ ansible_local.gitea.database_password }}{% endif %}" +_local_facts: + database_password: "{% if not ansible_local[role_name].database_password is defined %}{{ lookup('password', '/dev/null length=16 chars=ascii_letters') }}{% else %}{{ ansible_local[role_name].database_password }}{% endif %}" _gitea_nginx_vhosts: - name: gitea