Skip to content

Adding per node incus config options - #103

Merged
stgraber merged 1 commit into
lxc:mainfrom
tibeer:feature/per_node_incus_config_settings
Sep 29, 2026
Merged

stgraber merged 1 commit into
lxc:mainfrom
tibeer:feature/per_node_incus_config_settings

Conversation

@tibeer

@tibeer tibeer commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

The normal "incus config set" was only executed on one node when in cluster mode.
This works for nearly all settings, except some like:

  • core.bgp_address
  • core.bgp_routerid
  • core.https_address
    and so on. These need to be set for each node individually.

The logic allows you to use a new variable per host called "incus_init_config_per_node" to specify those.
Unfortunately, the executing needs to be done after the initial handler for the cluster wide config options
is executed, therefore the hacky use of 'ansible.builtin.command: /bin/true'. Handler registers are stored in
an ordered list.

Signed-off-by: Tim Beermann tibeer@berryit.de

@tibeer

tibeer commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

Happy to discuss if there are other ideas for per node configuration :)

Comment thread ansible/hosts.yaml.example Resolved
Comment thread ansible/README.md Outdated
- `standalone`
- `cluster`
- `ui`: Whether to serve the Incus UI
- `incus_init_config_per_node`: Per node configuration data (type: dict)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to have it be under the incus_init?

Say local_config under incus_init with config being for the global config.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also thinking about that, but having both incus_init in the group vars as well as incus_init in the host wars would make the host vars win and therefore overwrite the group vars. There is an option to set ansible to merge those dicts, but this would apply to everything, which is most likely not desired.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I agree, I also do not like my solution either. Either way, it feels kind of wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could maybe use something like this:

- name: Merge host-specific config into incus_init
  ansible.builtin.set_fact:
    incus_init: "{{ incus_init | combine( {'local_config': local_config | default({}) } ) }}"

in the tasks to combine variables, but it would still require the individual host vars to have local_config, while the group vars keep incus_init['config']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases your local_config would still be templated so would be fine in a group section. If it needs specific host variables, you can have it defined in the group with a template that picks up the local host var.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, pushed a new version. Still need a good example though for the normal cluster config section, or should I just leave out the example changes entirely?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the example you've put in place looks good.

@tibeer
tibeer force-pushed the feature/per_node_incus_config_settings branch 2 times, most recently from 1b7f6cd to 19fe8ee Compare September 29, 2026 12:45
Comment thread ansible/hosts.yaml.example Outdated

incus_init:
config:
acme.domain: "incus.example.com"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, that would be bad as an example, maybe set user.ui.title instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user.ui.title: "My cluster" would be a safe global example to use.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :)

The normal "incus config set" was only executed on one node when in cluster mode.
This works for nearly all settings, except some like:
- core.bgp_address
- core.bgp_routerid
- core.https_address
and so on. These need to be set for each node individually.

The logic allows you to use a new variable per host called "incus_init_config_per_node" to specify those.
Unfortunately, the executing needs to be done after the initial handler for the cluster wide config options
is executed, therefore the hacky use of 'ansible.builtin.command: /bin/true'. Handler registers are stored in
an ordered list.

Signed-off-by: Tim Beermann <tibeer@berryit.de>
@tibeer
tibeer force-pushed the feature/per_node_incus_config_settings branch from 19fe8ee to fcbe175 Compare September 29, 2026 12:56
@stgraber
stgraber merged commit 7b71f48 into lxc:main Sep 29, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants