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 3, 2024
1 parent 3e04b6c commit 7d446ec
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 122 deletions.
16 changes: 8 additions & 8 deletions api/bases/test.openstack.org_ansibletests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ metadata:
spec:
group: test.openstack.org
names:
kind: AnsibleTests
listKind: AnsibleTestsList
kind: AnsibleTest
listKind: AnsibleTestList
plural: ansibletests
singular: ansibletests
singular: ansibletest
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: AnsibleTestsStatus is the Schema for the AnsibleTestsStatus API
description: AnsibleTestStatus is the Schema for the AnsibleTestStatus API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -33,7 +33,7 @@ spec:
metadata:
type: object
spec:
description: AnsibleTestsSpec defines the desired state of AnsibleTests
description: AnsibleTestSpec defines the desired state of AnsibleTest
properties:
ansibleCollections:
default: ""
Expand Down Expand Up @@ -77,7 +77,7 @@ spec:
type: string
containerImage:
default: quay.io/podified-antelope-centos9/openstack-ansible-tests:current-podified
description: Container image for AnsibleTests
description: Container image for AnsibleTest
type: string
debug:
default: false
Expand Down Expand Up @@ -157,7 +157,7 @@ spec:
to ~/.ssh/id_ecdsa in the ansible pod
type: string
containerImage:
description: Container image for AnsibleTests
description: Container image for AnsibleTest
type: string
debug:
description: Run ansible playbook with -vvvv
Expand Down Expand Up @@ -223,7 +223,7 @@ spec:
- workloadSSHKeySecretName
type: object
status:
description: AnsibleTestsStatus defines the observed state of AnsibleTests
description: AnsibleTestStatus defines the observed state of AnsibleTest
properties:
conditions:
description: Conditions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type extraConfigmapsMounts struct {
SubPath string `json:"subPath"`
}

// AnsibleTestsSpec defines the desired state of AnsibleTests
type AnsibleTestsSpec struct {
// AnsibleTestSpec defines the desired state of AnsibleTest
type AnsibleTestSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +kubebuilder:validation:Optional
// Extra configmaps for mounting in the pod.
Expand Down Expand Up @@ -126,7 +126,7 @@ type AnsibleTestsSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +kubebuilder:validation:Optional
// +kubebuilder:default:="quay.io/podified-antelope-centos9/openstack-ansible-tests:current-podified"
// Container image for AnsibleTests
// Container image for AnsibleTest
ContainerImage string `json:"containerImage,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec
Expand All @@ -139,10 +139,10 @@ type AnsibleTestsSpec struct {
// A parameter that contains a workflow definition.
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number"}
Workflow []AnsibleTestsWorkflowSpec `json:"workflow,omitempty"`
Workflow []AnsibleTestWorkflowSpec `json:"workflow,omitempty"`
}

type AnsibleTestsWorkflowSpec struct {
type AnsibleTestWorkflowSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +kubebuilder:validation:Optional
// Extra configmaps for mounting in the pod
Expand Down Expand Up @@ -219,7 +219,7 @@ type AnsibleTestsWorkflowSpec struct {

// +operator-sdk:csv:customresourcedefinitions:type=spec
// +kubebuilder:validation:Optional
// Container image for AnsibleTests
// Container image for AnsibleTest
ContainerImage string `json:"containerImage,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=spec
Expand All @@ -228,8 +228,8 @@ type AnsibleTestsWorkflowSpec struct {
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
}

// AnsibleTestsStatus defines the observed state of AnsibleTests
type AnsibleTestsStatus struct {
// AnsibleTestStatus defines the observed state of AnsibleTest
type AnsibleTestStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

Expand All @@ -246,39 +246,39 @@ type AnsibleTestsStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// AnsibleTestsStatus is the Schema for the AnsibleTestsStatus API
type AnsibleTests struct {
// AnsibleTestStatus is the Schema for the AnsibleTestStatus API
type AnsibleTest struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AnsibleTestsSpec `json:"spec,omitempty"`
Status AnsibleTestsStatus `json:"status,omitempty"`
Spec AnsibleTestSpec `json:"spec,omitempty"`
Status AnsibleTestStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// AnsibleTestsList contains a list of AnsibleTests
type AnsibleTestsList struct {
// AnsibleTestList contains a list of AnsibleTest
type AnsibleTestList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AnsibleTests `json:"items"`
Items []AnsibleTest `json:"items"`
}

func init() {
SchemeBuilder.Register(&AnsibleTests{}, &AnsibleTestsList{})
SchemeBuilder.Register(&AnsibleTest{}, &AnsibleTestList{})
}

// RbacConditionsSet - set the conditions for the rbac object
func (instance AnsibleTests) RbacConditionsSet(c *condition.Condition) {
func (instance AnsibleTest) RbacConditionsSet(c *condition.Condition) {
instance.Status.Conditions.Set(c)
}

// RbacNamespace - return the namespace
func (instance AnsibleTests) RbacNamespace() string {
func (instance AnsibleTest) RbacNamespace() string {
return instance.Namespace
}

// RbacResourceName - return the name to be used for rbac objects (serviceaccount, role, rolebinding)
func (instance AnsibleTests) RbacResourceName() string {
func (instance AnsibleTest) RbacResourceName() string {
return instance.Name
}
48 changes: 24 additions & 24 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions config/crd/bases/test.openstack.org_ansibletests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ metadata:
spec:
group: test.openstack.org
names:
kind: AnsibleTests
listKind: AnsibleTestsList
kind: AnsibleTest
listKind: AnsibleTestList
plural: ansibletests
singular: ansibletests
singular: ansibletest
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
description: AnsibleTestsStatus is the Schema for the AnsibleTestsStatus API
description: AnsibleTestStatus is the Schema for the AnsibleTestStatus API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -33,7 +33,7 @@ spec:
metadata:
type: object
spec:
description: AnsibleTestsSpec defines the desired state of AnsibleTests
description: AnsibleTestSpec defines the desired state of AnsibleTest
properties:
ansibleCollections:
default: ""
Expand Down Expand Up @@ -77,7 +77,7 @@ spec:
type: string
containerImage:
default: quay.io/podified-antelope-centos9/openstack-ansible-tests:current-podified
description: Container image for AnsibleTests
description: Container image for AnsibleTest
type: string
debug:
default: false
Expand Down Expand Up @@ -157,7 +157,7 @@ spec:
to ~/.ssh/id_ecdsa in the ansible pod
type: string
containerImage:
description: Container image for AnsibleTests
description: Container image for AnsibleTest
type: string
debug:
description: Run ansible playbook with -vvvv
Expand Down Expand Up @@ -223,7 +223,7 @@ spec:
- workloadSSHKeySecretName
type: object
status:
description: AnsibleTestsStatus defines the observed state of AnsibleTests
description: AnsibleTestStatus defines the observed state of AnsibleTest
properties:
conditions:
description: Conditions
Expand Down
2 changes: 1 addition & 1 deletion config/crd/patches/cainjection_in_ansibleTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: ansibleTest.test.openstack.org
name: ansibletests.test.openstack.org
2 changes: 1 addition & 1 deletion config/crd/patches/webhook_in_ansibleTests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: ansibleTest.test.openstack.org
name: ansibletests.test.openstack.org
spec:
conversion:
strategy: Webhook
Expand Down
1 change: 0 additions & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ kind: Kustomization
images:
- name: controller
newName: quay.io/openstack-k8s-operators/test-operator
newTag: latest
Loading

0 comments on commit 7d446ec

Please sign in to comment.