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?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAHEKYV68ohnRP9Dx4mN%2Bo7NJDgxeUSyB-E-f_Shn9-qsAn%2B9Uw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to