If the requirements per host are different you can do it two ways:

1. Create a role per host
2. Split your current roles into 'generic' that are applicable to all hosts
and 'specific' that only apply to given hosts

It's probably easier to have a playbook per host then trying to coerce a
single playbook and and a single role to do multiple things.

kind regards
Pshem


On Tue, 14 Mar 2017 at 23:11 Dennis Klein <[email protected]> wrote:

> Having one file with tasks for all hosts is worse than having one file for
> each host, but i already have a host_vars file for every host.
>
> Why do i need a different file to configure a host in another directory?
>
> That makes ansible pretty hard for other contributors to understand, if
> one host get's it's tasks and configuration from different files.
>
> Puppet has just one file for each host where every configuration is in!
>
> Jenkins was just an example, this is a general problem of the design of
> Ansible.
>
> Is there any solution for this or is Ansible just not usable if you
> need individual settings for hosts outside of the scope of your roles?
>
>
> Am Donnerstag, 2. März 2017 18:02:02 UTC+1 schrieb Kai Stian Olstad:
>
> On 02. mars 2017 11:27, Dennis Klein wrote:
> > Hello,
> >
> > i'm not sure if i understand the Ansible structure correctly and if
> Ansible
> > is the best solution for us.
> >
> > Our scenario: We are a webhosting company with about 200 VMs (and
> counting) with
> > mostly individual websites.
> > We also have 4 server farms where multiple VMs serve one website. (3x
> > Webserver, 2x Varnish, 2x DB, etc)
> >
> > We have started to use Ansible and are now at a point where the best
> > practices from the docs are not usable.
> >
> > An example for the problem: We have a Jenkins-Server in evey server
> farm.
> > So we use a Jenkins Role to install it.
> > But every instance needs different packages installed for Jenkins to
> build
> > the software on it.
> > So the Task for Ansible to do is to install one package on one Host.
> >
> > I simply can do that in Puppet or Saltstack, but in Ansible i can't
> apply a
> > task to a Host as i know.
> > How am i supposed to organize this situation?
> >
> > I think it is not meant to have a role that is only used once or a
> playbook
> > for every host.
>
> - name: Install a package on one host
>    package:
>      name: <some package>
>    when: inventory_hostname == 'host.example.com'
>
> A better way might be to set a variable in host_vars/host.example.com.yml
> ---
> packages_to_install_on_jenkins:
>    - <package one>
>    - <package two>
>
>
> The in the role you could do this.
>
> - name: Install some packages needed for Jenkins build
>    package:
>      name: "{{ item }}"
>    with_items: "{{ packages_to_install_on_jenkins }}"
>
> I hope this gives you an idea of how you can solve it in Ansible.
>
> --
> Kai Stian Olstad
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/e7065861-3679-407b-ad61-94f0eb04d0f2%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/e7065861-3679-407b-ad61-94f0eb04d0f2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEaZiRULJdZogjwWP4kCiq1%2BgnZva4S1CZkGUGQMyhrOjZQtrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to