You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hetzner-ansible/roles/awx/tasks/main.yml

135 lines
3.1 KiB
YAML

---
- name: "Install pip3 for {{ service_name }}"
apt:
name: python3-pip
state: present
become: True
tags:
- kube_apply
- name: "Install kubernetes over pip3 for {{ service_name }}"
pip:
name: kubernetes
state: present
become: True
tags:
- kube_apply
- name: "Install and setup kubernetes (single node, master-only cluster) for {{ service_name }}"
include_role:
name: geerlingguy.kubernetes
vars:
kubernetes_allow_pods_on_master: true
tags:
- kube_install
- name: "Download awx {{ awx_operator_version }} to kubernetes template for {{ service_name }}"
get_url:
url: "{{ awx_operator_url }}"
dest: /tmp/awx-operator.yaml
mode: '0664'
tags:
- kube_apply
- name: "Apply awx {{ awx_operator_version }} to kubernetes {{ service_name }}"
k8s:
state: present
src: /tmp/awx-operator.yaml
namespace: default
wait: yes
wait_timeout: 300
tags:
- kube_apply
- name: "Ensure that postgres volume directory exists for {{ service_name }}"
file:
path: "{{ item }}"
state: directory
owner: 'root'
group: 'root'
loop:
- "{{ kubernetes_awx_postgres_volume_path }}"
- "{{ kubernetes_awx_project_volume_path }}"
tags:
- kube_apply
- name: "Copy deployment template for {{ service_name }}"
template:
src: awx-deployment.yml.j2
dest: /tmp/awx-deployment.yml
owner: root
group: root
mode: '0644'
tags:
- kube_apply
- name: "Create a awx k8s namespace for {{ service_name }}"
k8s:
name: "{{ kubernetes_awx_namespace }}"
api_version: v1
kind: Namespace
state: present
tags:
- kube_apply
- name: "Apply awx deployment for {{ service_name }}"
k8s:
state: present
src: /tmp/awx-deployment.yml
namespace: "{{ kubernetes_awx_namespace }}"
wait: yes
wait_timeout: 300
tags:
- kube_apply
- name: "Cleanup for {{ service_name }}"
file:
path: "{{ item }}"
state: absent
loop:
- /tmp/awx-operator.yaml
- /tmp/awx-deployment.yml
tags:
- kube_apply
- name: "Wait for awx service {{ service_name }}"
uri:
url: "http://{{ stage_server_ip }}:{{ kubernetes_awx_service_port }}"
status_code: 200
validate_certs: False
register: result
until: result.status == 200
retries: 60
delay: 20
tags:
- kube_apply
- name: "Search for all pods labeled app.kubernetes.io/name=awx {{ service_name }}"
k8s_info:
kind: Pod
namespace: "{{ kubernetes_awx_namespace }}"
label_selectors:
- app.kubernetes.io/name=awx
register: pod_list
tags:
- kube_apply
- name: "Wait for awx-task db-migration {{ service_name }}"
kubernetes.core.k8s_exec:
namespace: "{{ kubernetes_awx_namespace }}"
pod: "{{ pod_list.resources[0].metadata.name }}"
container: awx-task
command: /usr/local/bin/wait-for-migrations
tags:
- kube_apply
- include_tasks: awx-configurator.yml
vars:
awx_base_url: "http://{{ stage_server_ip }}"
awx_rest_api_access_user: "admin"
awx_rest_api_access_pw: "{{ awx_admin_password }}"
awx_project_path: "{{ kubernetes_awx_project_volume_path }}"
tags:
- awx_communication