Skip to content

Commit 572f39c

Browse files
committed
[IDG-15757] - [API] Improve our development env for OpenShift
Signed-off-by: Mauricio Magnani <[email protected]>
1 parent 85c4398 commit 572f39c

File tree

22 files changed

+600
-0
lines changed

22 files changed

+600
-0
lines changed

automation/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Overview
2+
--------
3+
4+
This is a ansible based project to deploy all eda-server related components.
5+
6+
Pre-requisites
7+
--------------
8+
9+
Minikube - https://minikube.sigs.k8s.io/docs ( `minikube addons enable ingress`, `minikube addons enable storage-provisioner` and `minikube addons enable default-storageclass` )
10+
11+
Red Hat OpenShift Local - https://developers.redhat.com/products/openshift-local/overview
12+
13+
Ansible - https://github.com/ansible/ansible
14+
15+
Kubernetes Collection for Ansible - `ansible-galaxy collection install kubernetes.core`
16+
17+
18+
Usage
19+
--------------
20+
21+
Make sure that your Minikube or Openshift Local is running.
22+
23+
After that, review the variables and make any necessary customizations. This can be done in the file:
24+
25+
```bash
26+
group_vars/all/vars.yml
27+
```
28+
29+
The following variables can be customized to determine whether a specific action is executed or not.
30+
31+
**env_type**: This variable supports `"minikube"` or `"openshift"` as the execution target.
32+
33+
**eda_deploy_operator**: This variable must be set to `"true"` for the eda-server-operator to be installed.
34+
35+
**eda_deploy_server**: This variable must be set to `"true"` for eda-server to be installed. At this moment, this installation still relies on the eda-server-operator, as everything is based on the "eda" crd.
36+
37+
**awx_deploy_operator**: This variable must be set to `"true"` for the awx-server-operator to be installed.
38+
39+
**awx_deploy_server**: This variable must be set to `"true"` for awx-server to be installed. At this moment, this installation still relies on the awx-server-operator, as everything is based on the "awx" crd.
40+
41+
To run, simply be in the same directory as the `playbook.yaml` file and execute the command: `ansible-playbook playbook.yaml`
42+
43+
At the end of the execution, you should have all components installed in the namespace defined in the variable `eda_namespace`
44+
45+
In openshift-local (crc) you can access the UI at `eda-aap-eda.apps-crc.testing` and in minikube at `eda.local`

automation/ansible.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[defaults]
2+
host_key_checking = False
3+
retry_files_enabled = False
4+
callback_whitelist = profile_tasks

automation/group_vars/all/vars.yaml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
ansible_python_interpreter: /usr/bin/env python
3+
4+
env_type: openshift #openshift
5+
eda_deploy_operator: "true"
6+
eda_deploy_server: "true"
7+
8+
eda_namespace: aap-eda
9+
10+
eda_operator:
11+
api_version: kustomize.config.k8s.io/v1beta1
12+
namespace: aap-eda
13+
disable_name_suffix_hash: true
14+
secret_generator_name: redhat-operators-pull-secret
15+
operator_literal: eda
16+
resource_url: github.com/ansible/eda-server-operator/config/default?ref=0.0.11
17+
image_name: quay.io/ansible/eda-server-operator
18+
image_new_tag: 0.0.11
19+
20+
eda_operator_files_path: roles/eda-deploy-operator/files
21+
eda_server_files_path: roles/eda-deploy-server/files
22+
23+
eda_server:
24+
pvc_name: eda-postgres-13-volume
25+
access_modes: ReadWriteOnce
26+
storage_request: 500Mi
27+
namespace: aap-eda
28+
admin_user: admin
29+
admin_password_secret: eda-admin-password
30+
automation_server_url: https://awx.local
31+
automation_server_ssl_verify: "no"
32+
image: quay.io/ansible/eda-server
33+
image_version: sha-98eaec9
34+
image_web: quay.io/ansible/eda-ui
35+
image_web_version: 2.4.860
36+
redis_image:
37+
redis_image_version:
38+
api:
39+
replicas: 1
40+
ui:
41+
replicas: 1
42+
worker:
43+
replicas: 2
44+
redis:
45+
replicas: 1
46+
database:
47+
database_secret: eda-database-configuration
48+
storage_requirements:
49+
requests:
50+
storage: 3Gi
51+
resource_requirements:
52+
requests: {}
53+
54+
eda_server_kustomization:
55+
eda_database_configuration_host: eda-postgres-13
56+
eda_database_configuration_port: 5432
57+
eda_database_configuration_database: eda
58+
eda_database_configuration_username: eda
59+
eda_database_configuration_password: testpass
60+
eda_database_configuration_type: managed
61+
eda_admin_password: testpass
62+
63+
# AWX
64+
65+
aws_deploy_operator: "false"
66+
aws_deploy_server: "false"
67+
awx_operator_files_path: roles/awx-deploy-operator/files
68+
awx_server_files_path: roles/awx-deploy-server/files
69+
awx_namespace: aap-awx
70+
71+
awx_operator:
72+
disableNameSuffixHash: true
73+
secretName: "redhat-operators-pull-secret"
74+
operatorLiteral: "operator=awx"
75+
awxOperatorConfigURL: "github.com/ansible/awx-operator/config/default?ref=2.10.0"
76+
operatorImageName: "quay.io/ansible/awx-operator"
77+
operatorImageTag: "2.10.0"
78+
79+
awx_server:
80+
pvc_name: awx-postgres-13-volume
81+
access_modes: ReadWriteOnce
82+
storage_request: 1000Mi
83+
admin_user: admin
84+
admin_password_secret: awx-admin-password
85+
86+
awx_server_kustomization:
87+
awx_database_configuration_host: awx-postgres-13
88+
awx_database_configuration_port: 5432
89+
awx_database_configuration_database: awx
90+
awx_database_configuration_username: awx
91+
awx_database_configuration_password: testpass
92+
awx_database_configuration_type: managed
93+
awx_admin_password: testpass
94+

