Mapping from hosts to services

Hi all,

I’m still in the learning phase.

I try to complete a strong normalized approach with all variables and dependencies declared in the inventory with the goal to manage the configuration of a server infrastructure.

Currently, my ansible setup configures and populates FreeBSD hosts and all the jails on them.
Jails on FreeBSD are light weight VMs.
Additionally, I have completed a role which installs and configures a service on such a jail out of a template and inventory variables.
This role is specific to the service (in this case, DNS with bind9).

Now the question:
How can I enhance my inventory to map this role to a jail on a specific host ?
Or more general, to map services to jails?

Thanks, Axel

AFAIK playbooks and roles can’t be selected from variables or per conditionals.Their calling statements are fixed, once the top level palybook has started.

What comes into mind:

  1. call all service roles n each jail role and give it the inventory info as argument
  2. in the service role, check if it should be installed in the current jail. If not, return immediately.

It would be an architectural deficiency of ansible, if there is no better solution.

Axel

How can I enhance my inventory to map this role to a jail on a specific host ?
Or more general, to map services to jails?

AFAIK playbooks and roles can’t be selected from variables or per conditionals.
Their calling statements are fixed, once the top level palybook has started.

What comes into mind:
1. call all service roles n each jail role and give it the inventory info as argument
2. in the service role, check if it should be installed in the current jail. If not, return immediately.

It would be an architectural deficiency of ansible, if there is no better solution.

You can certainly use roles dynamically from the playbook. Get rid of the unflexible roles:
statement in your playbook and use tasks:

- hosts: chaosjails
  tasks:
    - include_role:
        name: "{{ myjail_role }}"
      when: myvar is defined

Regards
         Racke

Looks perfectly for what I’m looking.
Thanks a lot Racke!

Axel