Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#152 from fao89/identifier
Browse files Browse the repository at this point in the history
Document log persistence
  • Loading branch information
openshift-merge-robot authored May 11, 2023
2 parents 4c14ffa + a3f50d7 commit 07c2e0a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
16 changes: 16 additions & 0 deletions controllers/openstack_ansibleee_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apiserver/pkg/storage/names"

"context"

Expand Down Expand Up @@ -256,6 +257,21 @@ func (r *OpenStackAnsibleEEReconciler) jobForOpenStackAnsibleEE(instance *redhat
args = []string{"ansible-runner", "run", "/runner", "-p", instance.Spec.Playbook}
}

hasIdentifier := false
for _, arg := range args {
// ansible runner identifier
// https://ansible-runner.readthedocs.io/en/stable/intro/#artifactdir
if arg == "-i" || arg == "--ident" {
hasIdentifier = true
break
}
}

if !hasIdentifier {
identifier := names.SimpleNameGenerator.GenerateName(fmt.Sprintf("%s-", instance.Name))
args = append(args, []string{"-i", identifier}...)
}

job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: instance.Name,
Expand Down
28 changes: 28 additions & 0 deletions docs/logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Persistent logs

For enabling persistent logging, you need to mount `/runner/artifacts` into a [persistent Volume](https://kubernetes.io/docs/concepts/storage/volumes/) through `extraMounts` field.

#### Example:
```yaml
apiVersion: ansibleee.openstack.org/v1alpha1
kind: OpenStackAnsibleEE
metadata:
name: ansibleee-logs
namespace: openstack
spec:
playbook: "test.yaml"
image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest
inventory: |
all:
hosts:
localhost
extraMounts:
- extraVolType: Logs
volumes:
- name: ansible-logs
persistentVolumeClaim:
claimName: openstack-ansible-logs
mounts:
- name: ansible-logs
mountPath: "/runner/artifacts"
```
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.26.3
k8s.io/apimachinery v0.26.3
k8s.io/apiserver v0.26.2
k8s.io/client-go v0.26.3
sigs.k8s.io/controller-runtime v0.14.6
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ k8s.io/apiextensions-apiserver v0.26.2 h1:/yTG2B9jGY2Q70iGskMf41qTLhL9XeNN2KhI0u
k8s.io/apiextensions-apiserver v0.26.2/go.mod h1:Y7UPgch8nph8mGCuVk0SK83LnS8Esf3n6fUBgew8SH8=
k8s.io/apimachinery v0.26.3 h1:dQx6PNETJ7nODU3XPtrwkfuubs6w7sX0M8n61zHIV/k=
k8s.io/apimachinery v0.26.3/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I=
k8s.io/apiserver v0.26.2 h1:Pk8lmX4G14hYqJd1poHGC08G03nIHVqdJMR0SD3IH3o=
k8s.io/apiserver v0.26.2/go.mod h1:GHcozwXgXsPuOJ28EnQ/jXEM9QeG6HT22YxSNmpYNh8=
k8s.io/client-go v0.26.3 h1:k1UY+KXfkxV2ScEL3gilKcF7761xkYsSD6BC9szIu8s=
k8s.io/client-go v0.26.3/go.mod h1:ZPNu9lm8/dbRIPAgteN30RSXea6vrCpFvq+MateTUuQ=
k8s.io/component-base v0.26.2 h1:IfWgCGUDzrD6wLLgXEstJKYZKAFS2kO+rBRi0p3LqcI=
Expand Down
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ nav:
- Home: index.md
- Custom Resources:
- OpenStackAnsibleEE: openstack_ansibleee.md
- Config:
- Logs: logs.md
- Contributing: contributing.md
markdown_extensions:
- toc:
Expand Down

0 comments on commit 07c2e0a

Please sign in to comment.