Skip to content

Commit 0822da4

Browse files
committed
Fix: added customizable ansibleEE env ConfigMap name
Currently there is only one hardcoded string `openstack-aee-default-env` for ansibleEE environment variable, which is applied throughout the cluser. This PR tries to let users ability to customize the ansibleEE env configMap for deployments and nodeset levels individually. The precedence order for ansibleEEEnvConfigMap is deployment > nodeset > default.
1 parent 38e6308 commit 0822da4

11 files changed

Lines changed: 247 additions & 5 deletions

api/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ spec:
5959
description: OpenStackDataPlaneDeploymentSpec defines the desired state
6060
of OpenStackDataPlaneDeployment
6161
properties:
62+
ansibleEEEnvConfigMapName:
63+
description: |-
64+
AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
65+
variables to inject into the Ansible Execution Environment pod.
66+
If set, this takes precedence over the NodeSet's AnsibleEEEnvConfigMapName.
67+
If not specified, the NodeSet's AnsibleEEEnvConfigMapName is used, or the
68+
default "openstack-aee-default-env" if neither is set.
69+
maxLength: 253
70+
type: string
6271
ansibleExtraVars:
6372
description: AnsibleExtraVars for ansible execution
6473
x-kubernetes-preserve-unknown-fields: true

api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ spec:
5555
description: OpenStackDataPlaneNodeSetSpec defines the desired state of
5656
OpenStackDataPlaneNodeSet
5757
properties:
58+
ansibleEEEnvConfigMapName:
59+
default: openstack-aee-default-env
60+
description: |-
61+
AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
62+
variables to inject into the Ansible Execution Environment pod.
63+
The ConfigMap should contain environment variables used by ansible-runner
64+
such as ANSIBLE_VERBOSITY, ANSIBLE_FORCE_COLOR, or other runner settings.
65+
See https://ansible.readthedocs.io/projects/runner/en/stable/intro/#env-settings-settings-for-runner-itself
66+
If not specified, defaults to "openstack-aee-default-env".
67+
This can be overridden at the Deployment level.
68+
maxLength: 253
69+
type: string
5870
baremetalSetTemplate:
5971
description: BaremetalSetTemplate Template for BaremetalSet for the
6072
NodeSet

api/dataplane/v1beta1/common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,7 @@ type AnsibleEESpec struct {
198198
// the ansible execution run with. Without specifying, it will run with
199199
// default serviceaccount
200200
ServiceAccountName string
201+
// AnsibleEEEnvConfigMapName is the name of ConfigMap containing environment
202+
// variables to inject to the Ansible execution environment pod.
203+
AnsibleEEEnvConfigMapName string `json:"ansibleEEEnvConfigMapName,omitempty"`
201204
}

api/dataplane/v1beta1/openstackdataplanedeployment_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ type OpenStackDataPlaneDeploymentSpec struct {
7171
// +kubebuilder:validation:Optional
7272
// AnsibleJobNodeSelector to target subset of worker nodes running the ansible jobs
7373
AnsibleJobNodeSelector map[string]string `json:"ansibleJobNodeSelector,omitempty"`
74+
75+
// +kubebuilder:validation:Optional
76+
// +kubebuilder:validation:MaxLength:=253
77+
// AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
78+
// variables to inject into the Ansible Execution Environment pod.
79+
// If set, this takes precedence over the NodeSet's AnsibleEEEnvConfigMapName.
80+
// If not specified, the NodeSet's AnsibleEEEnvConfigMapName is used, or the
81+
// default "openstack-aee-default-env" if neither is set.
82+
AnsibleEEEnvConfigMapName string `json:"ansibleEEEnvConfigMapName,omitempty"`
7483
}
7584

7685
// OpenStackDataPlaneDeploymentStatus defines the observed state of OpenStackDataPlaneDeployment

api/dataplane/v1beta1/openstackdataplanenodeset_types.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ type OpenStackDataPlaneNodeSetSpec struct {
8686
// +kubebuilder:default=true
8787
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
8888
TLSEnabled bool `json:"tlsEnabled" yaml:"tlsEnabled"`
89+
90+
// +kubebuilder:validation:Optional
91+
// +kubebuilder:default="openstack-aee-default-env"
92+
// +kubebuilder:validation:MaxLength:=253
93+
// AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
94+
// variables to inject into the Ansible Execution Environment pod.
95+
// The ConfigMap should contain environment variables used by ansible-runner
96+
// such as ANSIBLE_VERBOSITY, ANSIBLE_FORCE_COLOR, or other runner settings.
97+
// See https://ansible.readthedocs.io/projects/runner/en/stable/intro/#env-settings-settings-for-runner-itself
98+
// If not specified, defaults to "openstack-aee-default-env".
99+
// This can be overridden at the Deployment level.
100+
AnsibleEEEnvConfigMapName string `json:"ansibleEEEnvConfigMapName,omitempty"`
89101
}
90102

