@@ -33,6 +33,7 @@ import (
3333 job "github.com/openstack-k8s-operators/lib-common/modules/common/job"
3434 nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment"
3535 common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac"
36+ "github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3637 oko_secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3738 "github.com/openstack-k8s-operators/lib-common/modules/common/service"
3839 "github.com/openstack-k8s-operators/lib-common/modules/common/statefulset"
@@ -415,6 +416,22 @@ func (r *IronicInspectorReconciler) findObjectsForSrc(ctx context.Context, src c
415416 return requests
416417}
417418
419+ func (r * IronicInspectorReconciler ) getTransportURL (
420+ ctx context.Context ,
421+ h * helper.Helper ,
422+ instance * ironicv1.IronicInspector ,
423+ ) (string , error ) {
424+ transportURLSecret , _ , err := secret .GetSecret (ctx , h , instance .Status .TransportURLSecret , instance .Namespace )
425+ if err != nil {
426+ return "" , err
427+ }
428+ transportURL , ok := transportURLSecret .Data ["transport_url" ]
429+ if ! ok {
430+ return "" , fmt .Errorf ("transport_url %w Transport Secret" , util .ErrNotFound )
431+ }
432+ return string (transportURL ), nil
433+ }
434+
418435func (r * IronicInspectorReconciler ) reconcileTransportURL (
419436 ctx context.Context ,
420437 instance * ironicv1.IronicInspector ,
@@ -589,15 +606,9 @@ func (r *IronicInspectorReconciler) reconcileConfigMapsAndSecrets(
589606 // calculate an overall hash of hashes
590607 //
591608
592- //
593- // create Configmap required for ironic input
594- // - %-scripts configmap holding scripts to e.g. bootstrap the service
595- // - %-config configmap holding minimal ironic config required to get the
596- // service up, user can add additional files to be added to the service
597- // - parameters which has passwords gets added from the OpenStack secret
598- // via the init container
599- //
600- err = r .generateServiceConfigMaps (
609+ // create Secret required for ironicneutronagent input. It contains minimal ironicneutronagent config required
610+ // to get the service up, user can add additional files to be added to the service.
611+ err = r .generateServiceSecrets (
601612 ctx ,
602613 instance ,
603614 helper ,
@@ -1411,24 +1422,16 @@ func (r *IronicInspectorReconciler) reconcileUpgrade(
14111422 return ctrl.Result {}, nil
14121423}
14131424
1414- // generateServiceConfigMaps - create create configmaps which hold scripts and service configuration
1425+ // generateServiceSecrets - create secrets which hold service configuration
14151426// TODO add DefaultConfigOverwrite
1416- func (r * IronicInspectorReconciler ) generateServiceConfigMaps (
1427+ func (r * IronicInspectorReconciler ) generateServiceSecrets (
14171428 ctx context.Context ,
14181429 instance * ironicv1.IronicInspector ,
14191430 h * helper.Helper ,
14201431 envVars * map [string ]env.Setter ,
14211432 db * mariadbv1.Database ,
14221433) error {
1423- //
1424- // create Configmap/Secret required for ironic-inspector input
1425- // - %-scripts configmap holding scripts to e.g. bootstrap the service
1426- // - %-config configmap holding minimal ironic-inspector config required
1427- // to get the service up, user can add additional files to be added to
1428- // the service
1429- // - parameters which has passwords gets added from the ospSecret via the
1430- // init container
1431- //
1434+ // Create/update secrets from templates
14321435 cmLabels := labels .GetLabels (
14331436 instance ,
14341437 labels .GetGroupLabel (ironic .ServiceName ),
@@ -1439,13 +1442,11 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
14391442 tlsCfg = & tls.Service {}
14401443 }
14411444 // customData hold any customization for the service.
1442- // custom.conf is going to /etc/ironic-inspector/inspector.conf.d
1443- // all other files get placed into /etc/ironic-inspector to allow
1444- // overwrite of e.g. policy.json.
1445- // TODO: make sure custom.conf can not be overwritten
1445+ // 02-inspector-custom.conf is going to /etc/ironic-inspector/inspector.conf.d
1446+ // 01-inspector.conf is going to /etc/ironic-inspector/inspector such that it gets loaded before custom one
14461447 customData := map [string ]string {
1447- common . CustomServiceConfigFileName : instance .Spec .CustomServiceConfig ,
1448- "my.cnf" : db .GetDatabaseClientConfig (tlsCfg ), //(mschuppert) for now just get the default my.cnf
1448+ "02-inspector-custom.conf" : instance .Spec .CustomServiceConfig ,
1449+ "my.cnf" : db .GetDatabaseClientConfig (tlsCfg ), //(mschuppert) for now just get the default my.cnf
14491450 }
14501451 for key , data := range instance .Spec .DefaultConfigOverwrite {
14511452 customData [key ] = data
@@ -1467,9 +1468,30 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
14671468 return err
14681469 }
14691470
1471+ transportURL , err := r .getTransportURL (ctx , h , instance )
1472+ if err != nil {
1473+ return err
1474+ }
1475+
1476+ ospSecret , _ , err := secret .GetSecret (ctx , h , instance .Spec .Secret , instance .Namespace )
1477+ if err != nil {
1478+ return err
1479+ }
1480+
1481+ servicePassword := string (ospSecret .Data [instance .Spec .PasswordSelectors .Service ])
1482+
14701483 templateParameters ["ServiceUser" ] = instance .Spec .ServiceUser
1484+ templateParameters ["ServicePassword" ] = servicePassword
14711485 templateParameters ["KeystoneInternalURL" ] = keystoneInternalURL
14721486 templateParameters ["KeystonePublicURL" ] = keystonePublicURL
1487+ templateParameters ["TransportURL" ] = transportURL
1488+
1489+ // Other OpenStack services
1490+ templateParameters ["ServicePassword" ] = servicePassword
1491+ templateParameters ["keystone_authtoken" ] = servicePassword
1492+ templateParameters ["service_catalog" ] = servicePassword
1493+ templateParameters ["ironic" ] = servicePassword
1494+ templateParameters ["swift" ] = servicePassword
14731495 } else {
14741496 ironicAPI , err := ironicv1 .GetIronicAPI (
14751497 ctx , h , instance .Namespace , map [string ]string {})
@@ -1516,20 +1538,6 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
15161538 templateParameters ["TimeOut" ] = instance .Spec .APITimeout
15171539
15181540 cms := []util.Template {
1519- // Scripts ConfigMap
1520- {
1521- Name : fmt .Sprintf ("%s-scripts" , instance .Name ),
1522- Namespace : instance .Namespace ,
1523- Type : util .TemplateTypeScripts ,
1524- InstanceType : instance .Kind ,
1525- AdditionalTemplate : map [string ]string {
1526- "common.sh" : "/common/bin/common.sh" ,
1527- "get_net_ip" : "/common/bin/get_net_ip" ,
1528- "runlogwatch.sh" : "/common/bin/runlogwatch.sh" ,
1529- "pxe-init.sh" : "/common/bin/pxe-init.sh" ,
1530- },
1531- Labels : cmLabels ,
1532- },
15331541 // ConfigMap
15341542 {
15351543 Name : fmt .Sprintf ("%s-config-data" , instance .Name ),
0 commit comments