[openstack-dev] [openstack-ansible] group/host specific config file overrides: how-to?
Markus Zoeller
mzoeller at linux.vnet.ibm.com
Tue Aug 22 12:24:29 UTC 2017
On 22.08.2017 09:46, Flávio Ramalho wrote:
> 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
Oh, I didn't see those variables, good hint! I'll give it a try, maybe
that's good enough for me. Thanks a lot Flavio!
http://git.openstack.org/cgit/openstack/openstack-ansible-os_nova/tree/templates/nova.conf.j2
Despite that this will probably work, is that an "interface" I'm allowed
to touch or is it considered an "internal/private" part of
OpenStack-Ansible (and/or its roles)?
--
Regards, Markus Zoeller (markus_z)
> 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
>>>
>>>
More information about the OpenStack-dev
mailing list