91103
// +kubebuilder:object:root=true
@@ -205,10 +217,11 @@ func (instance *OpenStackDataPlaneNodeSet) InitConditions() {
205217
// GetAnsibleEESpec - get the fields that will be passed to AEE Job
206218
func (instance OpenStackDataPlaneNodeSet) GetAnsibleEESpec() AnsibleEESpec {
207219
return AnsibleEESpec{
208-
NetworkAttachments: instance.Spec.NetworkAttachments,
209-
ExtraMounts: instance.Spec.NodeTemplate.ExtraMounts,
210-
Env: instance.Spec.Env,
211-
ServiceAccountName: instance.Name,
220+
NetworkAttachments: instance.Spec.NetworkAttachments,
221+
ExtraMounts: instance.Spec.NodeTemplate.ExtraMounts,
222+
Env: instance.Spec.Env,
223+
ServiceAccountName: instance.Name,
224+
AnsibleEEEnvConfigMapName: instance.Spec.AnsibleEEEnvConfigMapName,
212225
}
213226
}
214227

bindata/crds/crds.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17144,6 +17144,15 @@ spec:
1714417144
description: OpenStackDataPlaneDeploymentSpec defines the desired state
1714517145
of OpenStackDataPlaneDeployment
1714617146
properties:
17147+
ansibleEEEnvConfigMapName:
17148+
description: |-
17149+
AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
17150+
variables to inject into the Ansible Execution Environment pod.
17151+
If set, this takes precedence over the NodeSet's AnsibleEEEnvConfigMapName.
17152+
If not specified, the NodeSet's AnsibleEEEnvConfigMapName is used, or the
17153+
default "openstack-aee-default-env" if neither is set.
17154+
maxLength: 253
17155+
type: string
1714717156
ansibleExtraVars:
1714817157
description: AnsibleExtraVars for ansible execution
1714917158
x-kubernetes-preserve-unknown-fields: true
@@ -17399,6 +17408,18 @@ spec:
1739917408
description: OpenStackDataPlaneNodeSetSpec defines the desired state of
1740017409
OpenStackDataPlaneNodeSet
1740117410
properties:
17411+
ansibleEEEnvConfigMapName:
17412+
default: openstack-aee-default-env
17413+
description: |-
17414+
AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
17415+
variables to inject into the Ansible Execution Environment pod.
17416+
The ConfigMap should contain environment variables used by ansible-runner
17417+
such as ANSIBLE_VERBOSITY, ANSIBLE_FORCE_COLOR, or other runner settings.
17418+
See https://ansible.readthedocs.io/projects/runner/en/stable/intro/#env-settings-settings-for-runner-itself
17419+
If not specified, defaults to "openstack-aee-default-env".
17420+
This can be overridden at the Deployment level.
17421+
maxLength: 253
17422+
type: string
1740217423
baremetalSetTemplate:
1740317424
description: BaremetalSetTemplate Template for BaremetalSet for the
1740417425
NodeSet

config/crd/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ spec:
5959
description: OpenStackDataPlaneDeploymentSpec defines the desired state
6060
of OpenStackDataPlaneDeployment
6161
properties:
62+
ansibleEEEnvConfigMapName:
63+
description: |-
64+
AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
65+
variables to inject into the Ansible Execution Environment pod.
66+
If set, this takes precedence over the NodeSet's AnsibleEEEnvConfigMapName.
67+
If not specified, the NodeSet's AnsibleEEEnvConfigMapName is used, or the
68+
default "openstack-aee-default-env" if neither is set.
69+
maxLength: 253
70+
type: string
6271
ansibleExtraVars:
6372
description: AnsibleExtraVars for ansible execution
6473
x-kubernetes-preserve-unknown-fields: true

config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ spec:
5555
description: OpenStackDataPlaneNodeSetSpec defines the desired state of
5656
OpenStackDataPlaneNodeSet
5757
properties:
58+
ansibleEEEnvConfigMapName:
59+
default: openstack-aee-default-env
60+
description: |-
61+
AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
62+
variables to inject into the Ansible Execution Environment pod.
63+
The ConfigMap should contain environment variables used by ansible-runner
64+
such as ANSIBLE_VERBOSITY, ANSIBLE_FORCE_COLOR, or other runner settings.
65+
See https://ansible.readthedocs.io/projects/runner/en/stable/intro/#env-settings-settings-for-runner-itself
66+
If not specified, defaults to "openstack-aee-default-env".
67+
This can be overridden at the Deployment level.
68+
maxLength: 253
69+
type: string
5870
baremetalSetTemplate:
5971
description: BaremetalSetTemplate Template for BaremetalSet for the
6072
NodeSet

internal/controller/dataplane/openstackdataplanedeployment_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
288288
ansibleEESpec.AnsibleSkipTags = instance.Spec.AnsibleSkipTags
289289
ansibleEESpec.AnsibleLimit = instance.Spec.AnsibleLimit
290290
ansibleEESpec.ExtraVars = instance.Spec.AnsibleExtraVars
291+
// override the ansibleEEEnvConfigMapName on nodeset if there is any provided for a specific deployment.
292+
if instance.Spec.AnsibleEEEnvConfigMapName != "" {
293+
ansibleEESpec.AnsibleEEEnvConfigMapName = instance.Spec.AnsibleEEEnvConfigMapName
294+
}
291295

292296
if nodeSet.Status.DNSClusterAddresses != nil && nodeSet.Status.CtlplaneSearchDomain != "" {
293297
ansibleEESpec.DNSConfig = &corev1.PodDNSConfig{

internal/dataplane/util/ansible_execution.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,18 @@ func AnsibleExecution(
6565
return nil
6666
}
6767

68+
// Fallback for backwards compatibility with existing NodeSets created
69+
// before ansibleEEEnvConfigMapName field was added
70+
envConfigMapName := aeeSpec.AnsibleEEEnvConfigMapName
71+
if envConfigMapName == "" {
72+
envConfigMapName = "openstack-aee-default-env"
73+
}
74+
6875
ansibleEE := EEJob{
6976
Name: executionName,
7077
Namespace: deployment.GetNamespace(),
7178
Labels: labels,
72-
EnvConfigMapName: "openstack-aee-default-env",
79+
EnvConfigMapName: envConfigMapName,
7380
}
7481

7582
ansibleEE.NetworkAttachments = aeeSpec.NetworkAttachments

0 commit comments

Comments
 (0)