kubeadm-playbook
kubeadm-playbook copied to clipboard
Draft: Allow to change group names used in conditions to be able to use with bigger inventories
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
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?
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