-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathawx-install-fixed-projects.yml
103 lines (95 loc) · 3.17 KB
/
awx-install-fixed-projects.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
- name: Install AWX
hosts: localhost
become: yes
vars:
awx_namespace: awx
project_directory: /var/lib/awx/projects
storage_size: 2Gi
tasks:
- name: Download Kustomize with curl
ansible.builtin.shell:
cmd: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
creates: /usr/local/bin/kustomize
- name: Move Kustomize to the /usr/local/bin directory
ansible.builtin.shell:
cmd: mv kustomize /usr/local/bin
args:
creates: /usr/local/bin/kustomize
- name: Ensure namespace {{ awx_namespace }} exists
ansible.builtin.shell:
cmd: kubectl create namespace {{ awx_namespace }} --dry-run=client -o yaml | kubectl apply -f -
- name: Generate AWX resource file
ansible.builtin.copy:
dest: "./awx.yaml"
content: |
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
name: awx
spec:
service_type: nodeport
nodeport_port: 30060
projects_persistence: true
projects_existing_claim: awx-projects-claim
- name: Fetch latest release tag of AWX Operator
ansible.builtin.shell:
cmd: curl -s https://api.github.com/repos/ansible/awx-operator/releases/latest | grep tag_name | cut -d '"' -f 4
register: release_tag
changed_when: false
- name: Generate PV and PVC resource files
ansible.builtin.copy:
dest: "{{ item.dest }}"
content: "{{ item.content }}"
loop:
- dest: "./pv.yml"
content: |
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: awx-projects-volume
spec:
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
capacity:
storage: {{ storage_size }}
storageClassName: awx-projects-volume
hostPath:
path: {{ project_directory }}
- dest: "./pvc.yml"
content: |
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: awx-projects-claim
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: {{ storage_size }}
storageClassName: awx-projects-volume
- name: Create kustomization.yaml
ansible.builtin.copy:
dest: "./kustomization.yaml"
content: |
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/ansible/awx-operator/config/default?ref={{ release_tag.stdout }}
- pv.yml
- pvc.yml
- awx.yaml
images:
- name: quay.io/ansible/awx-operator
newTag: {{ release_tag.stdout }}
namespace: {{ awx_namespace }}
- name: Apply Kustomize configuration
ansible.builtin.shell:
cmd: kustomize build . | kubectl apply -f -