Skip to content

Commit

Permalink
Added controller for running ansible playbooks
Browse files Browse the repository at this point in the history
This addition should be flexible enough to run
ansible playbooks for testing popuses.
it is dependent on this patch
openstack-k8s-operators/tcib#182
  • Loading branch information
Ella Shulman authored and eshulman2 committed Jul 2, 2024
1 parent 3e04b6c commit 2692b58
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
6 changes: 3 additions & 3 deletions config/rbac/ansibleTests_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ metadata:
app.kubernetes.io/created-by: test-operator
app.kubernetes.io/part-of: test-operator
app.kubernetes.io/managed-by: kustomize
name: ansibleTests-editor-role
name: ansibletests-editor-role
rules:
- apiGroups:
- test.openstack.org
resources:
- ansibleTests
- ansibletests
verbs:
- create
- delete
Expand All @@ -26,6 +26,6 @@ rules:
- apiGroups:
- test.openstack.org
resources:
- ansibleTests/status
- ansibletests/status
verbs:
- get
6 changes: 3 additions & 3 deletions config/rbac/ansibleTests_viewer_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ metadata:
app.kubernetes.io/created-by: test-operator
app.kubernetes.io/part-of: test-operator
app.kubernetes.io/managed-by: kustomize
name: ansibleTests-viewer-role
name: ansibletests-viewer-role
rules:
- apiGroups:
- test.openstack.org
resources:
- ansibleTests
- ansibletests
verbs:
- get
- list
- watch
- apiGroups:
- test.openstack.org
resources:
- ansibleTests/status
- ansibletests/status
verbs:
- get
6 changes: 3 additions & 3 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ rules:
- apiGroups:
- test.openstack.org
resources:
- ansibleTests
- ansibletests
verbs:
- create
- delete
Expand All @@ -133,13 +133,13 @@ rules:
- apiGroups:
- test.openstack.org
resources:
- ansibleTests/finalizers
- ansibletests/finalizers
verbs:
- update
- apiGroups:
- test.openstack.org
resources:
- ansibleTests/status
- ansibletests/status
verbs:
- get
- patch
Expand Down
44 changes: 23 additions & 21 deletions pkg/ansibleTests/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,23 @@ func GetVolumes(
volumes = append(volumes, extraVol)
}

for _, vol := range instance.Spec.Workflow[externalWorkflowCounter].ExtraMounts {
extraWorkflowVol := corev1.Volume{
Name: vol.Name,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: &publicInfoMode,
LocalObjectReference: corev1.LocalObjectReference{
Name: vol.Name,
if len(instance.Spec.Workflow) > 0 {
for _, vol := range instance.Spec.Workflow[externalWorkflowCounter].ExtraMounts {
extraWorkflowVol := corev1.Volume{
Name: vol.Name,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
DefaultMode: &publicInfoMode,
LocalObjectReference: corev1.LocalObjectReference{
Name: vol.Name,
},
},
},
},
}
}

volumes = append(volumes, extraWorkflowVol)
volumes = append(volumes, extraWorkflowVol)
}
}

return volumes
}

Expand Down Expand Up @@ -229,17 +230,18 @@ func GetVolumeMounts(mountCerts bool, instance *testv1beta1.AnsibleTests, extern
volumeMounts = append(volumeMounts, extraMounts)
}

for _, vol := range instance.Spec.Workflow[externalWorkflowCounter].ExtraMounts {
if len(instance.Spec.Workflow) > 0 {
for _, vol := range instance.Spec.Workflow[externalWorkflowCounter].ExtraMounts {

extraMounts := corev1.VolumeMount{
Name: vol.Name,
MountPath: vol.MountPath,
SubPath: vol.SubPath,
ReadOnly: true,
}
extraMounts := corev1.VolumeMount{
Name: vol.Name,
MountPath: vol.MountPath,
SubPath: vol.SubPath,
ReadOnly: true,
}

volumeMounts = append(volumeMounts, extraMounts)
volumeMounts = append(volumeMounts, extraMounts)
}
}

return volumeMounts
}

0 comments on commit 2692b58

Please sign in to comment.