mirror of
https://github.com/ansible/awx-operator.git
synced 2026-05-08 06:12:54 +00:00
Merge pull request #113 from shanemcd/refactor-templates
Refactor templates
This commit is contained in:
@@ -22,11 +22,16 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- tower_config.yaml.j2
|
- tower_config.yaml.j2
|
||||||
|
|
||||||
- name: Apply Resource Deployment Configuration
|
- name: Apply Resources
|
||||||
k8s:
|
k8s:
|
||||||
apply: yes
|
apply: yes
|
||||||
definition: "{{ lookup('template', 'tower.yaml.j2') }}"
|
definition: "{{ lookup('template', item + '.yaml.j2') }}"
|
||||||
register: tower_deployment_result
|
register: tower_deployment_result
|
||||||
|
loop:
|
||||||
|
- 'tower_app_credentials'
|
||||||
|
- 'tower_deployment'
|
||||||
|
- 'tower_service'
|
||||||
|
- 'tower_ingress'
|
||||||
|
|
||||||
- name: Get the resource pod information.
|
- name: Get the resource pod information.
|
||||||
k8s_info:
|
k8s_info:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
- name: Create secret key secret
|
- name: Create secret key secret
|
||||||
k8s:
|
k8s:
|
||||||
apply: true
|
apply: true
|
||||||
definition: "{{ lookup('template', 'tower_secret.yaml.j2') }}"
|
definition: "{{ lookup('template', 'tower_secret_key.yaml.j2') }}"
|
||||||
|
|
||||||
- name: Read secret key secret
|
- name: Read secret key secret
|
||||||
k8s_info:
|
k8s_info:
|
||||||
|
|||||||
10
roles/installer/templates/tower_app_credentials.yaml.j2
Normal file
10
roles/installer/templates/tower_app_credentials.yaml.j2
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# AWX Secret Configurations
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: '{{ meta.name }}-app-credentials'
|
||||||
|
namespace: '{{ meta.namespace }}'
|
||||||
|
data:
|
||||||
|
credentials_py: "{{ lookup('template', 'credentials.py.j2') | b64encode }}"
|
||||||
|
environment_sh: "{{ lookup('template', 'environment.sh.j2') | b64encode }}"
|
||||||
@@ -1,14 +1,3 @@
|
|||||||
# AWX Secret Configurations
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: '{{ meta.name }}-secrets'
|
|
||||||
namespace: '{{ meta.namespace }}'
|
|
||||||
data:
|
|
||||||
credentials_py: "{{ lookup('template', 'credentials.py.j2') | b64encode }}"
|
|
||||||
environment_sh: "{{ lookup('template', 'environment.sh.j2') | b64encode }}"
|
|
||||||
|
|
||||||
# AWX Deployment.
|
# AWX Deployment.
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
@@ -174,7 +163,7 @@ spec:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
- name: "{{ meta.name }}-application-credentials"
|
- name: "{{ meta.name }}-application-credentials"
|
||||||
secret:
|
secret:
|
||||||
secretName: "{{ meta.name }}-secrets"
|
secretName: "{{ meta.name }}-app-credentials"
|
||||||
items:
|
items:
|
||||||
- key: credentials_py
|
- key: credentials_py
|
||||||
path: 'credentials.py'
|
path: 'credentials.py'
|
||||||
@@ -220,92 +209,3 @@ spec:
|
|||||||
{% if tower_extra_volumes -%}
|
{% if tower_extra_volumes -%}
|
||||||
{{ tower_extra_volumes | indent(width=8, indentfirst=True) }}
|
{{ tower_extra_volumes | indent(width=8, indentfirst=True) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# AWX Service.
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: '{{ meta.name }}-service'
|
|
||||||
namespace: '{{ meta.namespace }}'
|
|
||||||
labels:
|
|
||||||
app: '{{ deployment_type }}'
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 80
|
|
||||||
protocol: TCP
|
|
||||||
targetPort: 8052
|
|
||||||
name: http
|
|
||||||
{% if tower_ingress_type | lower == 'route' and tower_route_tls_termination_mechanism | lower == 'passthrough' %}
|
|
||||||
- port: 443
|
|
||||||
protocol: TCP
|
|
||||||
targetPort: 8053
|
|
||||||
name: https
|
|
||||||
{% endif %}
|
|
||||||
selector:
|
|
||||||
app: '{{ deployment_type }}'
|
|
||||||
{% if tower_ingress_type != "none" %}
|
|
||||||
type: NodePort
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# AWX Ingress.
|
|
||||||
{% if 'ingress' == tower_ingress_type|lower %}
|
|
||||||
---
|
|
||||||
apiVersion: extensions/v1beta1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
name: '{{ meta.name }}-ingress'
|
|
||||||
namespace: '{{ meta.namespace }}'
|
|
||||||
{% if tower_ingress_annotations %}
|
|
||||||
annotations:
|
|
||||||
{{ tower_ingress_annotations | indent(width=4) }}
|
|
||||||
{% endif %}
|
|
||||||
spec:
|
|
||||||
rules:
|
|
||||||
- host: '{{ tower_hostname }}'
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- path: /
|
|
||||||
backend:
|
|
||||||
serviceName: '{{ meta.name }}-service'
|
|
||||||
servicePort: 80
|
|
||||||
{% if tower_ingress_tls_secret %}
|
|
||||||
tls:
|
|
||||||
- hosts:
|
|
||||||
- {{ tower_hostname }}
|
|
||||||
secretName: {{ tower_ingress_tls_secret }}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if 'route' == tower_ingress_type|lower %}
|
|
||||||
---
|
|
||||||
apiVersion: route.openshift.io/v1
|
|
||||||
kind: Route
|
|
||||||
metadata:
|
|
||||||
name: '{{ meta.name }}'
|
|
||||||
namespace: '{{ meta.namespace }}'
|
|
||||||
spec:
|
|
||||||
{% if tower_route_host != '' %}
|
|
||||||
host: {{ tower_route_host }}
|
|
||||||
{% endif %}
|
|
||||||
port:
|
|
||||||
targetPort: '{{ (tower_route_tls_termination_mechanism | lower == "passthrough") | ternary("https", "http") }}'
|
|
||||||
tls:
|
|
||||||
insecureEdgeTerminationPolicy: Redirect
|
|
||||||
termination: {{ tower_route_tls_termination_mechanism | lower }}
|
|
||||||
{% if tower_route_tls_termination_mechanism | lower == 'edge' and tower_route_tls_secret != '' %}
|
|
||||||
key: |-
|
|
||||||
{{ tower_route_tls_key | indent(width=6, indentfirst=True) }}
|
|
||||||
certificate: |-
|
|
||||||
{{ tower_route_tls_crt | indent(width=6, indentfirst=True) }}
|
|
||||||
{% if tower_route_ca_crt is defined %}
|
|
||||||
caCertificate: |-
|
|
||||||
{{ tower_route_ca_crt | indent(width=6, indentfirst=True) }}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
to:
|
|
||||||
kind: Service
|
|
||||||
name: {{ meta.name }}-service
|
|
||||||
weight: 100
|
|
||||||
wildcardPolicy: None
|
|
||||||
{% endif %}
|
|
||||||
60
roles/installer/templates/tower_ingress.yaml.j2
Normal file
60
roles/installer/templates/tower_ingress.yaml.j2
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{% if 'ingress' == tower_ingress_type|lower %}
|
||||||
|
---
|
||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: '{{ meta.name }}-ingress'
|
||||||
|
namespace: '{{ meta.namespace }}'
|
||||||
|
{% if tower_ingress_annotations %}
|
||||||
|
annotations:
|
||||||
|
{{ tower_ingress_annotations | indent(width=4) }}
|
||||||
|
{% endif %}
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- host: '{{ tower_hostname }}'
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
backend:
|
||||||
|
serviceName: '{{ meta.name }}-service'
|
||||||
|
servicePort: 80
|
||||||
|
{% if tower_ingress_tls_secret %}
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- {{ tower_hostname }}
|
||||||
|
secretName: {{ tower_ingress_tls_secret }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if 'route' == tower_ingress_type|lower %}
|
||||||
|
---
|
||||||
|
apiVersion: route.openshift.io/v1
|
||||||
|
kind: Route
|
||||||
|
metadata:
|
||||||
|
name: '{{ meta.name }}'
|
||||||
|
namespace: '{{ meta.namespace }}'
|
||||||
|
spec:
|
||||||
|
{% if tower_route_host != '' %}
|
||||||
|
host: {{ tower_route_host }}
|
||||||
|
{% endif %}
|
||||||
|
port:
|
||||||
|
targetPort: '{{ (tower_route_tls_termination_mechanism | lower == "passthrough") | ternary("https", "http") }}'
|
||||||
|
tls:
|
||||||
|
insecureEdgeTerminationPolicy: Redirect
|
||||||
|
termination: {{ tower_route_tls_termination_mechanism | lower }}
|
||||||
|
{% if tower_route_tls_termination_mechanism | lower == 'edge' and tower_route_tls_secret != '' %}
|
||||||
|
key: |-
|
||||||
|
{{ tower_route_tls_key | indent(width=6, indentfirst=True) }}
|
||||||
|
certificate: |-
|
||||||
|
{{ tower_route_tls_crt | indent(width=6, indentfirst=True) }}
|
||||||
|
{% if tower_route_ca_crt is defined %}
|
||||||
|
caCertificate: |-
|
||||||
|
{{ tower_route_ca_crt | indent(width=6, indentfirst=True) }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
to:
|
||||||
|
kind: Service
|
||||||
|
name: {{ meta.name }}-service
|
||||||
|
weight: 100
|
||||||
|
wildcardPolicy: None
|
||||||
|
{% endif %}
|
||||||
25
roles/installer/templates/tower_service.yaml.j2
Normal file
25
roles/installer/templates/tower_service.yaml.j2
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: '{{ meta.name }}-service'
|
||||||
|
namespace: '{{ meta.namespace }}'
|
||||||
|
labels:
|
||||||
|
app: '{{ deployment_type }}'
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 8052
|
||||||
|
name: http
|
||||||
|
{% if tower_ingress_type | lower == 'route' and tower_route_tls_termination_mechanism | lower == 'passthrough' %}
|
||||||
|
- port: 443
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 8053
|
||||||
|
name: https
|
||||||
|
{% endif %}
|
||||||
|
selector:
|
||||||
|
app: '{{ deployment_type }}'
|
||||||
|
{% if tower_ingress_type != "none" %}
|
||||||
|
type: NodePort
|
||||||
|
{% endif %}
|
||||||
Reference in New Issue
Block a user