Обновить ansible/deploy_awx_k8s.yml
This commit is contained in:
@@ -6,30 +6,21 @@
|
|||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
# Основные параметры — лучше переопределять в Semaphore Variable Group
|
# Простые fallback-значения (переопределяются Semaphore Variable Group)
|
||||||
awx_namespace: "{{ awx_namespace | default('awx') }}"
|
awx_namespace: awx
|
||||||
awx_instance_name: "{{ awx_instance_name | default('awx') }}"
|
awx_instance_name: awx
|
||||||
awx_service_type: "{{ awx_service_type | default('NodePort') }}" # NodePort / ClusterIP / LoadBalancer
|
awx_service_type: NodePort # NodePort / ClusterIP / LoadBalancer
|
||||||
awx_operator_version: "{{ awx_operator_version | default('2.19.1') }}" # 2.19.1 → AWX 24.6.x (последняя стабильная на конец 2025)
|
awx_operator_version: 2.19.1 # Последняя стабильная на конец 2025
|
||||||
|
|
||||||
# Путь к kubeconfig внутри контейнера Semaphore
|
|
||||||
kubeconfig_path: "/home/semaphore/.kube/config"
|
kubeconfig_path: "/home/semaphore/.kube/config"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Fail if kubeconfig not found
|
- name: Fail if kubeconfig not found inside container
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ kubeconfig_path }}"
|
path: "{{ kubeconfig_path }}"
|
||||||
register: kubeconfig_stat
|
register: kubeconfig_stat
|
||||||
failed_when: not kubeconfig_stat.stat.exists
|
failed_when: not kubeconfig_stat.stat.exists
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Install kubernetes python library (fallback)
|
|
||||||
ansible.builtin.pip:
|
|
||||||
name: kubernetes>=25.3.0
|
|
||||||
state: present
|
|
||||||
delegate_to: localhost
|
|
||||||
ignore_errors: true # если уже стоит через /etc/semaphore/requirements.txt
|
|
||||||
|
|
||||||
- name: Create namespace for AWX
|
- name: Create namespace for AWX
|
||||||
kubernetes.core.k8s:
|
kubernetes.core.k8s:
|
||||||
state: present
|
state: present
|
||||||
@@ -40,18 +31,17 @@
|
|||||||
metadata:
|
metadata:
|
||||||
name: "{{ awx_namespace }}"
|
name: "{{ awx_namespace }}"
|
||||||
|
|
||||||
- name: Apply AWX Operator (via kustomize from github)
|
- name: Apply AWX Operator from GitHub kustomize
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: >-
|
cmd: >-
|
||||||
kubectl apply -k "github.com/ansible/awx-operator/config/default?ref={{ awx_operator_version }}"
|
kubectl apply -k "github.com/ansible/awx-operator/config/default?ref={{ awx_operator_version }}"
|
||||||
creates: "{{ kubeconfig_path }}" # dummy — чтобы не повторять каждый раз
|
|
||||||
environment:
|
environment:
|
||||||
KUBECONFIG: "{{ kubeconfig_path }}"
|
KUBECONFIG: "{{ kubeconfig_path }}"
|
||||||
changed_when: true
|
changed_when: true
|
||||||
register: operator_apply
|
register: operator_apply
|
||||||
failed_when: operator_apply.rc != 0 and 'already exists' not in operator_apply.stderr
|
failed_when: operator_apply.rc != 0 and 'already exists' not in operator_apply.stderr | default('')
|
||||||
|
|
||||||
- name: Wait for AWX Operator deployment to be ready
|
- name: Wait for AWX Operator to be ready
|
||||||
kubernetes.core.k8s_info:
|
kubernetes.core.k8s_info:
|
||||||
kubeconfig: "{{ kubeconfig_path }}"
|
kubeconfig: "{{ kubeconfig_path }}"
|
||||||
api_version: apps/v1
|
api_version: apps/v1
|
||||||
@@ -60,8 +50,9 @@
|
|||||||
namespace: "{{ awx_namespace }}"
|
namespace: "{{ awx_namespace }}"
|
||||||
register: operator_status
|
register: operator_status
|
||||||
until: >-
|
until: >-
|
||||||
|
operator_status.resources | length > 0 and
|
||||||
operator_status.resources[0].status.readyReplicas is defined and
|
operator_status.resources[0].status.readyReplicas is defined and
|
||||||
operator_status.resources[0].status.readyReplicas == operator_status.resources[0].status.replicas
|
operator_status.resources[0].status.readyReplicas >= 1
|
||||||
retries: 40
|
retries: 40
|
||||||
delay: 15
|
delay: 15
|
||||||
|
|
||||||
@@ -77,51 +68,34 @@
|
|||||||
namespace: "{{ awx_namespace }}"
|
namespace: "{{ awx_namespace }}"
|
||||||
spec:
|
spec:
|
||||||
service_type: "{{ awx_service_type }}"
|
service_type: "{{ awx_service_type }}"
|
||||||
# Можно добавить/раскомментировать по необходимости:
|
|
||||||
# ingress_type: Ingress
|
|
||||||
# ingress_hostname: awx.your-domain.com
|
|
||||||
# ingress_class_name: nginx
|
|
||||||
# replicas: 1
|
|
||||||
# projects_persistence: true
|
|
||||||
# projects_storage_class: standard
|
|
||||||
# projects_storage_size: 10Gi
|
|
||||||
|
|
||||||
- name: Wait for AWX pods to become ready (up to ~10–15 minutes)
|
- name: Wait for AWX pods to be running
|
||||||
kubernetes.core.k8s_info:
|
kubernetes.core.k8s_info:
|
||||||
kubeconfig: "{{ kubeconfig_path }}"
|
kubeconfig: "{{ kubeconfig_path }}"
|
||||||
kind: Pod
|
kind: Pod
|
||||||
namespace: "{{ awx_namespace }}"
|
namespace: "{{ awx_namespace }}"
|
||||||
label_selectors:
|
label_selectors:
|
||||||
- "app.kubernetes.io/managed-by=awx-operator"
|
- "app.kubernetes.io/managed-by=awx-operator"
|
||||||
- "app.kubernetes.io/name={{ awx_instance_name }}"
|
|
||||||
register: awx_pods
|
register: awx_pods
|
||||||
until: >-
|
until: >-
|
||||||
awx_pods.resources | selectattr('status.phase', 'equalto', 'Running') | list | length >= 2 and
|
awx_pods.resources | selectattr('status.phase', 'equalto', 'Running') | list | length >= 2
|
||||||
(awx_pods.resources | selectattr('status.conditions', 'search', 'type: Ready, status: True') | list | length >= 2)
|
|
||||||
retries: 60
|
retries: 60
|
||||||
delay: 20
|
delay: 20
|
||||||
|
|
||||||
- name: Get AWX admin password from secret
|
- name: Retrieve AWX admin password
|
||||||
kubernetes.core.k8s_info:
|
kubernetes.core.k8s_info:
|
||||||
kubeconfig: "{{ kubeconfig_path }}"
|
kubeconfig: "{{ kubeconfig_path }}"
|
||||||
api_version: v1
|
api_version: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
name: "{{ awx_instance_name }}-admin-password"
|
name: "{{ awx_instance_name }}-admin-password"
|
||||||
namespace: "{{ awx_namespace }}"
|
namespace: "{{ awx_namespace }}"
|
||||||
register: awx_admin_secret
|
register: awx_secret
|
||||||
|
|
||||||
- name: Show AWX access information
|
- name: Display AWX login information
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: |
|
msg: |
|
||||||
AWX успешно развёрнут!
|
AWX deployed successfully!
|
||||||
Namespace: {{ awx_namespace }}
|
Access URL: http://<your-node-ip>:<node-port>
|
||||||
Instance name: {{ awx_instance_name }}
|
(get port: kubectl get svc {{ awx_instance_name }}-service -n {{ awx_namespace }})
|
||||||
Service type: {{ awx_service_type }}
|
Username: admin
|
||||||
|
Password: {{ awx_secret.resources[0].data.password | b64decode }}
|
||||||
Получите NodePort для доступа:
|
|
||||||
kubectl get svc {{ awx_instance_name }}-service -n {{ awx_namespace }}
|
|
||||||
|
|
||||||
Логин: admin
|
|
||||||
Пароль: {{ awx_admin_secret.resources[0].data.password | b64decode }}
|
|
||||||
|
|
||||||
Если используете Ingress — настройте его отдельно в spec AWX ресурса.
|
|
||||||
Reference in New Issue
Block a user