3 ms·
systemd configuration lookups are lightweights and straightforward compared to ansible variables lookups rules : -- Understanding variable precedence Ansib
by nick__m 3y ago
systemd configuration lookups are lightweights and straightforward compared to ansible variables lookups rules :
--
Understanding variable precedence
Ansible does apply variable precedence, and you might have a use for it. Here is the order of precedence from least to greatest (the last listed variables override all other variables):
1 command line values (for example, -u my_user, these are not variables)
2 role defaults (defined in role/defaults/main.yml) 1
3 inventory file or script group vars 2
4 inventory group_vars/all 3
5 playbook group_vars/all 3
6 inventory group_vars/* 3
7 playbook group_vars/* 3
8 inventory file or script host vars 2
9 inventory host_vars/* 3
10 playbook host_vars/* 3
11 host facts / cached set_facts 4
12 play vars
13 play vars_prompt
14 play vars_files
15 role vars (defined in role/vars/main.yml)
16 block vars (only for tasks in block)
17 task vars (only for the task)
18 include_vars
19 set_facts / registered vars
20 role (and include_role) params
21 include params
22 extra vars (for example, -e "user=my_user")(always win precedence)
‐‐
that is a RedHat-isim
- oblio 3y agoMeh, it's not Red Hat. Configuration management tools do this. Chef is similar.
- eropple 3y agoChef is worse. It's discouraged to use `override` in Chef cookbooks but nothing says that you can't, and introducing spooky action at a distance is just part of your life now.
- pferde 3y agoIIRC, Ansible had this exact variable precedence long before they were acquired by RH. I get that hating RH is in vogue currently, but let's keep it grounded in reality please. EDIT: And for the record, these Ansible precedence rules are not a bad thing. Once you are somewhat familiar with them, it allows you to write incredibly flexible and extensible playbooks and roles.
- TheNewsIsHere 3y agoAs an Ansible person, I couldn’t agree more. Being able to manage variables at basically any level of precedence is extremely useful. I am also ever more deeply concerned about IBM’s hell-bent purge of all the good left at Redhat. I had thought it would take them less time to destroy Redhat, but I’m sure they wanted to make sure they spent time “listening” before making all these ecosystem-eroding changes.
- hedora 3y agoI love how there are 21 places to look if you're trying to figure out why a CLI parameter is being ignored. Does it at least print a warning or something?
- faangsticle 3y agoOther way around. Cli params have highest precedence.
- deleted 3y ago[deleted]