So I need to define lots of variables for a specific host because I am
configuring its network (turning more interfaces on and whatnot). So I
created a host_vars/oddhost.yml that have lines like this:
home_nic: "eth0"
interfaces:
- {
vlan: 2,
nic: "{{ home_nic }}.{{ vlan }}",
[...]
}
- {
vlan: 3,
nic: "{{ home_nic }}.{{ vlan }}",
bridge_name: "dmzbr"
}
First of all, is there a way to move the nic definition out of the
dictionary so I do not need to keep on repeating it? I think not
because it is specific to each vlan.
Second, I am hardcoding home_nic here. But, what if I decide to have
some script that will find which nic is the one I really need (in case
of a multiple interface setup)? Would interfaces be only populated
after I get home_nic or it will try to load it before going to the
roles? I guess I am asking about the order of events (maybe load
global vars, host vars, somewhere get info about target host, role
vars, and then get to the tasks in the first role it opens).
Final question is about best practices: I have a "common" roles to do
stuff you normally do to a target host, like give it a name and create
its users (if a package needs an user it can just access that later
on). I also have a network role where I setup firewall rules, adjust
sshd_config, and do ntp client thingies. Would setting up network be
something that belongs under common roles or network? Or am I
overthinking?