automation/hosts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[all]
2+
localhost

automation/playbook.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
- hosts: localhost
2+
roles:
3+
4+
- name: eda-deploy-operator
5+
when: eda_deploy_operator == "true"
6+
7+
- name: eda-deploy-server
8+
when: eda_deploy_server == "true"
9+
10+
- name: awx-deploy-operator
11+
when: aws_deploy_operator == "true"
12+
13+
- name: awx-deploy-server
14+
when: aws_deploy_server == "true"

automation/roles/awx-deploy-operator/files/.gitkeep

Whitespace-only changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
- name: Check {{ env_type }} connection
3+
block:
4+
- k8s_info:
5+
api_version: v1
6+
kind: Pod
7+
namespace: default
8+
name: ansible-check-pod
9+
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
10+
register: k8s_info_result
11+
rescue:
12+
- fail:
13+
msg: "Failed to connect to Kubernetes cluster. Please check your configuration and try again."
14+
always:
15+
- debug:
16+
var: k8s_info_result
17+
18+
- name: Create {{ awx_namespace }} namespace
19+
k8s:
20+
definition:
21+
apiVersion: v1
22+
kind: Namespace
23+
metadata:
24+
name: "{{ awx_namespace }}"
25+
when: k8s_info_result is succeeded
26+
27+
- name: Generate AWX Operator kustomization file
28+
template:
29+
src: kustomization-awx-operator.yaml.j2
30+
dest: "{{ awx_operator_files_path }}/kustomization.yaml"
31+
32+
- name: Apply AWX Operator kustomization file
33+
k8s:
34+
definition: "{{ lookup('pipe', 'kustomize build {{ awx_operator_files_path }}') }}"
35+
state: present
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: {{ awx_namespace }}
4+
5+
generatorOptions:
6+
disableNameSuffixHash: {{ awx_operator.disableNameSuffixHash | default('false') }}
7+
8+
secretGenerator:
9+
- name: {{ awx_operator.secretName }}
10+
literals:
11+
- operator={{ awx_operator.operatorLiteral }}
12+
13+
resources:
14+
- {{ awx_operator.awxOperatorConfigURL }}
15+
16+
images:
17+
- name: {{ awx_operator.operatorImageName }}
18+
newTag: {{ awx_operator.operatorImageTag }}

automation/roles/awx-deploy-server/files/.gitkeep

