Do not rely on ansible_user (#214)

* Apply "become" on roles instead of plays

This leads to facts being gathered for the "regular" login user, instead
of root.

* Do not rely on ansible_user

Instead of reading ansible_user (which may or may not be defined), this
patch lets the roles rely on Ansible facts [1].

[1]: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_vars_facts.html
This commit is contained in:
Simon Leiner
2023-01-30 04:20:25 +01:00
committed by GitHub
parent e33cbe52c1
commit be3e72e173
6 changed files with 17 additions and 14 deletions

View File

@@ -3,7 +3,7 @@
file:
path: /tmp/k3s
state: directory
owner: "{{ ansible_user }}"
owner: "{{ ansible_user_id }}"
mode: 0755
with_items: "{{ groups['master'] }}"
run_once: true
@@ -12,7 +12,7 @@
template:
src: "metallb.crs.j2"
dest: "/tmp/k3s/metallb-crs.yaml"
owner: "{{ ansible_user }}"
owner: "{{ ansible_user_id }}"
mode: 0755
with_items: "{{ groups['master'] }}"
run_once: true