Skip to content

Commit 7a2c695

Browse files
oliashishopenshift-cherrypick-robot
authored andcommitted
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 46eab35 commit 7a2c695

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
@@ -18370,6 +18370,15 @@ spec:
1837018370
description: OpenStackDataPlaneDeploymentSpec defines the desired state
1837118371
of OpenStackDataPlaneDeployment
1837218372
properties:
18373+
ansibleEEEnvConfigMapName:
18374+
description: |-
18375+
AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
18376+
variables to inject into the Ansible Execution Environment pod.
18377+
If set, this takes precedence over the NodeSet's AnsibleEEEnvConfigMapName.
18378+
If not specified, the NodeSet's AnsibleEEEnvConfigMapName is used, or the
18379+
default "openstack-aee-default-env" if neither is set.
18380+
maxLength: 253
18381+
type: string
1837318382
ansibleExtraVars:
1837418383
description: AnsibleExtraVars for ansible execution
1837518384
x-kubernetes-preserve-unknown-fields: true
@@ -18625,6 +18634,18 @@ spec:
1862518634
description: OpenStackDataPlaneNodeSetSpec defines the desired state of
1862618635
OpenStackDataPlaneNodeSet
1862718636
properties:
18637+
ansibleEEEnvConfigMapName:
18638+
default: openstack-aee-default-env
18639+
description: |-
18640+
AnsibleEEEnvConfigMapName is the name of the ConfigMap containing environment
18641+
variables to inject into the Ansible Execution Environment pod.
18642+
The ConfigMap should contain environment variables used by ansible-runner
18643+
such as ANSIBLE_VERBOSITY, ANSIBLE_FORCE_COLOR, or other runner settings.
18644+
See https://ansible.readthedocs.io/projects/runner/en/stable/intro/#env-settings-settings-for-runner-itself
18645+
If not specified, defaults to "openstack-aee-default-env".
18646+
This can be overridden at the Deployment level.
18647+
maxLength: 253
18648+
type: string
1862818649
baremetalSetTemplate:
1862918650
description: BaremetalSetTemplate Template for BaremetalSet for the
1863018651
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
@@ -66,11 +66,18 @@ func AnsibleExecution(
6666
return nil
6767
}
6868

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

7683
ansibleEE.NetworkAttachments = aeeSpec.NetworkAttachments

0 commit comments

Comments
 (0)