Whitespace-only changes.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
- name: Check {{ env_type }} connection
3+
block:
4+
- k8s_info:
5+
api_version: v1
6+
kind: Pod
7+
namespace: default
8+
name: ansible-check-pod
9+
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
10+
register: k8s_info_result
11+
rescue:
12+
- fail:
13+
msg: "Failed to connect to Kubernetes cluster. Please check your configuration and try again."
14+
always:
15+
- debug:
16+
var: k8s_info_result
17+
18+
- name: Check if {{ awx_namespace }} namespace exists
19+
k8s_info:
20+
kind: Namespace
21+
name: "{{ awx_namespace }}"
22+
kubeconfig: "{{ lookup('env', 'KUBECONFIG') }}"
23+
register: namespace_info
24+
failed_when: namespace_info.resources|length == 0
25+
26+
- name: Define the AWX Host
27+
set_fact:
28+
awx_host: "{{ 'awx.local' if env_type == 'minikube' else 'awx-aap-awx.apps-crc.testing' }}"
29+
30+
- name: Generate private key
31+
command: "openssl genpkey -algorithm RSA -out tls.key"
32+
args:
33+
chdir: "{{ awx_server_files_path }}"
34+
35+
- name: Generate certificate signing request (CSR)
36+
command: "openssl req -new -key tls.key -out csr.pem -subj '/CN={{ awx_host }}/O={{ awx_host }}' -addext 'subjectAltName=DNS:{{ awx_host }}'"
37+
args:
38+
chdir: "{{ awx_server_files_path }}"
39+
40+
- name: Generate signed certificate
41+
command: "openssl x509 -req -in csr.pem -signkey tls.key -out tls.crt -days 365"
42+
args:
43+
chdir: "{{ awx_server_files_path }}"
44+
45+
- name: Remove temporary certificate signing request (CSR)
46+
file:
47+
path: "{{ awx_server_files_path }}/csr.pem"
48+
state: absent
49+
50+
- name: Define Ingress type
51+
set_fact:
52+
ingress_type: "{{ 'ingress' if env_type == 'minikube' else 'Route' }}"
53+
54+
- name: Define the TLS termination Mechanism
55+
set_fact:
56+
tls_termination_mechanism: "{{ '' if env_type == 'minikube' else 'Edge' }}"
57+
58+
- name: Define the PostgreSQL storage class
59+
set_fact:
60+
postgres_storage_class: "{{ 'standard' if env_type == 'minikube' else 'crc-csi-hostpath-provisioner' }}"
61+
62+
- name: Generate AWX Server pvc file
63+
template:
64+
src: awx-server-pvc.yaml.j2
65+
dest: "{{ awx_server_files_path }}/awx-server-pvc.yaml"
66+
67+
- name: Generate AWX Server file
68+
template:
69+
src: awx-server.yaml.j2
70+
dest: "{{ awx_server_files_path }}/awx-server.yaml"
71+
72+
- name: Generate AWX Server kustomization file
73+
template:
74+
src: awx-server-kustomization.yaml.j2
75+
dest: "{{ awx_server_files_path }}/kustomization.yaml"
76+
77+
- name: Apply AWX Server kustomization file
78+
k8s:
79+
definition: "{{ lookup('pipe', 'kustomize build {{ awx_server_files_path }}') }}"
80+
state: present
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
namespace: {{ awx_namespace }}
5+
6+
generatorOptions:
7+
disableNameSuffixHash: true
8+
9+
secretGenerator:
10+
- name: awx-secret-tls
11+
files:
12+
- tls.crt
13+
- tls.key
14+
15+
secretGenerator:
16+
- name: awx-database-configuration
17+
type: Opaque
18+
literals:
19+
- host={{ awx_server_kustomization.awx_database_configuration_host }}
20+
- port={{ awx_server_kustomization.awx_database_configuration_port }}
21+
- database={{ awx_server_kustomization.awx_database_configuration_database }}
22+
- username={{ awx_server_kustomization.awx_database_configuration_username }}
23+
- password={{ awx_server_kustomization.awx_database_configuration_password }}
24+
- type=managed
25+
26+
- name: awx-admin-password
27+
type: Opaque
28+
literals:
29+
- password={{ awx_server_kustomization.awx_admin_password }}
30+
31+
resources:
32+
- awx-server-pvc.yaml
33+
- awx-server.yaml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: {{ awx_server.pvc_name }}
5+
namespace: {{ awx_namespace }}
6+
spec:
7+
accessModes:
8+
- "{{ awx_server.access_modes }}"
9+
resources:
10+
requests:
11+
storage: {{ awx_server.storage_request }}
12+
status: {}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: awx.ansible.com/v1beta1
2+
kind: AWX
3+
metadata:
4+
name: awx
5+
spec:
6+
admin_user: {{ awx_server.admin_user }}
7+
admin_password_secret: {{ awx_server.admin_password_secret }}
8+
9+
route_tls_termination_mechanism: {{ tls_termination_mechanism }}
10+
ingress_tls_secret: awx-secret-tls
11+
ingress_type: {{ ingress_type }}
12+
hostname: {{ awx_host }}
13+
14+
postgres_configuration_secret: awx-postgres-configuration
15+
16+
postgres_storage_requirements:
17+
requests:
18+
storage: 500Mi
19+
20+
projects_persistence: true
21+
projects_existing_claim: awx-postgres-13-volume
22+
23+
web_replicas: 1
24+
task_replicas: 1
25+
26+
postgres_init_container_resource_requirements: {}
27+
postgres_resource_requirements: {}
28+
web_resource_requirements: {}
29+
task_resource_requirements: {}
30+
ee_resource_requirements: {}
31+
init_container_resource_requirements: {}
32+
33+
# Uncomment to reveal "censored" logs
34+
#no_log: false
35+

automation/roles/eda-deploy-operator/files/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)