Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Allow to change group names used in conditions to be able to use with bigger inventories #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghormoon
Copy link
Contributor

@ghormoon ghormoon commented Mar 30, 2024

This draft tries to solve the issue that in all conditions etc, there are used generic group names, even 'all'.
If you attempt to use an inventory that has also other hosts in other groups, the counting of nodes is failing and eg one node clusters don't trigger their one-node specific tasks.

I've created a way to rename the gropus used in when: and simmilar conditions. Note that this is NOT possible for hosts: in a play, because it will not pull the value from group_vars. So if you want to run it against only one cluster, you still need to use -l name_of_the_cluster_all_group

So far it's tested only on one node clusters, so more testing needs to be done, but at least it allows to coexist with other playbooks with one inventory and multiple clusters should work. You just need to add the specific groups to the generic one, because of the hosts:, eg.

[kube_prod_cluster:children]
kube_prod_cluster_masters
kube_prod_cluster_nodes

[kube_lab_cluster:children]
kube_lab_cluster_masters
kube_lab_cluster_nodes


[masters:children]
kube_lab_cluster_masters
kube_prod_cluster_masters

[primary-master:children]
kube_lab_cluster_primary_master
kube_prod_cluster_primary_master

[secondary-masters:children]
kube_lab_cluster_secondary_masters
kube_prod_cluster_secondary_masters

[nodes:children]
kube_lab_cluster_nodes
kube_prod_cluster_nodes

and then you remap it in the group_vars/kube_lab_cluster like this (and analogically in group_vars/kube_prod_cluster)

cluster_inventory_group:
  all: kube_lab_cluster
  masters: kube_lab_cluster_masters
  primary_master: kube_lab_cluster_primary_master
  secondary_masters: kube_lab_cluster_secondary_masters
  nodes: kube_lab_cluster_nodes

@ReSearchITEng
Copy link
Owner

Doing this way is going to be backward compatible if I understand well?
We must make sure the old hosts files will keep working transparently, and only when someone wants to install multiple clusters from the same hosts file would have to adopt the new changes, correct?

@ghormoon
Copy link
Contributor Author

ghormoon commented Apr 3, 2024

yes, i believe it is, but i only tested with 1 node cluster in my lab. need to test with bigger clusters before finalizing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants