[openstack-dev] [openstack-ansible] group/host specific config file overrides: how-to?

Flávio Ramalho f.ramalhoo at gmail.com
Tue Aug 22 07:46:33 UTC 2017


Hi Markus,

I think you can achieve what you want by simple overriding the host
variables, for example:

In /etc/openstack_deploy/openstack_user_config.yml:
compute_hosts:
   compute1:
     ip: 192.168.100.12
     host_vars:
       nova_reserved_host_memory_mb: 256
   compute2:
     ip: 192.168.100.10

In this case you would have compute1 with reserved_host_memory_mb = 256 and
compute2 with the default value set for nova_reserved_host_memory_mb.


Flávio

On Mon, Aug 21, 2017 at 6:09 PM Markus Zoeller <mzoeller at linux.vnet.ibm.com>
wrote:

> On 21.08.2017 16:40, Andy McCrae wrote:
> > Hey Markus,
> >
> >
> >> I'm wondering which possibilities I have to do group/host specific
> >> config file overrides. After reading [1], I'm still a little clueless.
> >> To be specific, I have this setup (expressed as Ansible inventory file):
> >>
> >>     [z_compute_nodes]
> >>     compute1
> >>     # more nodes
> >>     [x_compute_nodes]
> >>     compute2
> >>     # more nodes
> >>     [computes:children]
> >>     z_compute_nodes
> >>     x_compute_nodes
> >>
> >> As an example, I want to set Nova's config option
> >> `reserved_host_memory_mb` of the `DEFAULT` config file section:
> >>
> >>     ### nova.conf
> >>     [DEFAULT]
> >>     reserved_host_memory_mb=$VALUE
> >>
> >> My goal is this:
> >>
> >>              | reserved_host_memory_mb
> >>     ----------------------------------
> >>     compute1 |         256
> >>     compute2 |         512
> >>
> >> I know there are overrides like `nova_nova_conf_overrides`.
> >> So I tried to set a default override in `user_variables.yml`:
> >>
> >>     ### /etc/openstack_deploy/user_variables.yml --------
> >>
> >>     nova_nova_conf_overrides:
> >>       DEFAULT:
> >>         reserved_host_memory_mb: 512
> >>
> >> But I wanted to override this depending on the host in
> >> `openstack_user_config.yml`:
> >>
> >>     ### /etc/openstack_deploy/openstack_user_config.yml --------
> >>     # [...]
> >>     # nova hypervisors
> >>     compute_hosts:
> >>       compute1:
> >>         ip: 192.168.100.12
> >>         host_vars:
> >>           nova_nova_conf_overrides:
> >>             DEFAULT:
> >>               reserved_host_memory_mb: 256
> >>       compute2:
> >>         ip: 192.168.100.10
> >>
> >
> > Try change "host_vars" to "container_vars".
> > If that doesn't work let me know, I'll spin up a test to recreate the
> > actual problem, but at a glance that looks correct otherwise.
> >
>
>
> Replacing `host_vars` with `container_vars` didn't have an effect:
>
>     ### controller1: /etc/openstack_deploy/openstack_user_config.yml
>     # nova hypervisors
>     compute_hosts:
>       compute1:
>         ip: 192.168.100.12
>         container_vars:
>           nova_nova_conf_overrides:
>                 DEFAULT:
>                     reserved_host_memory_mb: 256
>       compute2:
>         ip: 192.168.100.10
>
> Both compute nodes still have the same $VALUE, although `compute1`
> should have 256:
>
>     ### compute1: /etc/nova/nova.conf
>     root at compute1:~# grep reserved_host_memory_mb /etc/nova/nova.conf
>     reserved_host_memory_mb = 512
>
>
>     ### compute2: /etc/nova/nova.conf
>     root at compute2:~# grep reserved_host_memory_mb /etc/nova/nova.conf
>     reserved_host_memory_mb = 512
>
> I'd like to avoid to introduce some "clever" dict merging algorithm I
> won't understand anymore after a few weeks. :/
>
> Any hint is appreciated!
>
> --
> Regards, Markus Zoeller (markus_z)
>
> >>
> >> After testing this locally, it turned out that *both* hosts will
> >> have 512 for $VALUE. which was not my intended configuration.
> >>
> >> Please note that I only used 2 hosts here as an example but I'm looking
> >> for a solution which scales with much more hosts. I'm also applying
> >> those settings in a templated way like this:
> >>
> >>     ### /etc/openstack_deploy/openstack_user_config.yml --------
> >>     # [...]
> >>     # nova hypervisors
> >>     compute_hosts:
> >>     {% for host in groups['computes'] %}
> >>       {{ hostvars[host]['inventory_hostname'] }}:
> >>         ip: {{ hostvars[host]['ansible_host'] }}
> >>     {% endfor %}
> >>
> >> The reason is, that I use the same steps for different environments
> >> (dev, test, prod) with a different amount of nodes.
> >>
> >> Any tips how to do this properly?
> >>
> >>
> > Andy
> >
> >
> >
> >
> __________________________________________________________________________
> > OpenStack Development Mailing List (not for usage questions)
> > Unsubscribe:
> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> >
>
>
>
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20170822/2e69c142/attachment.html>


More information about the OpenStack-dev mailing list