mirror of
https://github.com/ansible/awx-operator.git
synced 2026-03-27 05:43:11 +00:00
Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a6040e0cd | ||
|
|
24f3f440f1 | ||
|
|
87b0511997 | ||
|
|
fde4a47a14 | ||
|
|
af2e681f1e | ||
|
|
82ffa3d348 | ||
|
|
db6a5b53ed | ||
|
|
0be17476cd | ||
|
|
f4a781ccc5 | ||
|
|
fcd2c4c023 | ||
|
|
8e30a17a77 | ||
|
|
b3037c1067 | ||
|
|
f7ff132a2e | ||
|
|
5f06e90906 | ||
|
|
36355b6a15 | ||
|
|
bc08c4bbbe | ||
|
|
7697825944 | ||
|
|
8a325293b1 | ||
|
|
dd53a1d415 | ||
|
|
c5db0e7104 | ||
|
|
59036fc373 | ||
|
|
c45a7bd4d7 | ||
|
|
34b6354001 | ||
|
|
801f392447 | ||
|
|
779572e8ff | ||
|
|
e7e48f92a0 | ||
|
|
3cd9ddd8c6 | ||
|
|
4e6be0a82c | ||
|
|
05943687fe | ||
|
|
9676ebc008 | ||
|
|
8352237260 | ||
|
|
35d4954027 | ||
|
|
4d6a491766 | ||
|
|
fa9eb53f92 | ||
|
|
00c9f5fbd1 | ||
|
|
fe82e9259e | ||
|
|
635d530dc9 | ||
|
|
e966e9299f | ||
|
|
683d23dbea | ||
|
|
8b3a297086 | ||
|
|
15830e3536 | ||
|
|
ef46d7f49c | ||
|
|
a5328b1a09 | ||
|
|
0983220fba | ||
|
|
3ac0232e89 | ||
|
|
75c7231afd | ||
|
|
363aa3642b | ||
|
|
bf74d5cc34 | ||
|
|
46586bd7b6 | ||
|
|
191be7bf3c | ||
|
|
b7e5f235ad | ||
|
|
6cbc6a7234 | ||
|
|
beba6a900d | ||
|
|
7f72260445 | ||
|
|
5b7baa106d | ||
|
|
9380686395 | ||
|
|
0de966153d | ||
|
|
efaa4718ec | ||
|
|
e6a473b765 | ||
|
|
859384e9f6 | ||
|
|
b66a16508f | ||
|
|
3da427f31d | ||
|
|
9f2b51a6a9 | ||
|
|
5b73ad172e | ||
|
|
2227301707 | ||
|
|
9f63fc0da5 | ||
|
|
322aea970d | ||
|
|
c4bef95662 | ||
|
|
fa705f6466 |
3
.github/CODE_OF_CONDUCT.md
vendored
Normal file
3
.github/CODE_OF_CONDUCT.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Community Code of Conduct
|
||||
|
||||
Please see the official [Ansible Community Code of Conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
|
||||
39
.github/ISSUE_TEMPLATE/bug_report.md
vendored
39
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,39 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
##### ISSUE TYPE
|
||||
- Bug Report
|
||||
|
||||
##### SUMMARY
|
||||
<!-- Briefly describe the problem. -->
|
||||
|
||||
##### ENVIRONMENT
|
||||
* AWX version: X.Y.Z
|
||||
* Operator version: X.Y.Z
|
||||
* Kubernetes version:
|
||||
* AWX install method: openshift, minishift, docker on linux, docker for mac, boot2docker
|
||||
|
||||
##### STEPS TO REPRODUCE
|
||||
|
||||
<!-- Please describe exactly how to reproduce the problem. -->
|
||||
|
||||
##### EXPECTED RESULTS
|
||||
|
||||
<!-- What did you expect to happen when running the steps above? -->
|
||||
|
||||
##### ACTUAL RESULTS
|
||||
|
||||
<!-- What actually happened? -->
|
||||
|
||||
##### ADDITIONAL INFORMATION
|
||||
|
||||
<!-- Include any links to sosreport, database dumps, screenshots or other
|
||||
information. -->
|
||||
|
||||
##### AWX-OPERATOR LOGS
|
||||
125
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
125
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
---
|
||||
name: Bug Report
|
||||
description: "🐞 Create a report to help us improve"
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Bug Report issues are for **concrete, actionable bugs** only.
|
||||
For debugging help or technical support, please see the [Get Involved section of our README](https://github.com/ansible/awx-operator#get-involved)
|
||||
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Please confirm the following
|
||||
options:
|
||||
- label: I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
|
||||
required: true
|
||||
- label: I have checked the [current issues](https://github.com/ansible/awx-operator/issues) for duplicates.
|
||||
required: true
|
||||
- label: I understand that the AWX Operator is open source software provided for free and that I might not receive a timely response.
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: summary
|
||||
attributes:
|
||||
label: Bug Summary
|
||||
description: Briefly describe the problem.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: input
|
||||
id: awx-operator-version
|
||||
attributes:
|
||||
label: AWX Operator version
|
||||
description: What version of the AWX Operator are you running?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: awx-version
|
||||
attributes:
|
||||
label: AWX version
|
||||
description: What version of AWX are you running?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: platform
|
||||
attributes:
|
||||
label: Kubernetes platform
|
||||
description: What platform did you install the Operator in?
|
||||
multiple: false
|
||||
options:
|
||||
- kubernetes
|
||||
- minikube
|
||||
- openshift
|
||||
- minishift
|
||||
- docker development environment
|
||||
- other (please specify in additional information)
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: kube-version
|
||||
attributes:
|
||||
label: Kubernetes/Platform version
|
||||
description: What version of your platform/kuberneties are you using?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: modified-architecture
|
||||
attributes:
|
||||
label: Modifications
|
||||
description: >-
|
||||
Have you modified the installation, deployment topology, or container images in any way? If yes, please
|
||||
explain in the "additional information" field at the bottom of the form.
|
||||
multiple: false
|
||||
options:
|
||||
- "no"
|
||||
- "yes"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: steps-to-reproduce
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: >-
|
||||
Starting from a new installation of the system, describe exactly how a developer or quality engineer can reproduce the bug
|
||||
on infrastructure that isn't yours. Include any and all resources created, input values, test users, roles assigned, playbooks used, etc.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected-results
|
||||
attributes:
|
||||
label: Expected results
|
||||
description: What did you expect to happpen when running the steps above?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: actual-results
|
||||
attributes:
|
||||
label: Actual results
|
||||
description: What actually happened?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: Additional information
|
||||
description: Include any relevant log output, links to sosreport, database dumps, screenshots, AWX spec yaml, or other information.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: operator-logs
|
||||
attributes:
|
||||
label: Operator Logs
|
||||
description: Include any relevant logs generated by the operator.
|
||||
validations:
|
||||
required: false
|
||||
12
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
12
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: For debugging help or technical support
|
||||
url: https://github.com/ansible/awx-operator#get-involved
|
||||
about: For general debugging or technical support please see the Get Involved section of our readme.
|
||||
- name: 📝 Ansible Code of Conduct
|
||||
url: https://docs.ansible.com/ansible/latest/community/code_of_conduct.html?utm_medium=github&utm_source=issue_template_chooser
|
||||
about: AWX uses the Ansible Code of Conduct; ❤ Be nice to other members of the community. ☮ Behave.
|
||||
- name: 💼 For Enterprise
|
||||
url: https://www.ansible.com/products/engine?utm_medium=github&utm_source=issue_template_chooser
|
||||
about: Red Hat offers support for the Ansible Automation Platform
|
||||
29
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
29
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
name: ✨ Feature request
|
||||
description: Suggest an idea for this project
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Feature Request issues are for **feature requests** only.
|
||||
For debugging help or technical support, please see the [Get Involved section of our README](https://github.com/ansible/awx-operator#get-involved)
|
||||
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Please confirm the following
|
||||
options:
|
||||
- label: I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
|
||||
required: true
|
||||
- label: I have checked the [current issues](https://github.com/ansible/awx-operator/issues) for duplicates.
|
||||
required: true
|
||||
- label: I understand that AWX Operator is open source software provided for free and that I might not receive a timely response.
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: summary
|
||||
attributes:
|
||||
label: Feature Summary
|
||||
description: Briefly describe the desired enhancement.
|
||||
validations:
|
||||
required: true
|
||||
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
##### SUMMARY
|
||||
<!--- Describe the change, including rationale and design decisions -->
|
||||
|
||||
<!---
|
||||
If you are fixing an existing issue, please include "fixes #nnn" in your
|
||||
commit message and your description; but you should still explain what
|
||||
the change does.
|
||||
-->
|
||||
|
||||
##### ISSUE TYPE
|
||||
<!--- Pick one below and delete the rest: -->
|
||||
- Breaking Change
|
||||
- New or Enhanced Feature
|
||||
- Bug, Docs Fix or other nominal change
|
||||
|
||||
##### ADDITIONAL INFORMATION
|
||||
<!---
|
||||
Include additional information to help people understand the change here.
|
||||
For bugs that don't have a linked bug report, a step-by-step reproduction
|
||||
of the problem is helpful.
|
||||
-->
|
||||
|
||||
<!--- Paste verbatim command output below, e.g. before and after your change -->
|
||||
```
|
||||
|
||||
```
|
||||
47
.github/workflows/ci.yaml
vendored
47
.github/workflows/ci.yaml
vendored
@@ -10,9 +10,9 @@ on:
|
||||
branches: [devel]
|
||||
|
||||
jobs:
|
||||
pull_request:
|
||||
molecule:
|
||||
runs-on: ubuntu-18.04
|
||||
name: pull_request
|
||||
name: molecule
|
||||
env:
|
||||
DOCKER_API_VERSION: "1.38"
|
||||
steps:
|
||||
@@ -39,3 +39,46 @@ jobs:
|
||||
sudo rm -f $(which kustomize)
|
||||
make kustomize
|
||||
KUSTOMIZE_PATH=$(readlink -f bin/kustomize) molecule test -s kind
|
||||
helm:
|
||||
runs-on: ubuntu-18.04
|
||||
name: helm
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Create k8s Kind Cluster
|
||||
uses: helm/kind-action@v1.2.0
|
||||
|
||||
- name: Build operator image and load into kind
|
||||
run: |
|
||||
IMG=awx-operator-ci make docker-build
|
||||
kind load docker-image --name chart-testing awx-operator-ci
|
||||
|
||||
- name: Patch pull policy for tests
|
||||
run: |
|
||||
kustomize edit add patch --path ../testing/pull_policy/Never.yaml
|
||||
working-directory: config/default
|
||||
|
||||
- name: Build and lint helm chart
|
||||
run: |
|
||||
IMG=awx-operator-ci make helm-chart
|
||||
helm lint ./charts/awx-operator
|
||||
|
||||
- name: Install kubeval
|
||||
run: |
|
||||
mkdir tmp && cd tmp
|
||||
wget https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz
|
||||
tar xf kubeval-linux-amd64.tar.gz
|
||||
sudo cp kubeval /usr/local/bin
|
||||
working-directory: ./charts
|
||||
|
||||
- name: Run kubeval
|
||||
run: |
|
||||
helm template -n awx awx-operator > tmp/test.yaml
|
||||
kubeval --strict --force-color --ignore-missing-schemas tmp/test.yaml
|
||||
working-directory: ./charts
|
||||
|
||||
- name: Install helm chart
|
||||
run: |
|
||||
helm install --wait my-awx-operator --namespace awx --create-namespace ./charts/awx-operator
|
||||
|
||||
45
.github/workflows/pr_body_check.yml
vendored
Normal file
45
.github/workflows/pr_body_check.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
name: PR Check
|
||||
env:
|
||||
BRANCH: ${{ github.base_ref || 'devel' }}
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, edited, reopened, synchronize]
|
||||
jobs:
|
||||
pr-check:
|
||||
name: Scan PR description for semantic versioning keywords
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Write PR body to a file
|
||||
run: |
|
||||
cat >> pr.body << __SOME_RANDOM_PR_EOF__
|
||||
${{ github.event.pull_request.body }}
|
||||
__SOME_RANDOM_PR_EOF__
|
||||
|
||||
- name: Display the received body for troubleshooting
|
||||
run: cat pr.body
|
||||
|
||||
# We want to write these out individually just incase the options were joined on a single line
|
||||
- name: Check for each of the lines
|
||||
run: |
|
||||
grep "Bug, Docs Fix or other nominal change" pr.body > Z
|
||||
grep "New or Enhanced Feature" pr.body > Y
|
||||
grep "Breaking Change" pr.body > X
|
||||
exit 0
|
||||
# We exit 0 and set the shell to prevent the returns from the greps from failing this step
|
||||
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
|
||||
shell: bash {0}
|
||||
|
||||
- name: Check for exactly one item
|
||||
run: |
|
||||
if [ $(cat X Y Z | wc -l) != 1 ] ; then
|
||||
echo "The PR body must contain exactly one of [ 'Bug, Docs Fix or other nominal change', 'New or Enhanced Feature', 'Breaking Change' ]"
|
||||
echo "We counted $(cat X Y Z | wc -l)"
|
||||
echo "See the default PR body for examples"
|
||||
exit 255;
|
||||
else
|
||||
exit 0;
|
||||
fi
|
||||
15
.github/workflows/promote.yaml
vendored
15
.github/workflows/promote.yaml
vendored
@@ -8,6 +8,8 @@ jobs:
|
||||
promote:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Log in to GHCR
|
||||
run: |
|
||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
@@ -23,3 +25,16 @@ jobs:
|
||||
docker tag ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} quay.io/${{ github.repository }}:latest
|
||||
docker push quay.io/${{ github.repository }}:${{ github.event.release.tag_name }}
|
||||
docker push quay.io/${{ github.repository }}:latest
|
||||
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config user.name "$GITHUB_ACTOR"
|
||||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
|
||||
- name: Release Helm chart
|
||||
run: |
|
||||
ansible-playbook ansible/helm-release.yml -v \
|
||||
-e operator_image=quay.io/${{ github.repository }} \
|
||||
-e chart_owner=${{ github.repository_owner }} \
|
||||
-e tag=${{ github.event.release.tag_name }} \
|
||||
-e gh_token=${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -4,3 +4,6 @@
|
||||
/bundle
|
||||
/bundle_tmp*
|
||||
/bundle.Dockerfile
|
||||
/charts
|
||||
/.cr-release-packages
|
||||
.vscode/
|
||||
|
||||
23
.helm/starter/.helmignore
Normal file
23
.helm/starter/.helmignore
Normal file
@@ -0,0 +1,23 @@
|
||||
# Patterns to ignore when building packages.
|
||||
# This supports shell glob matching, relative path matching, and
|
||||
# negation (prefixed with !). Only one pattern per line.
|
||||
.DS_Store
|
||||
# Common VCS dirs
|
||||
.git/
|
||||
.gitignore
|
||||
.bzr/
|
||||
.bzrignore
|
||||
.hg/
|
||||
.hgignore
|
||||
.svn/
|
||||
# Common backup files
|
||||
*.swp
|
||||
*.bak
|
||||
*.tmp
|
||||
*.orig
|
||||
*~
|
||||
# Various IDEs
|
||||
.project
|
||||
.idea/
|
||||
*.tmproj
|
||||
.vscode/
|
||||
7
.helm/starter/Chart.yaml
Normal file
7
.helm/starter/Chart.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
apiVersion: v2
|
||||
appVersion: 0.1.0
|
||||
description: A Helm chart for Kubernetes
|
||||
name: starter
|
||||
type: application
|
||||
version: 0.1.0
|
||||
56
.helm/starter/README.md
Normal file
56
.helm/starter/README.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# AWX Operator Helm Chart
|
||||
|
||||
This chart installs the AWX Operator resources configured in [this](https://github.com/ansible/awx-operator) repository.
|
||||
|
||||
## Getting Started
|
||||
To configure your AWX resource using this chart, create your own `yaml` values file. The name is up to personal preference since it will explicitly be passed into the helm chart. Helm will merge whatever values you specify in your file with the default `values.yaml`, overriding any settings you've changed while allowing you to fall back on defaults. Because of this functionality, `values.yaml` should not be edited directly.
|
||||
|
||||
In your values config, enable `AWX.enable` and add `AWX.spec` values based on the awx operator's [documentation](https://github.com/ansible/awx-operator/blob/devel/README.md). Consult the docs below for additional functionality.
|
||||
|
||||
### Installing
|
||||
The operator's [helm install](https://github.com/ansible/awx-operator/blob/devel/README.md#helm-install-on-existing-cluster) guide provides key installation instructions.
|
||||
|
||||
Example:
|
||||
```
|
||||
helm install my-awx-operator awx-operator/awx-operator -n awx --create-namespace -f myvalues.yaml
|
||||
```
|
||||
|
||||
Argument breakdown:
|
||||
* `-f` passes in the file with your custom values
|
||||
* `-n` sets the namespace to be installed in
|
||||
* This value is accessed by `{{ $.Release.Namespace }}` in the templates
|
||||
* Acts as the default namespace for all unspecified resources
|
||||
* `--create-namespace` specifies that helm should create the namespace before installing
|
||||
|
||||
To update an existing installation, use `helm upgrade` instead of `install`. The rest of the syntax remains the same.
|
||||
|
||||
## Configuration
|
||||
The goal of adding helm configurations is to abstract out and simplify the creation of multi-resource configs. The `AWX.spec` field maps directly to the spec configs of the `AWX` resource that the operator provides, which are detailed in the [main README](https://github.com/ansible/awx-operator/blob/devel/README.md). Other sub-config can be added with the goal of simplifying more involved setups that require additional resources to be specified.
|
||||
|
||||
These sub-headers aim to be a more intuitive entrypoint into customizing your deployment, and are easier to manage in the long-term. By design, the helm templates will defer to the manually defined specs to avoid configuration conflicts. For example, if `AWX.spec.postgres_configuration_secret` is being used, the `AWX.postgres` settings will not be applied, even if enabled.
|
||||
|
||||
### External Postgres
|
||||
The `AWX.postgres` section simplifies the creation of the external postgres secret. If enabled, the configs provided will automatically be placed in a `postgres-config` secret and linked to the `AWX` resource. For proper secret management, the `AWX.postgres.password` value, and any other sensitive values, can be passed in at the command line rather than specified in code. Use the `--set` argument with `helm install`.
|
||||
|
||||
|
||||
## Values Summary
|
||||
|
||||
### AWX
|
||||
| Value | Description | Default |
|
||||
|---|---|---|
|
||||
| `AWX.enabled` | Enable this AWX resource configuration | `false` |
|
||||
| `AWX.name` | The name of the AWX resource and default prefix for other resources | `"awx"` |
|
||||
| `AWX.spec` | specs to directly configure the AWX resource | `{}` |
|
||||
| `AWX.postgres` | configurations for the external postgres secret | - |
|
||||
|
||||
|
||||
# Contributing
|
||||
|
||||
## Adding abstracted sections
|
||||
Where possible, defer to `AWX.spec` configs before applying the abstracted configs to avoid collision. This can be facilitated by the `(hasKey .spec what_i_will_abstract)` check.
|
||||
|
||||
## Building and Testing
|
||||
This chart is built using the Makefile in the [awx-operator repo](https://github.com/ansible/awx-operator). Clone the repo and run `make helm-chart`. This will create the awx-operator chart in the `charts/awx-operator` directory. In this process, the contents of the `.helm/starter` directory will be added to the chart.
|
||||
|
||||
## Future Goals
|
||||
All values under the `AWX` header are focused on configurations that use the operator. Configurations that relate to the Operator itself could be placed under an `Operator` heading, but that may add a layer of complication over current development.
|
||||
6
.helm/starter/templates/_helpers.tpl
Normal file
6
.helm/starter/templates/_helpers.tpl
Normal file
@@ -0,0 +1,6 @@
|
||||
{{/*
|
||||
Generate the name of the postgres secret, expects AWX context passed in
|
||||
*/}}
|
||||
{{- define "postgres.secretName" -}}
|
||||
{{ default (printf "%s-postgres-configuration" .Values.AWX.name) .Values.AWX.postgres.secretName }}
|
||||
{{- end }}
|
||||
24
.helm/starter/templates/awx-deploy.yaml
Normal file
24
.helm/starter/templates/awx-deploy.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
{{- if $.Values.AWX.enabled }}
|
||||
{{- with .Values.AWX }}
|
||||
apiVersion: awx.ansible.com/v1beta1
|
||||
kind: AWX
|
||||
metadata:
|
||||
name: {{ .name }}
|
||||
namespace: {{ $.Release.Namespace }}
|
||||
spec:
|
||||
{{- /* Include raw map from the values file spec */}}
|
||||
{{ .spec | toYaml | indent 2 }}
|
||||
{{- /* Provide security context defaults */}}
|
||||
{{- if not (hasKey .spec "security_context_settings") }}
|
||||
security_context_settings:
|
||||
runAsGroup: 0
|
||||
runAsUser: 0
|
||||
fsGroup: 0
|
||||
fsGroupChangePolicy: OnRootMismatch
|
||||
{{- end }}
|
||||
{{- /* Postgres configs if enabled and not already present */}}
|
||||
{{- if and .postgres.enabled (not (hasKey .spec "postgres_configuration_secret")) }}
|
||||
postgres_configuration_secret: {{ include "postgres.secretName" $ }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
18
.helm/starter/templates/postgres-config.yaml
Normal file
18
.helm/starter/templates/postgres-config.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
{{- if and $.Values.AWX.enabled $.Values.AWX.postgres.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "postgres.secretName" . }}
|
||||
namespace: {{ $.Release.Namespace }}
|
||||
{{- with $.Values.AWX.postgres }}
|
||||
stringData:
|
||||
host: {{ .host }}
|
||||
port: {{ .port | quote }}
|
||||
database: {{ .dbName }}
|
||||
username: {{ .username }}
|
||||
password: {{ .password }}
|
||||
sslmode: {{ .sslmode }}
|
||||
type: {{ .type }}
|
||||
type: Opaque
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
19
.helm/starter/values.yaml
Normal file
19
.helm/starter/values.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
AWX:
|
||||
# enable use of awx-deploy template
|
||||
enabled: false
|
||||
name: awx
|
||||
spec:
|
||||
admin_user: admin
|
||||
|
||||
# configurations for external postgres instance
|
||||
postgres:
|
||||
enabled: false
|
||||
host: Unset
|
||||
port: 5678
|
||||
dbName: Unset
|
||||
username: admin
|
||||
# for secret management, pass in the password independently of this file
|
||||
# at the command line, use --set AWX.postgres.password
|
||||
password: Unset
|
||||
sslmode: prefer
|
||||
type: unmanaged
|
||||
@@ -6,6 +6,7 @@ ignore: |
|
||||
kustomization.yaml
|
||||
awx-operator.clusterserviceversion.yaml
|
||||
bundle
|
||||
.helm/starter
|
||||
|
||||
rules:
|
||||
truthy: disable
|
||||
|
||||
157
Makefile
157
Makefile
@@ -7,6 +7,13 @@ VERSION ?= $(shell git describe --tags)
|
||||
|
||||
CONTAINER_CMD ?= docker
|
||||
|
||||
# GNU vs BSD in-place sed
|
||||
ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
|
||||
SED_I := sed -i
|
||||
else
|
||||
SED_I := sed -i ''
|
||||
endif
|
||||
|
||||
# CHANNELS define the bundle channels used in the bundle.
|
||||
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
|
||||
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
|
||||
@@ -41,6 +48,14 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
|
||||
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
|
||||
NAMESPACE ?= awx
|
||||
|
||||
# Helm variables
|
||||
CHART_NAME ?= awx-operator
|
||||
CHART_DESCRIPTION ?= A Helm chart for the AWX Operator
|
||||
CHART_OWNER ?= $(GH_REPO_OWNER)
|
||||
CHART_REPO ?= awx-operator
|
||||
CHART_BRANCH ?= gh-pages
|
||||
CHART_INDEX ?= index.yaml
|
||||
|
||||
all: docker-build
|
||||
|
||||
##@ General
|
||||
@@ -93,7 +108,8 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
|
||||
$(KUSTOMIZE) build config/default | kubectl delete -f -
|
||||
|
||||
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||
ARCH := $(shell uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')
|
||||
ARCHA := $(shell uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')
|
||||
ARCHX := $(shell uname -m | sed -e 's/amd64/x86_64/' -e 's/aarch64/arm64/')
|
||||
|
||||
.PHONY: kustomize
|
||||
KUSTOMIZE = $(shell pwd)/bin/kustomize
|
||||
@@ -103,7 +119,7 @@ ifeq (,$(shell which kustomize 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(KUSTOMIZE)) ;\
|
||||
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.8.7/kustomize_v3.8.7_$(OS)_$(ARCH).tar.gz | \
|
||||
curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.2/kustomize_v4.5.2_$(OS)_$(ARCHA).tar.gz | \
|
||||
tar xzf - -C bin/ ;\
|
||||
}
|
||||
else
|
||||
@@ -119,7 +135,7 @@ ifeq (,$(shell which ansible-operator 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(ANSIBLE_OPERATOR)) ;\
|
||||
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.12.0/ansible-operator_$(OS)_$(ARCH) ;\
|
||||
curl -sSLo $(ANSIBLE_OPERATOR) https://github.com/operator-framework/operator-sdk/releases/download/v1.12.0/ansible-operator_$(OS)_$(ARCHA) ;\
|
||||
chmod +x $(ANSIBLE_OPERATOR) ;\
|
||||
}
|
||||
else
|
||||
@@ -150,7 +166,7 @@ ifeq (,$(shell which opm 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(OPM)) ;\
|
||||
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$(OS)-$(ARCH)-opm ;\
|
||||
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$(OS)-$(ARCHA)-opm ;\
|
||||
chmod +x $(OPM) ;\
|
||||
}
|
||||
else
|
||||
@@ -181,3 +197,136 @@ catalog-build: opm ## Build a catalog image.
|
||||
.PHONY: catalog-push
|
||||
catalog-push: ## Push a catalog image.
|
||||
$(MAKE) docker-push IMG=$(CATALOG_IMG)
|
||||
|
||||
.PHONY: kubectl-slice
|
||||
KUBECTL_SLICE = $(shell pwd)/bin/kubectl-slice
|
||||
kubectl-slice: ## Download kubectl-slice locally if necessary.
|
||||
ifeq (,$(wildcard $(KUBECTL_SLICE)))
|
||||
ifeq (,$(shell which kubectl-slice 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(KUBECTL_SLICE)) ;\
|
||||
curl -sSLo - https://github.com/patrickdappollonio/kubectl-slice/releases/download/v1.1.0/kubectl-slice_1.1.0_$(OS)_$(ARCHX).tar.gz | \
|
||||
tar xzf - -C bin/ kubectl-slice ;\
|
||||
}
|
||||
else
|
||||
KUBECTL_SLICE = $(shell which kubectl-slice)
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: helm
|
||||
HELM = $(shell pwd)/bin/helm
|
||||
helm: ## Download helm locally if necessary.
|
||||
ifeq (,$(wildcard $(HELM)))
|
||||
ifeq (,$(shell which helm 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(HELM)) ;\
|
||||
curl -sSLo - https://get.helm.sh/helm-v3.8.0-$(OS)-$(ARCHA).tar.gz | \
|
||||
tar xzf - -C bin/ $(OS)-$(ARCHA)/helm ;\
|
||||
mv bin/$(OS)-$(ARCHA)/helm bin/helm ;\
|
||||
rmdir bin/$(OS)-$(ARCHA) ;\
|
||||
}
|
||||
else
|
||||
HELM = $(shell which helm)
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: yq
|
||||
YQ = $(shell pwd)/bin/yq
|
||||
yq: ## Download yq locally if necessary.
|
||||
ifeq (,$(wildcard $(YQ)))
|
||||
ifeq (,$(shell which yq 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(HELM)) ;\
|
||||
curl -sSLo - https://github.com/mikefarah/yq/releases/download/v4.20.2/yq_$(OS)_$(ARCHA).tar.gz | \
|
||||
tar xzf - -C bin/ ;\
|
||||
mv bin/yq_$(OS)_$(ARCHA) bin/yq ;\
|
||||
}
|
||||
else
|
||||
YQ = $(shell which yq)
|
||||
endif
|
||||
endif
|
||||
|
||||
PHONY: cr
|
||||
CR = $(shell pwd)/bin/cr
|
||||
cr: ## Download cr locally if necessary.
|
||||
ifeq (,$(wildcard $(CR)))
|
||||
ifeq (,$(shell which cr 2>/dev/null))
|
||||
@{ \
|
||||
set -e ;\
|
||||
mkdir -p $(dir $(CR)) ;\
|
||||
curl -sSLo - https://github.com/helm/chart-releaser/releases/download/v1.3.0/chart-releaser_1.3.0_$(OS)_$(ARCHA).tar.gz | \
|
||||
tar xzf - -C bin/ cr ;\
|
||||
}
|
||||
else
|
||||
CR = $(shell which cr)
|
||||
endif
|
||||
endif
|
||||
|
||||
charts:
|
||||
mkdir -p $@
|
||||
|
||||
.PHONY: helm-chart
|
||||
helm-chart: helm-chart-generate helm-chart-slice
|
||||
|
||||
.PHONY: helm-chart-generate
|
||||
helm-chart-generate: kustomize helm kubectl-slice yq charts
|
||||
@echo "== KUSTOMIZE (image and namespace) =="
|
||||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
|
||||
|
||||
@echo "== HELM =="
|
||||
cd charts && \
|
||||
$(HELM) create awx-operator --starter $(shell pwd)/.helm/starter ;\
|
||||
$(YQ) -i '.version = "$(VERSION)"' $(CHART_NAME)/Chart.yaml ;\
|
||||
$(YQ) -i '.appVersion = "$(VERSION)" | .appVersion style="double"' $(CHART_NAME)/Chart.yaml ;\
|
||||
$(YQ) -i '.description = "$(CHART_DESCRIPTION)"' $(CHART_NAME)/Chart.yaml ;\
|
||||
|
||||
@cat charts/$(CHART_NAME)/Chart.yaml
|
||||
|
||||
@echo "== KUSTOMIZE (annotation) =="
|
||||
cd config/manager && $(KUSTOMIZE) edit set annotation helm.sh/chart:$(CHART_NAME)-$(VERSION)
|
||||
cd config/default && $(KUSTOMIZE) edit set annotation helm.sh/chart:$(CHART_NAME)-$(VERSION)
|
||||
|
||||
@echo "== SLICE =="
|
||||
$(KUSTOMIZE) build --load-restrictor LoadRestrictionsNone config/default | \
|
||||
$(KUBECTL_SLICE) --input-file=- \
|
||||
--output-dir=charts/$(CHART_NAME)/templates \
|
||||
--sort-by-kind
|
||||
@echo "AWX Operator installed with Helm Chart version $(VERSION)" > charts/$(CHART_NAME)/templates/NOTES.txt
|
||||
mkdir charts/$(CHART_NAME)/crds
|
||||
mv charts/$(CHART_NAME)/templates/customresourcedefinition* charts/$(CHART_NAME)/crds
|
||||
|
||||
.PHONY: helm-chart-edit
|
||||
helm-chart-slice:
|
||||
@echo "== EDIT =="
|
||||
$(foreach file, $(wildcard charts/$(CHART_NAME)/templates/*),$(YQ) -i 'del(.. | select(has("namespace")).namespace)' $(file);)
|
||||
$(foreach file, $(wildcard charts/$(CHART_NAME)/templates/*rolebinding*),$(YQ) -i '.subjects[0].namespace = "{{ .Release.Namespace }}"' $(file);)
|
||||
rm -f charts/$(CHART_NAME)/templates/namespace*.yaml
|
||||
|
||||
|
||||
.PHONY: helm-package
|
||||
helm-package: cr helm-chart
|
||||
@echo "== CHART RELEASER (package) =="
|
||||
$(CR) package ./charts/awx-operator
|
||||
|
||||
# The actual release happens in ansible/helm-release.yml
|
||||
# until https://github.com/helm/chart-releaser/issues/122 happens
|
||||
.PHONY: helm-index
|
||||
helm-index: cr helm-chart
|
||||
@echo "== CHART RELEASER (httpsorigin) =="
|
||||
git remote add httpsorigin "https://github.com/$(CHART_OWNER)/$(CHART_REPO).git"
|
||||
git fetch httpsorigin
|
||||
|
||||
@echo "== CHART RELEASER (index) =="
|
||||
$(CR) index \
|
||||
--owner "$(CHART_OWNER)" \
|
||||
--git-repo "$(CHART_REPO)" \
|
||||
--token "$(CR_TOKEN)" \
|
||||
--pages-branch "$(CHART_BRANCH)" \
|
||||
--index-path "./charts/$(CHART_INDEX)" \
|
||||
--charts-repo "https://$(CHART_OWNER).github.io/$(CHART_REPO)/$(CHART_INDEX)" \
|
||||
--remote httpsorigin \
|
||||
--release-name-template="{{ .Version }}" \
|
||||
--push
|
||||
|
||||
295
README.md
295
README.md
@@ -1,6 +1,10 @@
|
||||
# AWX Operator
|
||||
|
||||
[](https://opensource.org/licenses/Apache-2.0) [](https://github.com/ansible/awx-operator/actions)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
[](https://github.com/ansible/awx-operator/actions)
|
||||
[](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html)
|
||||
[](https://groups.google.com/g/awx-project)
|
||||
[](https://libera.chat)
|
||||
|
||||
An [Ansible AWX](https://github.com/ansible/awx) operator for Kubernetes built with [Operator SDK](https://github.com/operator-framework/operator-sdk) and Ansible.
|
||||
|
||||
@@ -14,6 +18,7 @@ An [Ansible AWX](https://github.com/ansible/awx) operator for Kubernetes built w
|
||||
* [Usage](#usage)
|
||||
* [Creating a minikube cluster for testing](#creating-a-minikube-cluster-for-testing)
|
||||
* [Basic Install](#basic-install)
|
||||
* [Helm Install on existing cluster](#helm-install-on-existing-cluster)
|
||||
* [Admin user account configuration](#admin-user-account-configuration)
|
||||
* [Network and TLS Configuration](#network-and-tls-configuration)
|
||||
* [Service Type](#service-type)
|
||||
@@ -27,19 +32,25 @@ An [Ansible AWX](https://github.com/ansible/awx) operator for Kubernetes built w
|
||||
* [Redis container capabilities](#redis-container-capabilities)
|
||||
* [Privileged Tasks](#privileged-tasks)
|
||||
* [Containers Resource Requirements](#containers-resource-requirements)
|
||||
* [Priority Classes](#priority-classes)
|
||||
* [Assigning AWX pods to specific nodes](#assigning-awx-pods-to-specific-nodes)
|
||||
* [Trusting a Custom Certificate Authority](#trusting-a-custom-certificate-authority)
|
||||
* [Enabling LDAP Integration at AWX bootstrap](#enabling-ldap-integration-at-awx-bootstrap)
|
||||
* [Persisting Projects Directory](#persisting-projects-directory)
|
||||
* [Custom Volume and Volume Mount Options](#custom-volume-and-volume-mount-options)
|
||||
* [Default execution environments from private registries](#default-execution-environments-from-private-registries)
|
||||
* [Control plane ee from private registry](#control-plane-ee-from-private-registry)
|
||||
* [Exporting Environment Variables to Containers](#exporting-environment-variables-to-containers)
|
||||
* [CSRF Cookie Secure](#csrf-cookie-secure-setting)
|
||||
* [Session Cookie Secure](#session-cookie-secure-setting)
|
||||
* [CSRF Cookie Secure Setting](#csrf-cookie-secure-setting)
|
||||
* [Session Cookie Secure Setting](#session-cookie-secure-setting)
|
||||
* [Extra Settings](#extra-settings)
|
||||
* [Configure no_log](#no-log)
|
||||
* [Auto Upgrade](#auto-upgrade)
|
||||
* [Upgrade of instances without auto upgrade](#upgrade-of-instances-without-auto-upgrade)
|
||||
* [Service Account](#service-account)
|
||||
* [Uninstall](#uninstall)
|
||||
* [Upgrading](#upgrading)
|
||||
* [Backup](#backup)
|
||||
* [v0.14.0](#v0140)
|
||||
* [Cluster-scope to Namespace-scope considerations](#cluster-scope-to-namespace-scope-considerations)
|
||||
* [Project is now based on v1.x of the operator-sdk project](#project-is-now-based-on-v1x-of-the-operator-sdk-project)
|
||||
@@ -47,6 +58,11 @@ An [Ansible AWX](https://github.com/ansible/awx) operator for Kubernetes built w
|
||||
* [Contributing](#contributing)
|
||||
* [Release Process](#release-process)
|
||||
* [Author](#author)
|
||||
* [Code of Conduct](#code-of-conduct)
|
||||
* [Get Involved](#get-involved)
|
||||
|
||||
<!-- Created by https://github.com/ekalinin/github-markdown-toc -->
|
||||
|
||||
<!--te-->
|
||||
|
||||
## Purpose
|
||||
@@ -179,8 +195,12 @@ metadata:
|
||||
name: awx-demo
|
||||
spec:
|
||||
service_type: nodeport
|
||||
# default nodeport_port is 30080
|
||||
nodeport_port: <nodeport_port>
|
||||
```
|
||||
|
||||
> It may make sense to create and specify your own secret key for your deployment so that if the k8s secret gets deleted, it can be re-created if needed. If it is not provided, one will be auto-generated, but cannot be recovered if lost. Read more [here](#secret-key-configuration).
|
||||
|
||||
Make sure to add this new file to the list of "resources" in your `kustomization.yaml` file:
|
||||
|
||||
```yaml
|
||||
@@ -236,6 +256,36 @@ You just completed the most basic install of an AWX instance via this operator.
|
||||
For an example using the Nginx Controller in Minukube, don't miss our [demo video](https://asciinema.org/a/416946).
|
||||
|
||||
|
||||
### Helm Install on existing cluster
|
||||
|
||||
For those that wish to use [Helm](https://helm.sh/) to install the awx-operator to an existing K8s cluster:
|
||||
|
||||
The helm chart is generated from the `helm-chart` Makefile section using the starter files in `.helm/starter`. Consult [the documentation](.helm/starter/README.md) on how to customize the AWX resource with your own values.
|
||||
|
||||
```bash
|
||||
$ helm repo add awx-operator https://ansible.github.io/awx-operator/
|
||||
"awx-operator" has been added to your repositories
|
||||
|
||||
$ helm repo update
|
||||
Hang tight while we grab the latest from your chart repositories...
|
||||
...Successfully got an update from the "awx-operator" chart repository
|
||||
Update Complete. ⎈Happy Helming!⎈
|
||||
|
||||
$ helm search repo awx-operator
|
||||
NAME CHART VERSION APP VERSION DESCRIPTION
|
||||
awx-operator/awx-operator 0.17.1 0.17.1 A Helm chart for the AWX Operator
|
||||
|
||||
$ helm install -n awx --create-namespace my-awx-operator awx-operator/awx-operator
|
||||
NAME: my-awx-operator
|
||||
LAST DEPLOYED: Thu Feb 17 22:09:05 2022
|
||||
NAMESPACE: default
|
||||
STATUS: deployed
|
||||
REVISION: 1
|
||||
TEST SUITE: None
|
||||
NOTES:
|
||||
Helm Chart 0.17.1
|
||||
```
|
||||
|
||||
### Admin user account configuration
|
||||
|
||||
There are three variables that are customizable for the admin user account creation.
|
||||
@@ -267,6 +317,41 @@ stringData:
|
||||
```
|
||||
|
||||
|
||||
### Secret Key Configuration
|
||||
|
||||
This key is used to encrypt sensitive data in the database.
|
||||
|
||||
| Name | Description | Default |
|
||||
| ----------------- | ----------------------------------------------------- | ---------------- |
|
||||
| secret_key_secret | Secret that contains the symmetric key for encryption | Generated |
|
||||
|
||||
|
||||
> :warning: **secret_key_secret must be a Kubernetes secret and not your text clear secret value**.
|
||||
|
||||
If `secret_key_secret` is not provided, the operator will look for a secret named `<resourcename>-secret-key` for the secret key. If it is not present, the operator will generate a password and create a Secret from it named `<resourcename>-secret-key`. It is important to not delete this secret as it will be needed for upgrades and if the pods get scaled down at any point. If you are using a GitOps flow, you will want to pass a secret key secret.
|
||||
|
||||
The secret should be formatted as follow:
|
||||
|
||||
```yaml
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: custom-awx-secret-key
|
||||
namespace: <target namespace>
|
||||
stringData:
|
||||
secret_key: supersecuresecretkey
|
||||
```
|
||||
|
||||
Then specify the secret name on the AWX spec:
|
||||
|
||||
```yaml
|
||||
---
|
||||
spec:
|
||||
...
|
||||
secret_key_secret: custom-awx-secret-key
|
||||
```
|
||||
|
||||
### Network and TLS Configuration
|
||||
|
||||
#### Service Type
|
||||
@@ -395,7 +480,7 @@ spec:
|
||||
|
||||
#### External PostgreSQL Service
|
||||
|
||||
In order for the AWX instance to rely on an external database, the Custom Resource needs to know about the connection details. Those connection details should be stored as a secret and either specified as `postgres_configuration_secret` at the CR spec level, or simply be present on the namespace under the name `<resourcename>-postgres-configuration`.
|
||||
To configure AWX to use an external database, the Custom Resource needs to know about the connection details. To do this, create a k8s secret with those connection details and specify the name of the secret as `postgres_configuration_secret` at the CR spec level.
|
||||
|
||||
|
||||
The secret should be formatted as follows:
|
||||
@@ -418,12 +503,21 @@ stringData:
|
||||
type: Opaque
|
||||
```
|
||||
|
||||
> Please ensure that the value for the variable `password` should _not_ contain single or double quotes (`'`, `"`) or backslashes (`\`) to avoid any issues during deployment, backup or restoration.
|
||||
> Please ensure that the value for the variable `password` should _not_ contain single or double quotes (`'`, `"`) or backslashes (`\`) to avoid any issues during deployment, [backup](https://github.com/ansible/awx-operator/tree/devel/roles/backup) or [restoration](https://github.com/ansible/awx-operator/tree/devel/roles/restore).
|
||||
|
||||
> It is possible to set a specific username, password, port, or database, but still have the database managed by the operator. In this case, when creating the postgres-configuration secret, the `type: managed` field should be added.
|
||||
|
||||
**Note**: The variable `sslmode` is valid for `external` databases only. The allowed values are: `prefer`, `disable`, `allow`, `require`, `verify-ca`, `verify-full`.
|
||||
|
||||
Once the secret is created, you can specify it on your spec:
|
||||
|
||||
```yaml
|
||||
---
|
||||
spec:
|
||||
...
|
||||
postgres_configuration_secret: <name-of-your-secret>
|
||||
```
|
||||
|
||||
#### Migrating data from an old AWX instance
|
||||
|
||||
For instructions on how to migrate from an older version of AWX, see [migration.md](./docs/migration.md).
|
||||
@@ -476,15 +570,15 @@ spec:
|
||||
|
||||
There are a few variables that are customizable for awx the image management.
|
||||
|
||||
| Name | Description |
|
||||
| ------------------- | ------------------------- |
|
||||
| image | Path of the image to pull |
|
||||
| image_version | Image version to pull |
|
||||
| image_pull_policy | The pull policy to adopt |
|
||||
| image_pull_secrets | The pull secrets to use |
|
||||
| ee_images | A list of EEs to register |
|
||||
| redis_image | Path of the image to pull |
|
||||
| redis_image_version | Image version to pull |
|
||||
| Name | Description | Default |
|
||||
| ------------------- | ------------------------- | -------------------------------------- |
|
||||
| image | Path of the image to pull | quay.io/ansible/awx |
|
||||
| image_version | Image version to pull | value of DEFAULT_AWX_VERSION or latest |
|
||||
| image_pull_policy | The pull policy to adopt | IfNotPresent |
|
||||
| image_pull_secrets | The pull secrets to use | None |
|
||||
| ee_images | A list of EEs to register | quay.io/ansible/awx-ee:latest |
|
||||
| redis_image | Path of the image to pull | docker.io/redis |
|
||||
| redis_image_version | Image version to pull | latest |
|
||||
|
||||
Example of customization could be:
|
||||
|
||||
@@ -581,7 +675,7 @@ spec:
|
||||
|
||||
The AWX and Postgres pods can be assigned a custom PriorityClass to rank their importance compared to other pods in your cluster, which determines which pods get evicted first if resources are running low.
|
||||
First, [create your PriorityClass](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) if needed.
|
||||
Then set the name of your priority class to the control plane and postgres pods as shown below.
|
||||
Then set the name of your priority class to the control plane and postgres pods as shown below.
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -605,8 +699,8 @@ The ability to specify topologySpreadConstraints is also allowed through `topolo
|
||||
|
||||
| Name | Description | Default |
|
||||
| --------------------------- | ----------------------------------- | ------- |
|
||||
| postgres_image | Path of the image to pull | 12 |
|
||||
| postgres_image_version | Image version to pull | 12 |
|
||||
| postgres_image | Path of the image to pull | postgres |
|
||||
| postgres_image_version | Image version to pull | 13 |
|
||||
| node_selector | AWX pods' nodeSelector | '' |
|
||||
| topology_spread_constraints | AWX pods' topologySpreadConstraints | '' |
|
||||
| tolerations | AWX pods' tolerations | '' |
|
||||
@@ -654,11 +748,11 @@ In cases which you need to trust a custom Certificate Authority, there are few v
|
||||
Trusting a custom Certificate Authority allows the AWX to access network services configured with SSL certificates issued locally, such as cloning a project from from an internal Git server via HTTPS. It is common for these scenarios, experiencing the error [unable to verify the first certificate](https://github.com/ansible/awx-operator/issues/376).
|
||||
|
||||
|
||||
| Name | Description | Default |
|
||||
| -------------------- | -------------------------------------- | ------- |
|
||||
| ldap_cacert_secret | LDAP Certificate Authority secret name | '' |
|
||||
| bundle_cacert_secret | Certificate Authority secret name | '' |
|
||||
|
||||
| Name | Description | Default |
|
||||
| -------------------------------- | ---------------------------------------- | --------|
|
||||
| ldap_cacert_secret | LDAP Certificate Authority secret name | '' |
|
||||
| ldap_password_secret | LDAP BIND DN Password secret name | '' |
|
||||
| bundle_cacert_secret | Certificate Authority secret name | '' |
|
||||
Please note the `awx-operator` will look for the data field `ldap-ca.crt` in the specified secret when using the `ldap_cacert_secret`, whereas the data field `bundle-ca.crt` is required for `bundle_cacert_secret` parameter.
|
||||
|
||||
Example of customization could be:
|
||||
@@ -668,10 +762,13 @@ Example of customization could be:
|
||||
spec:
|
||||
...
|
||||
ldap_cacert_secret: <resourcename>-custom-certs
|
||||
ldap_password_secret: <resourcename>-ldap-password
|
||||
bundle_cacert_secret: <resourcename>-custom-certs
|
||||
```
|
||||
|
||||
To create the secret, you can use the command below:
|
||||
To create the secrets, you can use the commands below:
|
||||
|
||||
* Certificate Authority secret
|
||||
|
||||
```
|
||||
# kubectl create secret generic <resourcename>-custom-certs \
|
||||
@@ -679,6 +776,66 @@ To create the secret, you can use the command below:
|
||||
--from-file=bundle-ca.crt=<PATH/TO/YOUR/CA/PEM/FILE>
|
||||
```
|
||||
|
||||
* LDAP BIND DN Password secret
|
||||
|
||||
```
|
||||
# kubectl create secret generic <resourcename>-ldap-password \
|
||||
--from-literal=ldap-password=<your_ldap_dn_password>
|
||||
```
|
||||
|
||||
#### Enabling LDAP Integration at AWX bootstrap
|
||||
|
||||
A sample of extra settings can be found as below:
|
||||
|
||||
```yaml
|
||||
- setting: AUTH_LDAP_SERVER_URI
|
||||
value: >-
|
||||
"ldaps://ad01.abc.com:636 ldaps://ad02.abc.com:636"
|
||||
|
||||
- setting: AUTH_LDAP_BIND_DN
|
||||
value: >-
|
||||
"CN=LDAP User,OU=Service Accounts,DC=abc,DC=com"
|
||||
|
||||
- setting: AUTH_LDAP_USER_SEARCH
|
||||
value: 'LDAPSearch("DC=abc,DC=com",ldap.SCOPE_SUBTREE,"(sAMAccountName=%(user)s)",)'
|
||||
|
||||
- setting: AUTH_LDAP_GROUP_SEARCH
|
||||
value: 'LDAPSearch("OU=Groups,DC=abc,DC=com",ldap.SCOPE_SUBTREE,"(objectClass=group)",)'
|
||||
|
||||
- setting: AUTH_LDAP_USER_ATTR_MAP
|
||||
value: '{"first_name": "givenName","last_name": "sn","email": "mail"}'
|
||||
|
||||
- setting: AUTH_LDAP_REQUIRE_GROUP
|
||||
value: >-
|
||||
"CN=operators,OU=Groups,DC=abc,DC=com"
|
||||
- setting: AUTH_LDAP_USER_FLAGS_BY_GROUP
|
||||
value: {
|
||||
"is_superuser": [
|
||||
"CN=admin,OU=Groups,DC=abc,DC=com"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
- setting: AUTH_LDAP_ORGANIZATION_MAP
|
||||
value: {
|
||||
"abc": {
|
||||
"admins": "CN=admin,OU=Groups,DC=abc,DC=com",
|
||||
"remove_users": false,
|
||||
"remove_admins": false,
|
||||
"users": true
|
||||
}
|
||||
}
|
||||
|
||||
- setting: AUTH_LDAP_TEAM_MAP
|
||||
value: {
|
||||
"admin": {
|
||||
"remove": true,
|
||||
"users": "CN=admin,OU=Groups,DC=abc,DC=com",
|
||||
"organization": "abc"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Persisting Projects Directory
|
||||
|
||||
In cases which you want to persist the `/var/lib/projects` directory, there are few variables that are customizable for the `awx-operator`.
|
||||
@@ -790,7 +947,7 @@ Example spec file for volumes and volume mounts
|
||||
|
||||
In order to register default execution environments from private registries, the Custom Resource needs to know about the pull credentials. Those credentials should be stored as a secret and either specified as `ee_pull_credentials_secret` at the CR spec level, or simply be present on the namespace under the name `<resourcename>-ee-pull-credentials` . Instance initialization will register a `Container registry` type credential on the deployed instance and assign it to the registered default execution environments.
|
||||
|
||||
The secret should be formated as follows:
|
||||
The secret should be formatted as follows:
|
||||
|
||||
```yaml
|
||||
---
|
||||
@@ -814,7 +971,7 @@ You can create `image_pull_secret`
|
||||
```
|
||||
kubectl create secret <resoucename>-cp-pull-credentials regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
|
||||
```
|
||||
If you need more control (for example, to set a namespace or a label on the new secret) then you can customise the Secret before storing it
|
||||
If you need more control (for example, to set a namespace or a label on the new secret) then you can customize the Secret before storing it
|
||||
|
||||
Example spec file extra-config
|
||||
|
||||
@@ -907,6 +1064,57 @@ Example configuration of `extra_settings` parameter
|
||||
value: "cn=admin,dc=example,dc=com"
|
||||
```
|
||||
|
||||
#### No Log
|
||||
Configure no_log for tasks with no_log
|
||||
|
||||
| Name | Description | Default |
|
||||
| ------ | -------------------- | ------- |
|
||||
| no_log | No log configuration | 'true' |
|
||||
|
||||
Example configuration of `no_log` parameter
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
no_log: 'true'
|
||||
```
|
||||
|
||||
#### Auto upgrade
|
||||
With this parameter you can influence the behavior during an operator upgrade.
|
||||
If set to `true`, the operator will upgrade the specific instance directly.
|
||||
When the value is set to `false`, and we have a running deployment, the operator will not update the AWX instance.
|
||||
This can be useful when you have multiple AWX instances which you want to upgrade step by step instead of all at once.
|
||||
|
||||
|
||||
| Name | Description | Default |
|
||||
| -------------| ---------------------------------- | ------- |
|
||||
| auto_upgrade | Automatic upgrade of AWX instances | true |
|
||||
|
||||
Example configuration of `auto_upgrade` parameter
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
auto_upgrade: true
|
||||
```
|
||||
|
||||
##### Upgrade of instances without auto upgrade
|
||||
|
||||
There are two ways to upgrade instances which are marked with the 'auto_upgrade: false' flag.
|
||||
|
||||
Changing flags:
|
||||
|
||||
- change the auto_upgrade flag on your AWX object to true
|
||||
- wait until the upgrade process of that instance is finished
|
||||
- change the auto_upgrade flag on your AWX object back to false
|
||||
|
||||
Delete the deployment:
|
||||
|
||||
- delete the deployment object of your AWX instance
|
||||
```
|
||||
$ kubectl -n awx delete deployment <yourInstanceName>
|
||||
```
|
||||
- wait until the instance gets redeployed
|
||||
|
||||
|
||||
#### Service Account
|
||||
|
||||
If you need to modify some `ServiceAccount` proprieties
|
||||
@@ -935,12 +1143,31 @@ awx.awx.ansible.com "awx-demo" deleted
|
||||
|
||||
Deleting an AWX instance will remove all related deployments and statefulsets, however, persistent volumes and secrets will remain. To enforce secrets also getting removed, you can use `garbage_collect_secrets: true`.
|
||||
|
||||
**Note**: If you ever intend to recover an AWX from an existing database you will need a copy of the secrets in order to perform a successful recovery.
|
||||
|
||||
### Upgrading
|
||||
|
||||
To upgrade AWX, it is recommended to upgrade the awx-operator to the version that maps to the desired version of AWX. To find the version of AWX that will be installed by the awx-operator by default, check the version specified in the `image_version` variable in `roles/installer/defaults/main.yml` for that particular release.
|
||||
|
||||
Apply the awx-operator.yml for that release to upgrade the operator, and in turn also upgrade your AWX deployment.
|
||||
|
||||
#### Backup
|
||||
|
||||
The first part of any upgrade should be a backup. Note, there are secrets in the pod which work in conjunction with the database. Having just a database backup without the required secrets will not be sufficient for recovering from an issue when upgrading to a new version. See the [backup role documentation](https://github.com/ansible/awx-operator/tree/devel/roles/backup) for information on how to backup your database and secrets. In the event you need to recover the backup see the [restore role documentation](https://github.com/ansible/awx-operator/tree/devel/roles/restore).
|
||||
|
||||
#### PostgreSQL Upgrade Considerations
|
||||
|
||||
If there is a PostgreSQL major version upgrade, after the data directory on the PVC is migrated to the new version, the old PVC is kept by default.
|
||||
This provides the ability to roll back if needed, but can take up extra storage space in your cluster unnecessarily. You can configure it to be deleted automatically
|
||||
after a successful upgrade by setting the following variable on the AWX spec.
|
||||
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
postgres_keep_pvc_after_upgrade: False
|
||||
```
|
||||
|
||||
|
||||
#### v0.14.0
|
||||
|
||||
##### Cluster-scope to Namespace-scope considerations
|
||||
@@ -974,12 +1201,26 @@ Please visit [our contributing guidelines](https://github.com/ansible/awx-operat
|
||||
|
||||
## Release Process
|
||||
|
||||
The first step is to create a draft release. Typically this will happen in the [Stage Release](https://github.com/ansible/awx/blob/devel/.github/workflows/stage.yml) workflow for AWX and you dont need to do it as a separate step.
|
||||
The first step is to create a draft release. Typically this will happen in the [Stage Release](https://github.com/ansible/awx/blob/devel/.github/workflows/stage.yml) workflow for AWX and you don't need to do it as a separate step.
|
||||
|
||||
If you need to do an independent release of the operator, you can run the [Stage Release](https://github.com/ansible/awx-operator/blob/devel/.github/workflows/stage.yml) in the awx-operator repo. Both of these workflows will run smoke tests, so there is no need to do this manually.
|
||||
|
||||
After the draft release is created, publish it and the [Promote AWX Operator image](https://github.com/ansible/awx-operator/blob/devel/.github/workflows/promote.yaml) will run, publishing the image to Quay.
|
||||
After the draft release is created, publish it and the [Promote AWX Operator image](https://github.com/ansible/awx-operator/blob/devel/.github/workflows/promote.yaml) will run, which will:
|
||||
|
||||
- Publish image to Quay
|
||||
- Release Helm chart
|
||||
|
||||
## Author
|
||||
|
||||
This operator was originally built in 2019 by [Jeff Geerling](https://www.jeffgeerling.com) and is now maintained by the Ansible Team
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
We ask all of our community members and contributors to adhere to the [Ansible code of conduct](http://docs.ansible.com/ansible/latest/community/code_of_conduct.html). If you have questions or need assistance, please reach out to our community team at [codeofconduct@ansible.com](mailto:codeofconduct@ansible.com)
|
||||
|
||||
## Get Involved
|
||||
|
||||
We welcome your feedback and ideas. The AWX operator uses the same mailing list and IRC channel as AWX itself. Here's how to reach us with feedback and questions:
|
||||
|
||||
- Join the `#ansible-awx` channel on irc.libera.chat
|
||||
- Join the [mailing list](https://groups.google.com/forum/#!forum/awx-project)
|
||||
|
||||
3
SECURITY.md
Normal file
3
SECURITY.md
Normal file
@@ -0,0 +1,3 @@
|
||||
For all security related bugs, email security@ansible.com instead of using this issue tracker and you will receive a prompt response.
|
||||
|
||||
For more information on the Ansible community's practices regarding responsible disclosure, see https://www.ansible.com/security
|
||||
47
ansible/helm-release.yml
Normal file
47
ansible/helm-release.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
vars:
|
||||
chart_repo: awx-operator
|
||||
tasks:
|
||||
- name: Look up release
|
||||
uri:
|
||||
url: "https://api.github.com/repos/{{ chart_owner }}/{{ chart_repo }}/releases/tags/{{ tag }}"
|
||||
register: release
|
||||
ignore_errors: yes
|
||||
|
||||
- fail:
|
||||
msg: |
|
||||
Release must exist before running this playbook
|
||||
when: release is not success
|
||||
|
||||
- name: Build and package helm chart
|
||||
command: |
|
||||
make helm-chart helm-package
|
||||
environment:
|
||||
VERSION: "{{ tag }}"
|
||||
IMAGE_TAG_BASE: "{{ operator_image }}"
|
||||
args:
|
||||
chdir: "{{ playbook_dir }}/../"
|
||||
|
||||
# Move to chart releaser after https://github.com/helm/chart-releaser/issues/122 exists
|
||||
- name: Upload helm chart
|
||||
uri:
|
||||
url: "https://uploads.github.com/repos/{{ chart_owner }}/{{ chart_repo }}/releases/{{ release.json.id }}/assets?name=awx-operator-{{ tag }}.tgz"
|
||||
src: "{{ playbook_dir }}/../.cr-release-packages/awx-operator-{{ tag }}.tgz"
|
||||
headers:
|
||||
Authorization: "token {{ gh_token }}"
|
||||
Content-Type: "application/octet-stream"
|
||||
status_code:
|
||||
- 200
|
||||
- 201
|
||||
register: asset_upload
|
||||
changed_when: asset_upload.json.state == "uploaded"
|
||||
|
||||
- name: Publish helm index
|
||||
command: |
|
||||
make helm-index
|
||||
environment:
|
||||
CHART_OWNER: "{{ chart_owner }}"
|
||||
CR_TOKEN: "{{ gh_token }}"
|
||||
args:
|
||||
chdir: "{{ playbook_dir }}/../"
|
||||
@@ -278,6 +278,28 @@ spec:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
redis_resource_requirements:
|
||||
description: Resource requirements for the redis container
|
||||
properties:
|
||||
requests:
|
||||
properties:
|
||||
cpu:
|
||||
type: string
|
||||
memory:
|
||||
type: string
|
||||
storage:
|
||||
type: string
|
||||
type: object
|
||||
limits:
|
||||
properties:
|
||||
cpu:
|
||||
type: string
|
||||
memory:
|
||||
type: string
|
||||
storage:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
service_account_annotations:
|
||||
description: ServiceAccount annotations
|
||||
type: string
|
||||
@@ -357,6 +379,9 @@ spec:
|
||||
postgres_selector:
|
||||
description: nodeSelector for the Postgres pods
|
||||
type: string
|
||||
postgres_keep_pvc_after_upgrade:
|
||||
description: Specify whether or not to keep the old PVC after PostgreSQL upgrades
|
||||
type: boolean
|
||||
postgres_tolerations:
|
||||
description: node tolerations for the Postgres pods
|
||||
type: string
|
||||
@@ -414,6 +439,9 @@ spec:
|
||||
ldap_cacert_secret:
|
||||
description: Secret where can be found the LDAP trusted Certificate Authority Bundle
|
||||
type: string
|
||||
ldap_password_secret:
|
||||
description: Secret where can be found the LDAP bind password
|
||||
type: string
|
||||
bundle_cacert_secret:
|
||||
description: Secret where can be found the trusted Certificate Authority Bundle
|
||||
type: string
|
||||
@@ -457,10 +485,21 @@ spec:
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
type: object
|
||||
type: array
|
||||
no_log:
|
||||
description: Configure no_log for no_log tasks
|
||||
type: string
|
||||
security_context_settings:
|
||||
description: Key/values that will be set under the pod-level securityContext field
|
||||
type: object
|
||||
x-kubernetes-preserve-unknown-fields: true
|
||||
auto_upgrade:
|
||||
description: Should AWX instances be automatically upgraded when operator gets upgraded
|
||||
type: boolean
|
||||
default: true
|
||||
set_self_labels:
|
||||
description: Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
type: boolean
|
||||
default: true
|
||||
type: object
|
||||
status:
|
||||
properties:
|
||||
@@ -483,7 +522,10 @@ spec:
|
||||
description: Secret key secret name of the deployed instance
|
||||
type: string
|
||||
migratedFromSecret:
|
||||
description: The secret used for migrating an old instance.
|
||||
description: The secret used for migrating an old instance
|
||||
type: string
|
||||
upgradedPostgresVersion:
|
||||
description: Status to indicate that the database has been upgraded to the version in the status
|
||||
type: string
|
||||
version:
|
||||
description: Version of the deployed instance
|
||||
|
||||
@@ -32,17 +32,20 @@ spec:
|
||||
description: Name of the deployment to be backed up
|
||||
type: string
|
||||
backup_pvc:
|
||||
description: Name of the PVC to be used for storing the backup
|
||||
description: Name of the backup PVC
|
||||
type: string
|
||||
backup_pvc_namespace:
|
||||
description: Namespace the PVC is in
|
||||
description: (Deprecated) Namespace the PVC is in
|
||||
type: string
|
||||
backup_storage_requirements:
|
||||
description: Storage requirements for the PostgreSQL container
|
||||
description: Storage requirements for backup PVC (may be similar to existing postgres PVC backing up from)
|
||||
type: string
|
||||
backup_storage_class:
|
||||
description: Storage class to use when creating PVC for backup
|
||||
type: string
|
||||
clean_backup_on_delete:
|
||||
description: Flag to indicate if backup should be deleted on PVC if AWXBackup object is deleted
|
||||
type: boolean
|
||||
postgres_label_selector:
|
||||
description: Label selector used to identify postgres pod for backing up data
|
||||
type: string
|
||||
@@ -52,6 +55,13 @@ spec:
|
||||
postgres_image_version:
|
||||
description: PostgreSQL container image version to use
|
||||
type: string
|
||||
no_log:
|
||||
description: Configure no_log for no_log tasks
|
||||
type: string
|
||||
set_self_labels:
|
||||
description: Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
type: boolean
|
||||
default: true
|
||||
status:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@@ -33,7 +33,8 @@ spec:
|
||||
- CR
|
||||
- PVC
|
||||
deployment_name:
|
||||
description: Name of the deployment to be restored to
|
||||
description: Name of the restored deployment. This should be different from the original deployment name
|
||||
if the original deployment still exists.
|
||||
type: string
|
||||
backup_name:
|
||||
description: AWXBackup object name
|
||||
@@ -42,7 +43,7 @@ spec:
|
||||
description: Name of the PVC to be restored from, set as a status found on the awxbackup object (backupClaim)
|
||||
type: string
|
||||
backup_pvc_namespace:
|
||||
description: Namespace the PVC is in
|
||||
description: (Deprecated) Namespace the PVC is in
|
||||
type: string
|
||||
backup_dir:
|
||||
description: Backup directory name, set as a status found on the awxbackup object (backupDirectory)
|
||||
@@ -56,6 +57,13 @@ spec:
|
||||
postgres_image_version:
|
||||
description: PostgreSQL container image version to use
|
||||
type: string
|
||||
no_log:
|
||||
description: Configure no_log for no_log tasks
|
||||
type: string
|
||||
set_self_labels:
|
||||
description: Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
type: boolean
|
||||
default: true
|
||||
status:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
@@ -54,5 +54,14 @@ spec:
|
||||
port: 6789
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests:
|
||||
memory: "32Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "4096Mi"
|
||||
cpu: "2000m"
|
||||
serviceAccountName: controller-manager
|
||||
imagePullSecrets:
|
||||
- name: redhat-operators-pull-secret
|
||||
terminationGracePeriodSeconds: 10
|
||||
|
||||
@@ -28,8 +28,7 @@ spec:
|
||||
- displayName: Backup persistent volume claim namespace
|
||||
path: backup_pvc_namespace
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:text
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:hidden
|
||||
- displayName: Backup PVC storage requirements
|
||||
path: backup_storage_requirements
|
||||
x-descriptors:
|
||||
@@ -67,12 +66,13 @@ spec:
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:text
|
||||
version: v1beta1
|
||||
- description: Restore a previous awx deployment into the namespace
|
||||
- description: Restore a previous awx deployment from an AWXBackup. The
|
||||
deployment name you provide will be the name of the new AWX CR that will be created.
|
||||
displayName: AWX Restore
|
||||
kind: AWXRestore
|
||||
name: awxrestores.awx.ansible.com
|
||||
specDescriptors:
|
||||
- displayName: Backup source to restore ?
|
||||
- displayName: Backup source to restore from
|
||||
path: backup_source
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:select:CR
|
||||
@@ -94,7 +94,7 @@ spec:
|
||||
- displayName: Backup namespace
|
||||
path: backup_pvc_namespace
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:text
|
||||
- urn:alm:descriptor:com.tectonic.ui:hidden
|
||||
- displayName: Backup directory in the persistent volume claim
|
||||
path: backup_dir
|
||||
x-descriptors:
|
||||
@@ -107,12 +107,10 @@ spec:
|
||||
- displayName: PostgreSQL Image
|
||||
path: postgres_image
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:hidden
|
||||
- displayName: PostgreSQL Image Version
|
||||
path: postgres_image_version
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:hidden
|
||||
statusDescriptors:
|
||||
- description: The state of the restore
|
||||
@@ -278,6 +276,11 @@ spec:
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:resourceRequirements
|
||||
- displayName: Redis container resource requirements
|
||||
path: redis_resource_requirements
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:resourceRequirements
|
||||
- displayName: PostgreSQL container resource requirements (when using a managed
|
||||
instance)
|
||||
path: postgres_resource_requirements
|
||||
@@ -377,6 +380,10 @@ spec:
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:hidden
|
||||
- displayName: Postgres Keep Old Data PVC After Upgrade
|
||||
path: postgres_keep_pvc_after_upgrade
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:hidden
|
||||
- displayName: Postgres Tolerations
|
||||
path: postgres_tolerations
|
||||
x-descriptors:
|
||||
@@ -569,6 +576,11 @@ spec:
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:hidden
|
||||
- displayName: No Log Configuration
|
||||
path: no_log
|
||||
x-descriptors:
|
||||
- urn:alm:descriptor:com.tectonic.ui:advanced
|
||||
- urn:alm:descriptor:com.tectonic.ui:hidden
|
||||
- displayName: Security Context Settings
|
||||
path: security_context_settings
|
||||
x-descriptors:
|
||||
|
||||
@@ -6,13 +6,13 @@ metadata:
|
||||
spec:
|
||||
web_resource_requirements:
|
||||
requests:
|
||||
cpu: 250m
|
||||
cpu: 50m
|
||||
memory: 128M
|
||||
task_resource_requirements:
|
||||
requests:
|
||||
cpu: 250m
|
||||
cpu: 50m
|
||||
memory: 128M
|
||||
ee_resource_requirements:
|
||||
requests:
|
||||
cpu: 200m
|
||||
cpu: 50m
|
||||
memory: 64M
|
||||
|
||||
51
docs/debugging.md
Normal file
51
docs/debugging.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# Iterating on the installer without deploying the operator
|
||||
|
||||
Go through the [normal basic install](https://github.com/ansible/awx-operator/blob/devel/README.md#basic-install) steps.
|
||||
|
||||
Install some dependencies:
|
||||
|
||||
```
|
||||
$ ansible-galaxy collection install -r molecule/requirements.yml
|
||||
$ pip install -r molecule/requirements.txt
|
||||
```
|
||||
|
||||
To prevent the changes we're about to make from being overwritten, scale down any running instance of the operator:
|
||||
|
||||
```
|
||||
$ kubectl scale deployment awx-operator-controller-manager --replicas=0
|
||||
```
|
||||
|
||||
Create a playbook that invokes the installer role (the operator uses ansible-runner's role execution feature):
|
||||
|
||||
```yaml
|
||||
# run.yml
|
||||
---
|
||||
- hosts: localhost
|
||||
roles:
|
||||
- installer
|
||||
```
|
||||
|
||||
Create a vars file:
|
||||
|
||||
```yaml
|
||||
# vars.yml
|
||||
---
|
||||
ansible_operator_meta:
|
||||
name: awx
|
||||
namespace: awx
|
||||
service_type: nodeport
|
||||
```
|
||||
|
||||
Run the installer:
|
||||
|
||||
```
|
||||
$ ansible-playbook run.yml -e @vars.yml -v
|
||||
```
|
||||
|
||||
Grab the URL and admin password:
|
||||
|
||||
```
|
||||
$ minikube service awx-service --url -n awx
|
||||
$ minikube kubectl get secret awx-admin-password -- -o jsonpath="{.data.password}" | base64 --decode
|
||||
LU6lTfvnkjUvDwL240kXKy1sNhjakZmT
|
||||
```
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
- name: Build kustomize testing overlay
|
||||
# load_restrictor must be set to none so we can load patch files from the default overlay
|
||||
command: '{{ kustomize }} build --load_restrictor none .'
|
||||
command: '{{ kustomize }} build --load-restrictor LoadRestrictionsNone .'
|
||||
args:
|
||||
chdir: '{{ config_dir }}/testing'
|
||||
register: resources
|
||||
|
||||
@@ -49,13 +49,13 @@
|
||||
name: Demo Job Template
|
||||
wait: yes
|
||||
validate_certs: no
|
||||
controller_host: localhost
|
||||
controller_host: localhost/awx/
|
||||
controller_username: admin
|
||||
controller_password: "{{ admin_pw_secret.resources[0].data.password | b64decode }}"
|
||||
rescue:
|
||||
- name: Get list of project updates and jobs
|
||||
uri:
|
||||
url: "http://localhost/api/v2/{{ resource }}/"
|
||||
url: "http://localhost/awx/api/v2/{{ resource }}/"
|
||||
user: admin
|
||||
password: "{{ admin_pw_secret.resources[0].data.password | b64decode }}"
|
||||
force_basic_auth: yes
|
||||
|
||||
@@ -11,19 +11,21 @@ spec:
|
||||
image_version: {{ awx_version }}
|
||||
{% endif %}
|
||||
ingress_type: ingress
|
||||
ingress_path: /awx
|
||||
ingress_annotations: |
|
||||
kubernetes.io/ingress.class: nginx
|
||||
web_resource_requirements:
|
||||
requests:
|
||||
cpu: 100m
|
||||
cpu: 50m
|
||||
memory: 32M
|
||||
task_resource_requirements:
|
||||
requests:
|
||||
cpu: 100m
|
||||
cpu: 50m
|
||||
memory: 32M
|
||||
ee_resource_requirements:
|
||||
requests:
|
||||
cpu: 200m
|
||||
memory: 32M
|
||||
cpu: 50m
|
||||
memory: 16M
|
||||
postgres_resource_requirements: {}
|
||||
postgres_init_container_resource_requirements: {}
|
||||
redis_resource_requirements: {}
|
||||
|
||||
0
projects/.gitkeep
Executable file → Normal file
0
projects/.gitkeep
Executable file → Normal file
@@ -60,13 +60,7 @@ backup_storage_class: 'standard'
|
||||
backup_storage_requirements: '20Gi'
|
||||
```
|
||||
|
||||
By default, the backup pvc will be created in the same namespace the awxbackup object is created in. If you want your backup to be stored
|
||||
in a specific namespace, you can do so by specifying `backup_pvc_namespace`. Keep in mind that you will
|
||||
need to provide the same namespace when restoring.
|
||||
|
||||
```
|
||||
backup_pvc_namespace: 'custom-namespace'
|
||||
```
|
||||
The backup pvc will be created in the same namespace the awxbackup object is created in.
|
||||
|
||||
If a custom postgres configuration secret was used when deploying AWX, it will automatically be used by the backup role.
|
||||
To check the name of this secret, look at the postgresConfigurationSecret status on your AWX object.
|
||||
@@ -74,7 +68,12 @@ To check the name of this secret, look at the postgresConfigurationSecret status
|
||||
The postgresql pod for the old deployment is used when backing up data to the new postgresql pod. If your postgresql pod has a custom label,
|
||||
you can pass that via the `postgres_label_selector` variable to make sure the postgresql pod can be found.
|
||||
|
||||
It is also possible to tie the lifetime of the backup files to that of the AWXBackup resource object. To do that you can set the
|
||||
`clean_backup_on_delete` value to true. This will delete the `backupDirectory` on the pvc associated with the AWXBackup object deleted.
|
||||
|
||||
```
|
||||
clean_backup_on_delete: true
|
||||
```
|
||||
Testing
|
||||
----------------
|
||||
|
||||
|
||||
@@ -10,3 +10,18 @@ backup_pvc_namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
|
||||
# Size of backup PVC if created dynamically
|
||||
backup_storage_requirements: ''
|
||||
|
||||
# Set no_log settings on certain tasks
|
||||
no_log: 'true'
|
||||
|
||||
# Variable to set when you want backups to be cleaned up when the CRD object is deleted
|
||||
clean_backup_on_delete: false
|
||||
|
||||
# Variable to signal that this role is being run as a finalizer
|
||||
finalizer_run: false
|
||||
|
||||
# Allow additional parameters to be added to the pg_dump backup command
|
||||
pg_dump_suffix: ''
|
||||
|
||||
# Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
set_self_labels: true
|
||||
|
||||
48
roles/backup/tasks/creation.yml
Normal file
48
roles/backup/tasks/creation.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
- name: Patching labels to {{ kind }} kind
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
metadata:
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
labels:
|
||||
app.kubernetes.io/name: "{{ ansible_operator_meta.name }}"
|
||||
app.kubernetes.io/part-of: "{{ ansible_operator_meta.name }}"
|
||||
app.kubernetes.io/managed-by: "{{ deployment_type }}-operator"
|
||||
app.kubernetes.io/component: "{{ deployment_type }}"
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
when: set_self_labels | bool
|
||||
|
||||
- name: Look up details for this backup object
|
||||
k8s_info:
|
||||
api_version: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: this_backup
|
||||
|
||||
- block:
|
||||
- include_tasks: init.yml
|
||||
|
||||
- include_tasks: postgres.yml
|
||||
|
||||
- include_tasks: awx-cro.yml
|
||||
|
||||
- include_tasks: secrets.yml
|
||||
|
||||
- name: Set flag signifying this backup was successful
|
||||
set_fact:
|
||||
backup_complete: true
|
||||
|
||||
- include_tasks: cleanup.yml
|
||||
|
||||
when:
|
||||
- this_backup['resources'][0]['status']['backupDirectory'] is not defined
|
||||
|
||||
- name: Update status variables
|
||||
include_tasks: update_status.yml
|
||||
7
roles/backup/tasks/delete_backup.yml
Normal file
7
roles/backup/tasks/delete_backup.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Cleanup backup associated with this option if enabled
|
||||
k8s_exec:
|
||||
namespace: "{{ backup_pvc_namespace }}"
|
||||
pod: "{{ ansible_operator_meta.name }}-db-management"
|
||||
command: >-
|
||||
bash -c 'rm -rf {{ backup_dir }}'
|
||||
@@ -25,15 +25,15 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: "{{ _name }}"
|
||||
register: _secret
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set secret data
|
||||
set_fact:
|
||||
_data: "{{ _secret['resources'][0]['data'] }}"
|
||||
_type: "{{ _secret['resources'][0]['type'] }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Create and Add secret names and data to dictionary
|
||||
set_fact:
|
||||
secret_dict: "{{ secret_dict | default({}) | combine({ item: {'name': _name, 'data': _data, 'type': _type }}) }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: "{{ _name }}"
|
||||
register: _secret
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set secret key
|
||||
set_fact:
|
||||
_data: "{{ _secret['resources'][0]['data'] }}"
|
||||
_type: "{{ _secret['resources'][0]['type'] }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Create and Add secret names and data to dictionary
|
||||
set_fact:
|
||||
secret_dict: "{{ secret_dict | default({}) | combine({item: { 'name': _name, 'data': _data, 'type': _type }}) }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: _name != ''
|
||||
|
||||
19
roles/backup/tasks/finalizer.yml
Normal file
19
roles/backup/tasks/finalizer.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
- name: Look up details for this backup object
|
||||
k8s_info:
|
||||
api_version: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: this_backup
|
||||
|
||||
- block:
|
||||
- include_tasks: init.yml
|
||||
|
||||
- include_tasks: delete_backup.yml
|
||||
|
||||
- include_tasks: cleanup.yml
|
||||
vars:
|
||||
backup_dir: "{{ this_backup['resources'][0]['status']['backupDirectory'] }}"
|
||||
when:
|
||||
- clean_backup_on_delete and backup_dir is defined
|
||||
@@ -1,5 +1,4 @@
|
||||
---
|
||||
|
||||
- name: Delete any existing management pod
|
||||
k8s:
|
||||
name: "{{ ansible_operator_meta.name }}-db-management"
|
||||
@@ -57,8 +56,8 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: '{{ deployment_name }}-backup-claim'
|
||||
namespace: '{{ backup_pvc_namespace }}'
|
||||
name: "{{ deployment_name }}-backup-claim"
|
||||
namespace: "{{ backup_pvc_namespace }}"
|
||||
ownerReferences: null
|
||||
when:
|
||||
- backup_pvc == '' or backup_pvc is not defined
|
||||
|
||||
@@ -1,47 +1,8 @@
|
||||
---
|
||||
- name: Patching labels to {{ kind }} kind
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: '{{ api_version }}'
|
||||
kind: '{{ kind }}'
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
app.kubernetes.io/component: '{{ deployment_type }}'
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
- name: Run creation tasks
|
||||
include_tasks: creation.yml
|
||||
when: not finalizer_run
|
||||
|
||||
- name: Look up details for this backup object
|
||||
k8s_info:
|
||||
api_version: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: this_backup
|
||||
|
||||
- block:
|
||||
- include_tasks: init.yml
|
||||
|
||||
- include_tasks: postgres.yml
|
||||
|
||||
- include_tasks: awx-cro.yml
|
||||
|
||||
- include_tasks: secrets.yml
|
||||
|
||||
- name: Set flag signifying this backup was successful
|
||||
set_fact:
|
||||
backup_complete: true
|
||||
|
||||
- include_tasks: cleanup.yml
|
||||
|
||||
when:
|
||||
- this_backup['resources'][0]['status']['backupDirectory'] is not defined
|
||||
|
||||
- name: Update status variables
|
||||
include_tasks: update_status.yml
|
||||
- name: Run finalizer tasks
|
||||
include_tasks: finalizer.yml
|
||||
when: finalizer_run
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: "{{ this_awx['resources'][0]['status']['postgresConfigurationSecret'] }}"
|
||||
register: pg_config
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Fail if postgres configuration secret status does not exist
|
||||
fail:
|
||||
@@ -21,12 +21,12 @@
|
||||
awx_postgres_port: "{{ pg_config['resources'][0]['data']['port'] | b64decode }}"
|
||||
awx_postgres_host: "{{ pg_config['resources'][0]['data']['host'] | b64decode }}"
|
||||
awx_postgres_type: "{{ pg_config['resources'][0]['data']['type'] | default('unmanaged'|b64encode) | b64decode }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- block:
|
||||
- name: Delete pod to reload a resource configuration
|
||||
set_fact:
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ deployment_name }}"
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ deployment_name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get the postgres pod information
|
||||
@@ -80,7 +80,7 @@
|
||||
- name: Set full resolvable host name for postgres pod
|
||||
set_fact:
|
||||
resolvable_db_host: '{{ (awx_postgres_type == "managed") | ternary(awx_postgres_host + "." + ansible_operator_meta.namespace + ".svc.cluster.local", awx_postgres_host) }}' # yamllint disable-line rule:line-length
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set pg_dump command
|
||||
set_fact:
|
||||
@@ -91,7 +91,8 @@
|
||||
-d {{ awx_postgres_database }}
|
||||
-p {{ awx_postgres_port }}
|
||||
-F custom
|
||||
no_log: true
|
||||
{{ pg_dump_suffix }}
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Write pg_dump to backup on PVC
|
||||
k8s_exec:
|
||||
@@ -104,5 +105,5 @@
|
||||
echo 'Successful'
|
||||
"""
|
||||
register: data_migration
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
failed_when: "'Successful' not in data_migration.stdout"
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
- name: Nest secrets under a single variable
|
||||
set_fact:
|
||||
secrets: {"secrets": '{{ secret_dict }}'}
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Write postgres configuration to pvc
|
||||
k8s_exec:
|
||||
@@ -47,4 +47,4 @@
|
||||
pod: "{{ ansible_operator_meta.name }}-db-management"
|
||||
command: >-
|
||||
bash -c "echo '{{ secrets | to_yaml }}' > {{ backup_dir }}/secrets.yml"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
deployment_type: "awx"
|
||||
_postgres_image: postgres
|
||||
_postgres_image_version: 12
|
||||
_postgres_image_version: 13
|
||||
backup_complete: false
|
||||
database_type: "unmanaged"
|
||||
supported_pg_version: 13
|
||||
|
||||
@@ -127,9 +127,9 @@ extra_volumes: ''
|
||||
_image: quay.io/ansible/awx
|
||||
_image_version: "{{ lookup('env', 'DEFAULT_AWX_VERSION') or 'latest' }}"
|
||||
_redis_image: docker.io/redis
|
||||
_redis_image_version: latest
|
||||
_redis_image_version: 7
|
||||
_postgres_image: postgres
|
||||
_postgres_image_version: 12
|
||||
_postgres_image_version: 13
|
||||
_init_container_image: quay.io/centos/centos
|
||||
_init_container_image_version: stream8
|
||||
image_pull_policy: IfNotPresent
|
||||
@@ -164,7 +164,8 @@ replicas: "1"
|
||||
task_args:
|
||||
- /usr/bin/launch_awx_task.sh
|
||||
task_command: []
|
||||
web_args: []
|
||||
web_args:
|
||||
- /usr/bin/launch_awx.sh
|
||||
web_command: []
|
||||
|
||||
task_resource_requirements:
|
||||
@@ -188,6 +189,11 @@ session_cookie_secure: False
|
||||
|
||||
# Assign a preexisting priority class to the control plane pods
|
||||
control_plane_priority_class: ''
|
||||
|
||||
redis_resource_requirements:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
# Add extra environment variables to the AWX task/web containers. Specify as
|
||||
# literal block. E.g.:
|
||||
# task_extra_env: |
|
||||
@@ -217,6 +223,9 @@ ee_extra_volume_mounts: ''
|
||||
# kubernetes.io/os: linux
|
||||
postgres_selector: ''
|
||||
|
||||
# Specify whether or not to keep the old PVC after PostgreSQL upgrades
|
||||
postgres_keep_pvc_after_upgrade: True
|
||||
|
||||
# Add node tolerations for the Postgres pods.
|
||||
# Specify as literal block. E.g.:
|
||||
# postgres_tolerations: |
|
||||
@@ -261,6 +270,9 @@ ca_trust_bundle: "/etc/pki/tls/certs/ca-bundle.crt"
|
||||
#
|
||||
ldap_cacert_secret: ''
|
||||
|
||||
# Secret to lookup that provides the LDAP bind password
|
||||
ldap_password_secret: ''
|
||||
|
||||
# Secret to lookup that provides the custom CA trusted bundle
|
||||
bundle_cacert_secret: ''
|
||||
|
||||
@@ -272,3 +284,13 @@ garbage_collect_secrets: false
|
||||
development_mode: false
|
||||
|
||||
security_context_settings: {}
|
||||
|
||||
# Set no_log settings on certain tasks
|
||||
no_log: 'true'
|
||||
|
||||
# Should AWX instances be automatically upgraded when operator gets upgraded
|
||||
#
|
||||
auto_upgrade: true
|
||||
|
||||
# Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
set_self_labels: true
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ admin_password_secret }}'
|
||||
register: _custom_admin_password
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: admin_password_secret | length
|
||||
|
||||
- name: Check for default admin password configuration
|
||||
@@ -14,19 +14,19 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-admin-password'
|
||||
register: _default_admin_password
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set admin password secret
|
||||
set_fact:
|
||||
_admin_password_secret: '{{ _custom_admin_password["resources"] | default([]) | length | ternary(_custom_admin_password, _default_admin_password) }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- block:
|
||||
- name: Create admin password secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'admin_password_secret.yaml.j2') }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Read admin password secret
|
||||
k8s_info:
|
||||
@@ -34,16 +34,16 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-admin-password'
|
||||
register: _generated_admin_password
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
when: not _admin_password_secret['resources'] | default([]) | length
|
||||
|
||||
- name: Set admin password secret
|
||||
set_fact:
|
||||
__admin_password_secret: '{{ _generated_admin_password["resources"] | default([]) | length | ternary(_generated_admin_password, _admin_password_secret) }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Store admin password
|
||||
set_fact:
|
||||
admin_password: "{{ __admin_password_secret['resources'][0]['data']['password'] | b64decode }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ broadcast_websocket_secret }}'
|
||||
register: _custom_broadcast_websocket
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: broadcast_websocket_secret | length
|
||||
|
||||
- name: Check for default broadcast websocket secret configuration
|
||||
@@ -14,20 +14,20 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-broadcast-websocket'
|
||||
register: _default_broadcast_websocket
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set broadcast websocket secret
|
||||
set_fact:
|
||||
# yamllint disable-line rule:line-length
|
||||
_broadcast_websocket_secret: '{{ _custom_broadcast_websocket["resources"] | default([]) | length | ternary(_custom_broadcast_websocket, _default_broadcast_websocket) }}' # noqa 204
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- block:
|
||||
- name: Create broadcast websocket secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'broadcast_websocket_secret.yaml.j2') }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Read broadcast websocket secret
|
||||
k8s_info:
|
||||
@@ -35,7 +35,7 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-broadcast-websocket'
|
||||
register: _generated_broadcast_websocket
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
when: not _broadcast_websocket_secret['resources'] | default([]) | length
|
||||
|
||||
@@ -43,9 +43,9 @@
|
||||
set_fact:
|
||||
# yamllint disable-line rule:line-length
|
||||
__broadcast_websocket_secret: '{{ _generated_broadcast_websocket["resources"] | default([]) | length | ternary(_generated_broadcast_websocket, _broadcast_websocket_secret) }}' # noqa 204
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Store broadcast websocket secret name
|
||||
set_fact:
|
||||
broadcast_websocket_secret_value: "{{ __broadcast_websocket_secret['resources'][0]['data']['secret'] | b64decode }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
- '{{ _secret_key }}'
|
||||
- '{{ _postgres_configuration }}'
|
||||
- '{{ _broadcast_websocket_secret }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
when: not garbage_collect_secrets | bool
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
name: '{{ postgres_configuration_secret }}'
|
||||
register: _custom_pg_config_resources
|
||||
when: postgres_configuration_secret | length
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Check for default PostgreSQL configuration
|
||||
k8s_info:
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-configuration'
|
||||
register: _default_pg_config_resources
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Check for specified old PostgreSQL configuration secret
|
||||
k8s_info:
|
||||
@@ -23,7 +23,7 @@
|
||||
name: '{{ old_postgres_configuration_secret }}'
|
||||
register: _custom_old_pg_config_resources
|
||||
when: old_postgres_configuration_secret | length
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Check for default old PostgreSQL configuration
|
||||
k8s_info:
|
||||
@@ -31,7 +31,7 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-old-postgres-configuration'
|
||||
register: _default_old_pg_config_resources
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set old PostgreSQL configuration
|
||||
set_fact:
|
||||
@@ -45,7 +45,7 @@
|
||||
when:
|
||||
- old_pg_config['resources'] is defined
|
||||
- old_pg_config['resources'] | length
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set default postgres image
|
||||
set_fact:
|
||||
@@ -54,7 +54,7 @@
|
||||
- name: Set PostgreSQL configuration
|
||||
set_fact:
|
||||
_pg_config: '{{ _custom_pg_config_resources["resources"] | default([]) | length | ternary(_custom_pg_config_resources, _default_pg_config_resources) }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set user provided postgres image
|
||||
set_fact:
|
||||
@@ -72,7 +72,7 @@
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'postgres_secret.yaml.j2') }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Read Database Configuration
|
||||
k8s_info:
|
||||
@@ -80,18 +80,74 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-configuration'
|
||||
register: _generated_pg_config_resources
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: not _pg_config['resources'] | default([]) | length
|
||||
|
||||
- name: Set PostgreSQL Configuration
|
||||
set_fact:
|
||||
pg_config: '{{ _generated_pg_config_resources["resources"] | default([]) | length | ternary(_generated_pg_config_resources, _pg_config) }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set actual postgres configuration secret used
|
||||
set_fact:
|
||||
__postgres_configuration_secret: "{{ pg_config['resources'][0]['metadata']['name'] }}"
|
||||
|
||||
- name: Store Database Configuration
|
||||
set_fact:
|
||||
awx_postgres_user: "{{ pg_config['resources'][0]['data']['username'] | b64decode }}"
|
||||
awx_postgres_pass: "{{ pg_config['resources'][0]['data']['password'] | b64decode }}"
|
||||
awx_postgres_database: "{{ pg_config['resources'][0]['data']['database'] | b64decode }}"
|
||||
awx_postgres_port: "{{ pg_config['resources'][0]['data']['port'] | b64decode }}"
|
||||
awx_postgres_host: "{{ pg_config['resources'][0]['data']['host'] | b64decode }}"
|
||||
awx_postgres_sslmode: "{{ pg_config['resources'][0]['data']['sslmode'] | default('prefer'|b64encode) | b64decode }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set database as managed
|
||||
set_fact:
|
||||
managed_database: "{{ pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed' }}"
|
||||
|
||||
- name: Get the old postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres-0"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: old_postgres_pod
|
||||
|
||||
- name: Look up details for this deployment
|
||||
k8s_info:
|
||||
api_version: "{{ api_version }}"
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: this_awx
|
||||
|
||||
- name: Check if postgres pod is running and version 12
|
||||
block:
|
||||
- name: Set path to PG_VERSION file for given container image
|
||||
set_fact:
|
||||
path_to_pg_version: '{{ postgres_data_path }}/PG_VERSION'
|
||||
|
||||
- name: Get old PostgreSQL version
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ ansible_operator_meta.name }}-postgres-0"
|
||||
command: |
|
||||
bash -c """
|
||||
cat {{ path_to_pg_version }}
|
||||
"""
|
||||
register: _old_pg_version
|
||||
|
||||
- name: Upgrade data dir from Postgres 12 to 13 if applicable
|
||||
include_tasks: upgrade_postgres.yml
|
||||
when:
|
||||
- _old_pg_version.stdout | default('0') | trim == '12'
|
||||
when:
|
||||
- managed_database
|
||||
- this_awx['resources'][0]['status']['upgradedPostgresVersion'] | default('none') != '12'
|
||||
- old_postgres_pod['resources'] | length # upgrade is complete and old pg pod has been removed
|
||||
|
||||
- block:
|
||||
- name: Create Database if no database is specified
|
||||
k8s:
|
||||
@@ -111,7 +167,7 @@
|
||||
kubernetes.core.k8s_scale:
|
||||
api_version: apps/v1
|
||||
kind: StatefulSet
|
||||
name: "{{ ansible_operator_meta.name }}-postgres"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres-13"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
replicas: 0
|
||||
wait: yes
|
||||
@@ -121,7 +177,7 @@
|
||||
state: absent
|
||||
api_version: apps/v1
|
||||
kind: StatefulSet
|
||||
name: "{{ ansible_operator_meta.name }}-postgres"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres-13"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
wait: yes
|
||||
when: create_statefulset_result.error == 422
|
||||
@@ -130,23 +186,29 @@
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'postgres.yaml.j2') }}"
|
||||
when: pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed'
|
||||
when: managed_database
|
||||
|
||||
- name: Store Database Configuration
|
||||
- name: Set Default label selector for custom resource generated postgres
|
||||
set_fact:
|
||||
awx_postgres_user: "{{ pg_config['resources'][0]['data']['username'] | b64decode }}"
|
||||
awx_postgres_pass: "{{ pg_config['resources'][0]['data']['password'] | b64decode }}"
|
||||
awx_postgres_database: "{{ pg_config['resources'][0]['data']['database'] | b64decode }}"
|
||||
awx_postgres_port: "{{ pg_config['resources'][0]['data']['port'] | b64decode }}"
|
||||
awx_postgres_host: "{{ pg_config['resources'][0]['data']['host'] | b64decode }}"
|
||||
awx_postgres_sslmode: "{{ pg_config['resources'][0]['data']['sslmode'] | default('prefer'|b64encode) | b64decode }}"
|
||||
no_log: true
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get the postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: postgres_pod
|
||||
|
||||
- name: Wait for Database to initialize if managed DB
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-0' # using name to keep compatibility
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: postgres_pod
|
||||
@@ -156,11 +218,7 @@
|
||||
- "postgres_pod['resources'][0]['status']['containerStatuses'][0]['ready'] == true"
|
||||
delay: 5
|
||||
retries: 60
|
||||
when: pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed'
|
||||
|
||||
- name: Set database as managed
|
||||
set_fact:
|
||||
managed_database: "{{ pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed' }}"
|
||||
when: managed_database
|
||||
|
||||
- name: Look up details for this deployment
|
||||
k8s_info:
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
bash -c "echo \"from django.contrib.auth.models import User;
|
||||
User.objects.create_superuser('{{ admin_user }}', '{{ admin_email }}', '{{ admin_password }}')\"
|
||||
| awx-manage shell"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: users_result.return_code > 0
|
||||
|
||||
- name: Check if legacy queue is present
|
||||
@@ -57,7 +57,7 @@
|
||||
_execution_environments_pull_credentials: >-
|
||||
{{ _custom_execution_environments_pull_credentials["resources"] | default([]) | length
|
||||
| ternary(_custom_execution_environments_pull_credentials, []) }}
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Register default execution environments (without authentication)
|
||||
k8s_exec:
|
||||
@@ -78,7 +78,7 @@
|
||||
default_execution_environment_pull_credentials_url: "{{ _execution_environments_pull_credentials['resources'][0]['data']['url'] | b64decode }}"
|
||||
default_execution_environment_pull_credentials_url_verify: >-
|
||||
{{ _execution_environments_pull_credentials['resources'][0]['data']['ssl_verify'] | default("True"|b64encode) | b64decode }}
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Register default execution environments (with authentication)
|
||||
k8s_exec:
|
||||
@@ -93,7 +93,7 @@
|
||||
--verify-ssl='{{ default_execution_environment_pull_credentials_url_verify }}'"
|
||||
register: ree
|
||||
changed_when: "'changed: True' in ree.stdout"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: _execution_environments_pull_credentials['resources'] | default([]) | length
|
||||
|
||||
- name: Create preload data if necessary. # noqa 305
|
||||
|
||||
89
roles/installer/tasks/install.yml
Normal file
89
roles/installer/tasks/install.yml
Normal file
@@ -0,0 +1,89 @@
|
||||
---
|
||||
- name: Patching labels to AWX kind
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: '{{ api_version }}'
|
||||
kind: '{{ kind }}'
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
app.kubernetes.io/component: '{{ deployment_type }}'
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
when: set_self_labels | bool
|
||||
|
||||
- name: Include secret key configuration tasks
|
||||
include_tasks: secret_key_configuration.yml
|
||||
|
||||
- name: Load LDAP CAcert certificate
|
||||
include_tasks: load_ldap_cacert_secret.yml
|
||||
when:
|
||||
- ldap_cacert_secret != ''
|
||||
|
||||
- name: Load ldap bind password
|
||||
include_tasks: load_ldap_password_secret.yml
|
||||
when:
|
||||
- ldap_password_secret != ''
|
||||
|
||||
- name: Load bundle certificate authority certificate
|
||||
include_tasks: load_bundle_cacert_secret.yml
|
||||
when:
|
||||
- bundle_cacert_secret != ''
|
||||
|
||||
- name: Include admin password configuration tasks
|
||||
include_tasks: admin_password_configuration.yml
|
||||
|
||||
- name: Include broadcast websocket configuration tasks
|
||||
include_tasks: broadcast_websocket_configuration.yml
|
||||
|
||||
- name: Include set_images tasks
|
||||
include_tasks: set_images.yml
|
||||
|
||||
- name: Include database configuration tasks
|
||||
include_tasks: database_configuration.yml
|
||||
|
||||
- name: Load Route TLS certificate
|
||||
include_tasks: load_route_tls_secret.yml
|
||||
when:
|
||||
- ingress_type | lower == 'route'
|
||||
- route_tls_secret != ''
|
||||
|
||||
- name: Include resources configuration tasks
|
||||
include_tasks: resources_configuration.yml
|
||||
|
||||
- name: Check for pending migrations
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ tower_pod_name }}"
|
||||
container: "{{ ansible_operator_meta.name }}-task"
|
||||
command: >-
|
||||
bash -c "awx-manage showmigrations | grep -v '[X]' | grep '[ ]' | wc -l"
|
||||
changed_when: false
|
||||
register: database_check
|
||||
|
||||
- name: Migrate the database if the K8s resources were updated. # noqa 305
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ tower_pod_name }}"
|
||||
container: "{{ ansible_operator_meta.name }}-task"
|
||||
command: >-
|
||||
bash -c "awx-manage migrate --noinput"
|
||||
register: migrate_result
|
||||
when:
|
||||
- database_check is defined
|
||||
- (database_check.stdout|trim) != '0'
|
||||
|
||||
- name: Initialize Django
|
||||
include_tasks: initialize_django.yml
|
||||
|
||||
- name: Update status variables
|
||||
include_tasks: update_status.yml
|
||||
|
||||
- name: Cleanup & Set garbage collection refs
|
||||
include_tasks: cleanup.yml
|
||||
@@ -5,10 +5,10 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ bundle_cacert_secret }}'
|
||||
register: bundle_cacert
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Load bundle Certificate Authority Secret content
|
||||
set_fact:
|
||||
bundle_ca_crt: '{{ bundle_cacert["resources"][0]["data"]["bundle-ca.crt"] | b64decode }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: '"bundle-ca.crt" in bundle_cacert["resources"][0]["data"]'
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ldap_cacert_secret }}'
|
||||
register: ldap_cacert
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Load LDAP CA Certificate Secret content
|
||||
set_fact:
|
||||
ldap_cacert_ca_crt: '{{ ldap_cacert["resources"][0]["data"]["ldap-ca.crt"] | b64decode }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: '"ldap-ca.crt" in ldap_cacert["resources"][0]["data"]'
|
||||
|
||||
14
roles/installer/tasks/load_ldap_password_secret.yml
Normal file
14
roles/installer/tasks/load_ldap_password_secret.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: Retrieve LDAP bind password Secret
|
||||
k8s_info:
|
||||
kind: Secret
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ldap_password_secret }}'
|
||||
register: ldap_password
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Load LDAP bind password Secret content
|
||||
set_fact:
|
||||
ldap_bind_password: '{{ ldap_password["resources"][0]["data"]["ldap-password"] | b64decode }}'
|
||||
no_log: "{{ no_log }}"
|
||||
when: '"ldap-password" in ldap_password["resources"][0]["data"]'
|
||||
@@ -5,16 +5,16 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ route_tls_secret }}'
|
||||
register: route_tls
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Load Route TLS Secret content
|
||||
set_fact:
|
||||
route_tls_key: '{{ route_tls["resources"][0]["data"]["tls.key"] | b64decode }}'
|
||||
route_tls_crt: '{{ route_tls["resources"][0]["data"]["tls.crt"] | b64decode }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Load Route TLS Secret content
|
||||
set_fact:
|
||||
route_ca_crt: '{{ route_tls["resources"][0]["data"]["ca.crt"] | b64decode }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: '"ca.crt" in route_tls["resources"][0]["data"]'
|
||||
|
||||
@@ -1,83 +1,13 @@
|
||||
---
|
||||
- name: Patching labels to AWX kind
|
||||
k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: '{{ api_version }}'
|
||||
kind: '{{ kind }}'
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
app.kubernetes.io/component: '{{ deployment_type }}'
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
|
||||
- name: Include secret key configuration tasks
|
||||
include_tasks: secret_key_configuration.yml
|
||||
|
||||
- name: Load LDAP CAcert certificate
|
||||
include_tasks: load_ldap_cacert_secret.yml
|
||||
when:
|
||||
- ldap_cacert_secret != ''
|
||||
|
||||
- name: Load bundle certificate authority certificate
|
||||
include_tasks: load_bundle_cacert_secret.yml
|
||||
when:
|
||||
- bundle_cacert_secret != ''
|
||||
|
||||
- name: Include admin password configuration tasks
|
||||
include_tasks: admin_password_configuration.yml
|
||||
|
||||
- name: Include broadcast websocket configuration tasks
|
||||
include_tasks: broadcast_websocket_configuration.yml
|
||||
|
||||
- name: Include set_images tasks
|
||||
include_tasks: set_images.yml
|
||||
|
||||
- name: Include database configuration tasks
|
||||
include_tasks: database_configuration.yml
|
||||
|
||||
- name: Load Route TLS certificate
|
||||
include_tasks: load_route_tls_secret.yml
|
||||
when:
|
||||
- ingress_type | lower == 'route'
|
||||
- route_tls_secret != ''
|
||||
|
||||
- name: Include resources configuration tasks
|
||||
include_tasks: resources_configuration.yml
|
||||
|
||||
- name: Check for pending migrations
|
||||
k8s_exec:
|
||||
- name: Check for presence of Deployment
|
||||
k8s_info:
|
||||
api_version: v1
|
||||
kind: Deployment
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ tower_pod_name }}"
|
||||
container: "{{ ansible_operator_meta.name }}-task"
|
||||
command: >-
|
||||
bash -c "awx-manage showmigrations | grep -v '[X]' | grep '[ ]' | wc -l"
|
||||
changed_when: false
|
||||
register: database_check
|
||||
register: tower_deployment
|
||||
|
||||
- name: Migrate the database if the K8s resources were updated. # noqa 305
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ tower_pod_name }}"
|
||||
container: "{{ ansible_operator_meta.name }}-task"
|
||||
command: >-
|
||||
bash -c "awx-manage migrate --noinput"
|
||||
register: migrate_result
|
||||
when:
|
||||
- database_check is defined
|
||||
- (database_check.stdout|trim) != '0'
|
||||
|
||||
- name: Initialize Django
|
||||
include_tasks: initialize_django.yml
|
||||
|
||||
- name: Update status variables
|
||||
include_tasks: update_status.yml
|
||||
|
||||
- name: Cleanup & Set garbage collection refs
|
||||
include_tasks: cleanup.yml
|
||||
# Just execute deployment steps when auto_upgrade is true or when no deployment exists
|
||||
- name: Start installation
|
||||
include_tasks: install.yml
|
||||
when: (tower_deployment['resources'] | length > 0 and auto_upgrade | bool ) or (tower_deployment['resources'] | length == 0)
|
||||
|
||||
@@ -11,27 +11,22 @@
|
||||
awx_old_postgres_database: "{{ old_pg_config['resources'][0]['data']['database'] | b64decode }}"
|
||||
awx_old_postgres_port: "{{ old_pg_config['resources'][0]['data']['port'] | b64decode }}"
|
||||
awx_old_postgres_host: "{{ old_pg_config['resources'][0]['data']['host'] | b64decode }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Default label selector to custom resource generated postgres
|
||||
- name: Set Default label selector for custom resource generated postgres
|
||||
set_fact:
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ ansible_operator_meta.name }}"
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get the postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-0' # using name to keep compatibility
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: postgres_pod
|
||||
until:
|
||||
- "postgres_pod['resources'] | length"
|
||||
- "postgres_pod['resources'][0]['status']['phase'] == 'Running'"
|
||||
- "postgres_pod['resources'][0]['status']['containerStatuses'][0]['ready'] == true"
|
||||
delay: 5
|
||||
retries: 60
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
@@ -49,7 +44,7 @@
|
||||
-d {{ awx_old_postgres_database }}
|
||||
-p {{ awx_old_postgres_port }}
|
||||
-F custom
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set pg_restore command
|
||||
set_fact:
|
||||
@@ -57,7 +52,7 @@
|
||||
pg_restore --clean --if-exists
|
||||
-U {{ database_username }}
|
||||
-d {{ database_name }}
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Stream backup from pg_dump to the new postgresql container
|
||||
k8s_exec:
|
||||
@@ -69,7 +64,7 @@
|
||||
PGPASSWORD='{{ awx_old_postgres_pass }}' {{ pgdump }} | PGPASSWORD='{{ awx_postgres_pass }}' {{ pg_restore }}
|
||||
echo 'Successful'
|
||||
"""
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
register: data_migration
|
||||
failed_when: "'Successful' not in data_migration.stdout"
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
- "app.kubernetes.io/component={{ deployment_type }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: tower_pods
|
||||
register: tower_pod
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
tower_pod_name: "{{ tower_pods['resources'][0]['metadata']['name'] | default('') }}"
|
||||
tower_pod_name: "{{ tower_pod['resources'][0]['metadata']['name'] | default('') }}"
|
||||
|
||||
- name: Set user provided control plane ee image
|
||||
set_fact:
|
||||
@@ -40,7 +40,7 @@
|
||||
- 'persistent'
|
||||
- 'service'
|
||||
- 'ingress'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set default awx app image
|
||||
set_fact:
|
||||
@@ -77,7 +77,7 @@
|
||||
apply: yes
|
||||
definition: "{{ lookup('template', 'deployment.yaml.j2') }}"
|
||||
wait: yes
|
||||
register: tower_deployment_result
|
||||
register: this_deployment_result
|
||||
|
||||
- block:
|
||||
- name: Delete pod to reload a resource configuration
|
||||
@@ -113,7 +113,7 @@
|
||||
set_fact:
|
||||
tower_pod_name: '{{ _new_pod["resources"][0]["metadata"]["name"] }}'
|
||||
when:
|
||||
- tower_resources_result.changed or tower_deployment_result.changed
|
||||
- tower_resources_result.changed or this_deployment_result.changed
|
||||
|
||||
- name: Verify the resource pod name is populated.
|
||||
assert:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
kind: Deployment
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
register: tower_deployment
|
||||
register: this_deployment
|
||||
|
||||
- name: Scale down Deployment for migration
|
||||
kubernetes.core.k8s_scale:
|
||||
@@ -16,4 +16,4 @@
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
replicas: 0
|
||||
wait: yes
|
||||
when: tower_deployment['resources'] | length
|
||||
when: this_deployment['resources'] | length
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ secret_key_secret }}'
|
||||
register: _custom_secret_key
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: secret_key_secret | length
|
||||
|
||||
- name: Check for default secret key configuration
|
||||
@@ -14,19 +14,19 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-secret-key'
|
||||
register: _default_secret_key
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set secret key secret
|
||||
set_fact:
|
||||
_secret_key_secret: '{{ _custom_secret_key["resources"] | default([]) | length | ternary(_custom_secret_key, _default_secret_key) }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- block:
|
||||
- name: Create secret key secret
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'secret_key.yaml.j2') }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Read secret key secret
|
||||
k8s_info:
|
||||
@@ -34,16 +34,16 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ ansible_operator_meta.name }}-secret-key'
|
||||
register: _generated_secret_key
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
when: not _secret_key_secret['resources'] | default([]) | length
|
||||
|
||||
- name: Set secret key secret
|
||||
set_fact:
|
||||
__secret_key_secret: '{{ _generated_secret_key["resources"] | default([]) | length | ternary(_generated_secret_key, _secret_key_secret) }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Store secret key secret name
|
||||
set_fact:
|
||||
secret_key_secret_name: "{{ __secret_key_secret['resources'][0]['metadata']['name'] }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
@@ -101,3 +101,13 @@
|
||||
status:
|
||||
migratedFromSecret: "{{ tower_migrated_from_secret }}"
|
||||
when: tower_migrated_from_secret is defined
|
||||
|
||||
- name: Update upgradedPostgresVersion status
|
||||
operator_sdk.util.k8s_status:
|
||||
api_version: '{{ api_version }}'
|
||||
kind: "{{ kind }}"
|
||||
name: "{{ ansible_operator_meta.name }}"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
status:
|
||||
upgradedPostgresVersion: "{{ upgraded_postgres_version }}"
|
||||
when: upgraded_postgres_version is defined
|
||||
|
||||
132
roles/installer/tasks/upgrade_postgres.yml
Normal file
132
roles/installer/tasks/upgrade_postgres.yml
Normal file
@@ -0,0 +1,132 @@
|
||||
---
|
||||
|
||||
# Upgrade Posgres (Managed Databases only)
|
||||
# * If postgres version is not 12, and not an external postgres instance (when managed_database is yes),
|
||||
# then run this playbook with include_tasks from database_configuration.yml
|
||||
# * Data will be streamed via a pg_dump from the postgres 12 pod to the postgres 13
|
||||
# pod via a pg_restore.
|
||||
|
||||
|
||||
- name: Scale down Deployment for migration
|
||||
include_tasks: scale_down_deployment.yml
|
||||
|
||||
- name: Delete existing postgres configuration secret
|
||||
k8s:
|
||||
api_version: v1
|
||||
kind: Secret
|
||||
name: "{{ ansible_operator_meta.name }}-postgres-configuration"
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
state: absent
|
||||
wait: yes
|
||||
|
||||
- name: Create Database configuration with new -postgres-{{ supported_pg_version }} hostname
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'postgres_upgrade_secret.yaml.j2') }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set new database var to be used when configuring app credentials (resources_configuration.yml)
|
||||
set_fact:
|
||||
awx_postgres_host: "{{ ansible_operator_meta.name }}-postgres-{{ supported_pg_version }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Create Database if no database is specified
|
||||
k8s:
|
||||
apply: true
|
||||
definition: "{{ lookup('template', 'postgres.yaml.j2') }}"
|
||||
wait: true
|
||||
register: create_statefulset_result
|
||||
|
||||
- name: Set postgres label if not defined by user
|
||||
set_fact:
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get new postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
register: postgres_pod
|
||||
until:
|
||||
- "postgres_pod['resources'] | length"
|
||||
- "postgres_pod['resources'][0]['status']['phase'] == 'Running'"
|
||||
- "postgres_pod['resources'][0]['status']['containerStatuses'][0]['ready'] == true"
|
||||
delay: 5
|
||||
retries: 60
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
postgres_pod_name: "{{ postgres_pod['resources'][0]['metadata']['name'] }}"
|
||||
|
||||
- name: Set full resolvable host name for postgres pod
|
||||
set_fact:
|
||||
resolvable_db_host: "{{ ansible_operator_meta.name }}-postgres.{{ ansible_operator_meta.namespace }}.svc.cluster.local" # yamllint disable-line rule:line-length
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set pg_dump command
|
||||
set_fact:
|
||||
pgdump: >-
|
||||
pg_dump
|
||||
-h {{ resolvable_db_host }}
|
||||
-U {{ awx_postgres_user }}
|
||||
-d {{ awx_postgres_database }}
|
||||
-p {{ awx_postgres_port }}
|
||||
-F custom
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set pg_restore command
|
||||
set_fact:
|
||||
pg_restore: >-
|
||||
pg_restore
|
||||
-U {{ awx_postgres_user }}
|
||||
-d {{ awx_postgres_database }}
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Stream backup from pg_dump to the new postgresql container
|
||||
k8s_exec:
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
pod: "{{ postgres_pod_name }}"
|
||||
command: |
|
||||
bash -c """
|
||||
set -e -o pipefail
|
||||
PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} | PGPASSWORD={{ awx_postgres_pass }} {{ pg_restore }}
|
||||
echo 'Successful'
|
||||
"""
|
||||
no_log: "{{ no_log }}"
|
||||
register: data_migration
|
||||
failed_when: "'Successful' not in data_migration.stdout"
|
||||
|
||||
- name: Set flag signifying that this instance has been migrated
|
||||
set_fact:
|
||||
upgraded_postgres_version: '13'
|
||||
|
||||
# Cleanup old Postgres resources
|
||||
- name: Remove old Postgres StatefulSet
|
||||
k8s:
|
||||
kind: StatefulSet
|
||||
api_version: v1
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres"
|
||||
state: absent
|
||||
wait: true
|
||||
|
||||
- name: Remove old Postgres Service
|
||||
k8s:
|
||||
kind: Service
|
||||
api_version: v1
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "{{ ansible_operator_meta.name }}-postgres"
|
||||
state: absent
|
||||
|
||||
- name: Remove old persistent volume claim
|
||||
k8s:
|
||||
kind: PersistentVolumeClaim
|
||||
api_version: v1
|
||||
namespace: "{{ ansible_operator_meta.namespace }}"
|
||||
name: "postgres-{{ ansible_operator_meta.name }}-postgres-0"
|
||||
state: absent
|
||||
when: postgres_keep_pvc_after_upgrade
|
||||
@@ -60,8 +60,8 @@ data:
|
||||
CLUSTER_HOST_ID = socket.gethostname()
|
||||
SYSTEM_UUID = os.environ.get('MY_POD_UID', '00000000-0000-0000-0000-000000000000')
|
||||
|
||||
CSRF_COOKIE_SECURE = '{{ csrf_cookie_secure }}'
|
||||
SESSION_COOKIE_SECURE = '{{ session_cookie_secure }}'
|
||||
CSRF_COOKIE_SECURE = {{ csrf_cookie_secure | bool }}
|
||||
SESSION_COOKIE_SECURE = {{ session_cookie_secure | bool }}
|
||||
|
||||
SERVER_EMAIL = 'root@localhost'
|
||||
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
|
||||
@@ -145,6 +145,7 @@ data:
|
||||
{% if route_tls_termination_mechanism | lower == 'passthrough' %}
|
||||
server {
|
||||
listen 8052 default_server;
|
||||
listen [::]:8052 default_server;
|
||||
server_name _;
|
||||
|
||||
# Redirect all HTTP links to the matching HTTPS page
|
||||
@@ -155,6 +156,7 @@ data:
|
||||
server {
|
||||
{% if route_tls_termination_mechanism | lower == 'passthrough' %}
|
||||
listen 8053 ssl;
|
||||
listen [::]:8053 ssl;
|
||||
|
||||
ssl_certificate /etc/nginx/pki/web.crt;
|
||||
ssl_certificate_key /etc/nginx/pki/web.key;
|
||||
@@ -165,6 +167,7 @@ data:
|
||||
ssl_prefer_server_ciphers on;
|
||||
{% else %}
|
||||
listen 8052 default_server;
|
||||
listen [::]:8052 default_server;
|
||||
{% endif %}
|
||||
|
||||
# If you have a domain name, this is where to add it
|
||||
@@ -176,6 +179,8 @@ data:
|
||||
|
||||
# Protect against click-jacking https://www.owasp.org/index.php/Testing_for_Clickjacking_(OTG-CLIENT-009)
|
||||
add_header X-Frame-Options "DENY";
|
||||
# Protect against MIME content sniffing https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
|
||||
location /nginx_status {
|
||||
stub_status on;
|
||||
@@ -229,6 +234,7 @@ data:
|
||||
add_header Strict-Transport-Security max-age=15768000;
|
||||
# Protect against click-jacking https://www.owasp.org/index.php/Testing_for_Clickjacking_(OTG-CLIENT-009)
|
||||
add_header X-Frame-Options "DENY";
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Expires "0";
|
||||
add_header Pragma "no-cache";
|
||||
|
||||
@@ -101,6 +101,7 @@ spec:
|
||||
mountPath: "/var/run/redis"
|
||||
- name: "{{ ansible_operator_meta.name }}-redis-data"
|
||||
mountPath: "/data"
|
||||
resources: {{ redis_resource_requirements }}
|
||||
- image: '{{ _image }}'
|
||||
name: '{{ ansible_operator_meta.name }}-web'
|
||||
{% if web_command %}
|
||||
|
||||
@@ -4,3 +4,8 @@ AUTH_LDAP_GLOBAL_OPTIONS = {
|
||||
ldap.OPT_X_TLS_CACERTFILE: "/etc/openldap/certs/ldap-ca.crt"
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
# Load LDAP BIND password from Kubernetes secret if define
|
||||
{% if ldap_password_secret -%}
|
||||
AUTH_LDAP_BIND_PASSWORD = "{{ ldap_bind_password }}"
|
||||
{% endif %}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}-postgres'
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-{{ supported_pg_version }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
app.kubernetes.io/name: 'postgres'
|
||||
app.kubernetes.io/instance: 'postgres-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
|
||||
app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/component: 'database'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
@@ -16,8 +16,8 @@ metadata:
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: 'postgres'
|
||||
app.kubernetes.io/instance: 'postgres-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
|
||||
app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/component: 'database'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
serviceName: '{{ ansible_operator_meta.name }}'
|
||||
@@ -27,8 +27,8 @@ spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: 'postgres'
|
||||
app.kubernetes.io/instance: 'postgres-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
|
||||
app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/component: 'database'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
@@ -45,20 +45,6 @@ spec:
|
||||
{% if postgres_priority_class is defined %}
|
||||
priorityClassName: '{{ postgres_priority_class }}'
|
||||
{% endif %}
|
||||
initContainers:
|
||||
- name: database-check
|
||||
image: '{{ _init_container_image }}'
|
||||
resources: {{ postgres_init_container_resource_requirements }}
|
||||
imagePullPolicy: '{{ image_pull_policy }}'
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
[[ -d /check-db/pgsql/data ]] && rm -rf /check-db/data && mv /check-db/pgsql/data/ /check-db/data/ && rm -rf /check-db/pgsql || exit 0
|
||||
volumeMounts:
|
||||
- name: postgres
|
||||
mountPath: /check-db
|
||||
subPath: ''
|
||||
containers:
|
||||
- image: '{{ _postgres_image }}'
|
||||
imagePullPolicy: '{{ image_pull_policy }}'
|
||||
@@ -67,7 +53,7 @@ spec:
|
||||
args: {{ postgres_extra_args }}
|
||||
{% endif %}
|
||||
env:
|
||||
# For postgres_image based on rhel8/postgresql-12
|
||||
# For postgres_image based on rhel8/postgresql-13
|
||||
- name: POSTGRESQL_DATABASE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
@@ -108,9 +94,9 @@ spec:
|
||||
value: '{{ postgres_host_auth_method }}'
|
||||
ports:
|
||||
- containerPort: {{ awx_postgres_port | default('5432')}}
|
||||
name: postgres
|
||||
name: postgres-{{ supported_pg_version }}
|
||||
volumeMounts:
|
||||
- name: postgres
|
||||
- name: postgres-{{ supported_pg_version }}
|
||||
mountPath: '{{ postgres_data_path | dirname }}'
|
||||
subPath: '{{ postgres_data_path | dirname | basename }}'
|
||||
resources: {{ postgres_resource_requirements }}
|
||||
@@ -124,7 +110,7 @@ spec:
|
||||
{% endif %}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: postgres
|
||||
name: postgres-{{ supported_pg_version }}
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
@@ -138,11 +124,11 @@ spec:
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}-postgres'
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-{{ supported_pg_version }}'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
app.kubernetes.io/name: 'postgres'
|
||||
app.kubernetes.io/instance: 'postgres-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
|
||||
app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/component: 'database'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
@@ -153,8 +139,8 @@ spec:
|
||||
- port: 5432
|
||||
clusterIP: None
|
||||
selector:
|
||||
app.kubernetes.io/name: 'postgres'
|
||||
app.kubernetes.io/instance: 'postgres-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
|
||||
app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/component: 'database'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
|
||||
@@ -16,5 +16,5 @@ stringData:
|
||||
username: '{{ database_username }}'
|
||||
database: '{{ database_name }}'
|
||||
port: '5432'
|
||||
host: {{ ansible_operator_meta.name }}-postgres
|
||||
host: {{ ansible_operator_meta.name }}-postgres-{{ supported_pg_version }}
|
||||
type: 'managed'
|
||||
|
||||
20
roles/installer/templates/postgres_upgrade_secret.yaml.j2
Normal file
20
roles/installer/templates/postgres_upgrade_secret.yaml.j2
Normal file
@@ -0,0 +1,20 @@
|
||||
# Postgres Secret.
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: '{{ ansible_operator_meta.name }}-postgres-configuration'
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
labels:
|
||||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
app.kubernetes.io/component: '{{ deployment_type }}'
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
stringData:
|
||||
password: '{{ awx_postgres_pass }}'
|
||||
username: '{{ awx_postgres_user }}'
|
||||
database: '{{ awx_postgres_database }}'
|
||||
port: '{{ awx_postgres_port }}'
|
||||
host: '{{ ansible_operator_meta.name }}-postgres-{{ supported_pg_version }}'
|
||||
type: 'managed'
|
||||
@@ -4,3 +4,4 @@ postgres_host_auth_method: 'scram-sha-256'
|
||||
ldap_cacert_ca_crt: ''
|
||||
bundle_ca_crt: ''
|
||||
projects_existing_claim: ''
|
||||
supported_pg_version: 13
|
||||
|
||||
@@ -33,7 +33,6 @@ metadata:
|
||||
spec:
|
||||
deployment_name: mytower
|
||||
backup_name: awxbackup-2021-04-22
|
||||
backup_pvc_namespace: 'old-awx-namespace'
|
||||
```
|
||||
|
||||
Note that the `deployment_name` above is the name of the AWX deployment you intend to create and restore to.
|
||||
@@ -81,11 +80,7 @@ awx-backup-volume-claim
|
||||
backup_pvc: 'awx-backup-volume-claim'
|
||||
```
|
||||
|
||||
By default, the backup pvc will be created in the same namespace the awxbackup object is created in. This namespace must be specified using the `backup_pvc_namespace` variable.
|
||||
|
||||
```
|
||||
backup_pvc_namespace: 'custom-namespace'
|
||||
```
|
||||
The backup pvc will be created in the same namespace the awxbackup object is created in.
|
||||
|
||||
If a custom postgres configuration secret was used when deploying AWX, it must be set:
|
||||
|
||||
|
||||
@@ -10,3 +10,9 @@ backup_pvc_namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
|
||||
# Required: backup name, found on the awxbackup object
|
||||
backup_dir: ''
|
||||
|
||||
# Set no_log settings on certain tasks
|
||||
no_log: 'true'
|
||||
|
||||
# Maintain some of the recommended `app.kubernetes.io/*` labels on the resource (self)
|
||||
set_self_labels: true
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
- '{{ admin_password_secret }}'
|
||||
- '{{ broadcast_websocket_secret }}'
|
||||
- '{{ postgres_configuration_secret }}'
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Cleanup temp spec file
|
||||
file:
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
|
||||
app.kubernetes.io/component: '{{ deployment_type }}'
|
||||
app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}'
|
||||
when: set_self_labels | bool
|
||||
|
||||
- name: Look up details for this restore object
|
||||
k8s_info:
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
name: '{{ postgres_configuration_secret }}'
|
||||
register: pg_config
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Store Database Configuration
|
||||
set_fact:
|
||||
@@ -20,30 +20,31 @@
|
||||
awx_postgres_port: "{{ pg_config['resources'][0]['data']['port'] | b64decode }}"
|
||||
awx_postgres_host: "{{ pg_config['resources'][0]['data']['host'] | b64decode }}"
|
||||
awx_postgres_type: "{{ pg_config['resources'][0]['data']['type'] | b64decode | default('unmanaged') }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Default label selector to custom resource generated postgres
|
||||
- name: Set Default label selector for custom resource generated postgres
|
||||
set_fact:
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ deployment_name }}"
|
||||
postgres_label_selector: "app.kubernetes.io/instance=postgres-{{ supported_pg_version }}-{{ deployment_name }}"
|
||||
when: postgres_label_selector is not defined
|
||||
|
||||
- name: Get the postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
register: postgres_pod
|
||||
until:
|
||||
- "postgres_pod['resources'] | length"
|
||||
- "postgres_pod['resources'][0]['status']['phase'] == 'Running'"
|
||||
- "postgres_pod['resources'][0]['status']['containerStatuses'][0]['ready'] == true"
|
||||
delay: 5
|
||||
retries: 60
|
||||
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
postgres_pod_name: "{{ postgres_pod['resources'][0]['metadata']['name'] }}"
|
||||
- block:
|
||||
- name: Get the postgres pod information
|
||||
k8s_info:
|
||||
kind: Pod
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
label_selectors:
|
||||
- "{{ postgres_label_selector }}"
|
||||
register: postgres_pod
|
||||
until:
|
||||
- "postgres_pod['resources'] | length"
|
||||
- "postgres_pod['resources'][0]['status']['phase'] == 'Running'"
|
||||
- "postgres_pod['resources'][0]['status']['containerStatuses'][0]['ready'] == true"
|
||||
delay: 5
|
||||
retries: 60
|
||||
- name: Set the resource pod name as a variable.
|
||||
set_fact:
|
||||
postgres_pod_name: "{{ postgres_pod['resources'][0]['metadata']['name'] }}"
|
||||
when: awx_postgres_type == 'managed'
|
||||
|
||||
- name: Check for presence of AWX Deployment
|
||||
k8s_info:
|
||||
@@ -66,7 +67,7 @@
|
||||
- name: Set full resolvable host name for postgres pod
|
||||
set_fact:
|
||||
resolvable_db_host: "{{ awx_postgres_host }}.{{ ansible_operator_meta.namespace }}.svc.cluster.local"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: awx_postgres_type == 'managed'
|
||||
|
||||
- name: Set pg_restore command
|
||||
@@ -78,7 +79,7 @@
|
||||
-U {{ awx_postgres_user }}
|
||||
-d {{ awx_postgres_database }}
|
||||
-p {{ awx_postgres_port }}
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Restore database dump to the new postgresql container
|
||||
k8s_exec:
|
||||
@@ -91,5 +92,5 @@
|
||||
echo 'Successful'
|
||||
"""
|
||||
register: data_migration
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
failed_when: "'Successful' not in data_migration.stdout"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
command: >-
|
||||
bash -c "cat '{{ backup_dir }}/secrets.yml'"
|
||||
register: _secrets
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Create Temporary secrets file
|
||||
tempfile:
|
||||
@@ -20,38 +20,38 @@
|
||||
dest: "{{ tmp_secrets.path }}"
|
||||
content: "{{ _secrets.stdout }}"
|
||||
mode: 0640
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Include secret vars from backup
|
||||
include_vars: "{{ tmp_secrets.path }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: If deployment is managed, set the database_host in the pg config secret
|
||||
block:
|
||||
- name: Set new database host
|
||||
set_fact:
|
||||
database_host: "{{ deployment_name }}-postgres"
|
||||
no_log: true
|
||||
database_host: "{{ deployment_name }}-postgres-{{ supported_pg_version }}"
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Set tmp postgres secret dict
|
||||
set_fact:
|
||||
_pg_secret: "{{ secrets['postgresConfigurationSecret'] }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Change postgres host value
|
||||
set_fact:
|
||||
_pg_data: "{{ _pg_secret['data'] | combine({'host': database_host | b64encode }) }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Create a postgres secret with the new host value
|
||||
set_fact:
|
||||
_pg_secret: "{{ _pg_secret | combine({'data': _pg_data}) }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Create a new dict of secrets with the new postgres secret
|
||||
set_fact:
|
||||
secrets: "{{ secrets | combine({'postgresConfigurationSecret': _pg_secret}) }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
when: secrets['postgresConfigurationSecret']['data']['type'] | b64decode == 'managed'
|
||||
|
||||
- name: Apply secret
|
||||
@@ -61,7 +61,7 @@
|
||||
apply: yes
|
||||
wait: yes
|
||||
definition: "{{ lookup('template', 'secrets.yml.j2') }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
- name: Remove ownerReference on restored secrets
|
||||
k8s:
|
||||
@@ -73,4 +73,4 @@
|
||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||
ownerReferences: null
|
||||
loop: "{{ secrets | dict2items }}"
|
||||
no_log: true
|
||||
no_log: "{{ no_log }}"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
deployment_type: "awx"
|
||||
_postgres_image: postgres
|
||||
_postgres_image_version: 12
|
||||
_postgres_image_version: 13
|
||||
|
||||
backup_api_version: '{{ deployment_type }}.ansible.com/v1beta1'
|
||||
backup_kind: 'AWXBackup'
|
||||
@@ -12,3 +12,4 @@ secret_key_secret: '{{ deployment_name }}-secret-key'
|
||||
admin_password_secret: '{{ deployment_name }}-admin-password'
|
||||
broadcast_websocket_secret: '{{ deployment_name }}-broadcast-websocket'
|
||||
postgres_configuration_secret: '{{ deployment_name }}-postgres-configuration'
|
||||
supported_pg_version: 13
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
kind: AWXBackup
|
||||
role: backup
|
||||
snakeCaseParameters: False
|
||||
finalizer:
|
||||
name: awx.ansible.com/finalizer
|
||||
role: backup
|
||||
vars:
|
||||
finalizer_run: true
|
||||
|
||||
- version: v1beta1
|
||||
group: awx.ansible.com
|
||||
|
||||
Reference in New Issue
Block a user