[TIDY] Move to ansible_facts dict instead of injected variables

This commit is contained in:
Jannik Beyerstedt 2025-12-20 21:01:23 +01:00
parent cdd9bc58d2
commit ccf581edaa
6 changed files with 20 additions and 20 deletions

View file

@ -2,7 +2,7 @@
# Tinc VPN Hostfile Distribution
- name: Distribute - Set different base dir for macOS
when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Darwin"
when: (override_os_family is defined) | ternary(override_os_family,ansible_facts['os_family']) == "Darwin"
ansible.builtin.set_fact:
tinc_base_dir: /usr/local/etc/tinc

View file

@ -2,15 +2,15 @@
# Tinc VPN Setup and Configuration
- name: Main - Set different base dir for macOS
when: (override_os_family is defined) | ternary(override_os_family, ansible_os_family) == "Darwin"
when: (override_os_family is defined) | ternary(override_os_family, ansible_facts['os_family']) == "Darwin"
ansible.builtin.set_fact:
tinc_base_dir: /usr/local/etc/tinc
- name: Main - Install tinc
ansible.builtin.include_tasks: "{{ item }}"
with_first_found:
- "setup-{{ ansible_distribution }}.yml"
- "setup-{{ (override_os_family is defined) | ternary(override_os_family, ansible_os_family) }}.yml"
- "setup-{{ ansible_facts['distribution'] }}.yml"
- "setup-{{ (override_os_family is defined) | ternary(override_os_family, ansible_facts['os_family']) }}.yml"
- name: Main - Create tinc directories
become: true
@ -38,14 +38,14 @@
become: true
ansible.builtin.fetch:
src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/rsa_key.pub"
dest: "{{ role_path }}/templates/tmp/rsa_key-{{ ansible_hostname | replace('-', '_') }}.pub"
dest: "{{ role_path }}/templates/tmp/rsa_key-{{ ansible_facts['hostname'] | replace('-', '_') }}.pub"
flat: true
- name: Main - Create own hostfile
become: true
ansible.builtin.template:
src: "{{ role_path }}/templates/hostfile.j2"
dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname | replace('-', '_') }}"
dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_facts['hostname'] | replace('-', '_') }}"
- name: Main - Create tinc-up script
become: true
@ -64,12 +64,12 @@
- name: Main - Fetch all hostfiles
become: true
ansible.builtin.fetch:
src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname | replace('-', '_') }}"
dest: "{{ role_path }}/files/tmp/{{ ansible_hostname | replace('-', '_') }}"
src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_facts['hostname'] | replace('-', '_') }}"
dest: "{{ role_path }}/files/tmp/{{ ansible_facts['hostname'] | replace('-', '_') }}"
flat: true
- name: "Main - Enable {{ tinc_vpn_id }}"
when: ansible_os_family != 'Darwin'
when: ansible_facts['os_family'] != 'Darwin'
become: true
block:
- name: "Main - Enable {{ tinc_vpn_id }} in tinc config"