Hi list,
my goal: A role which allows to configure various aspects how tasks
should behave, e.g. how to use the become subsystem, especially for
local_action tasks.
Ultimate goal: Configure a few variables in inventory, and have all
roles behavior configured for that specific infrastructure.
# Assumptions:
- Role foo depends on role foobar (meta/main.yml dependencies:)
- Role bar depends on role foobar (meta/main.yml ...)
- Role foobar provides variables to control the become subsystem.
- Role foo and bar use variables from foobar.
# Role foobar
## defaults/main.yml
foobar_action_become_enable: yes
#foobar_action_become_user: root
#foobar_action_become_method: sudo
# Role foo
## tasks/main.yml
- name: Do something that requires sudo
become: "{{ foobar_action_become_enable }}"
become_user: "{{ foobar_action_become_user|default(omit) }}"
become_method: "{{ foobar_action_become_method|default(omit) }}"
file:
state=directory
dest=/usr/local/foo
owner=0
group=0
mode=0755
I did something similar with
[groover.util](https://github.com/silpion/ansible-util/tree/0.1.0) role
regarding sudo and sudo_user, which felt to work as intended.
Thing is, ... this doesn't work (anymore, or at least with become).
# Example playbook