-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathawx_on_kind.yaml
159 lines (128 loc) · 5.51 KB
/
awx_on_kind.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
- name: Install and configure AWX on KIND
hosts: localhost
become: yes
tasks:
- debug:
msg: "{{ansible_facts['distribution']}}"
- name: Upgrade all OS packages (Ubuntu and Debian)
apt:
name: "*"
state: latest
autoremove: yes
autoclean: yes
when: ansible_facts['distribution'] == "Ubuntu" or ansible_facts['distribution'] == "Debian"
- name: Install curl (Ubuntu and Debian)
apt:
name: curl
state: latest
when: ansible_facts['distribution'] == "Ubuntu" or ansible_facts['distribution'] == "Debian"
- name: Upgrade all OS packages (Fedora and RHEL)
become: yes
dnf:
name: "*"
state: latest
when: ansible_facts['distribution'] == "Fedora" or ansible_facts['distribution'] == "RHEL"
- name: Install curl (Fedora and RHEL)
dnf:
name: curl
state: latest
when: ansible_facts['distribution'] == "Fedora" or ansible_facts['distribution'] == "RHEL"
- name: Upgrade all OS packages (CentOS)
become: yes
yum:
name: "*"
state: latest
when: ansible_facts['distribution'] == "CentOS"
- name: Install curl and git (CentOS)
yum:
name:
- curl
- git
state: latest
when: ansible_facts['distribution'] == "CentOS"
- name: Get Docker install script and install it
shell: "curl -fsSL https://get.docker.com -o get-docker.sh && chmod +x get-docker.sh && sh get-docker.sh && rm -rf get-docker.sh"
- name: Start docker service (Ubuntu and Debian)
service:
name: docker
enabled: true
state: started
when: ansible_facts['distribution'] == "Ubuntu" or ansible_facts['distribution'] == "Debian"
- name: Start docker service (Fedora and RHEL and CentOS)
systemd:
name: docker
enabled: true
state: started
when: ansible_facts['distribution'] == "Fedora" or ansible_facts['distribution'] == "RHEL" or ansible_facts['distribution'] == "CentOS"
- name: Download kubectl
shell: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- name: Install kubectl (Debian | Ubuntu | Fedora | RHEL)
become: yes
shell: "install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && rm -rf kubectl"
when: ansible_facts['distribution'] == "Ubuntu" or ansible_facts['distribution'] == "Debian" or
ansible_facts['distribution'] == "Fedora" or ansible_facts['distribution'] == "RHEL"
- name: Install kubectl (CentOS)
become: yes
shell: "install -o root -g root -m 0755 kubectl /usr/bin/kubectl && rm -rf kubectl"
when: ansible_facts['distribution'] == "CentOS"
- name: Download KIND
shell: curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64
- name: Install KIND (Debian | Ubuntu | Fedora | RHEL)
become: yes
shell: "chmod +x ./kind && mv ./kind /usr/local/bin/kind"
when: ansible_facts['distribution'] == "Ubuntu" or ansible_facts['distribution'] == "Debian" or
ansible_facts['distribution'] == "Fedora" or ansible_facts['distribution'] == "RHEL"
- name: Install KIND (CentOS)
become: yes
shell: "chmod +x ./kind && mv ./kind /usr/bin/kind"
when: ansible_facts['distribution'] == "CentOS"
- name: Create HA KIND Cluster (3 workers)
shell: "sudo kind create cluster --config=kind_cluster.yaml"
- name: Download Kustomize
shell: "curl -s 'https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh' | bash"
- name: Install Kustomize (Debian | Ubuntu | Fedora | RHEL)
become: yes
shell: "mv kustomize /usr/local/bin"
when: ansible_facts['distribution'] == "Ubuntu" or ansible_facts['distribution'] == "Debian" or
ansible_facts['distribution'] == "Fedora" or ansible_facts['distribution'] == "RHEL"
- name: Install Kustomize (CentOS)
become: yes
shell: "mv kustomize /usr/bin"
when: ansible_facts['distribution'] == "CentOS"
- name: Apply the awx-operator to the cluster
shell: "kustomize build . | sudo kubectl apply -f -"
- name: Wait for the awx-operator to become available
shell: "sudo kubectl wait deployment awx-operator-controller-manager -n awx --for condition=Available=True --timeout=300s"
- name: Add the awx.yml to kustomization.yaml file
copy:
src: kustomization_with_awx.yaml
dest: kustomization.yaml
- name: Apply the awx-kind deployment to the cluster
shell: "kustomize build . | sudo kubectl apply -f -"
- name: Wait 5 minutes
pause:
minutes: 5
- name: Wait to the awx resource to be up and running
shell: "sudo kubectl wait deployment -n awx awx-kind --for condition=Available=True --timeout=300s"
- name: Expose the cluster loadbalancer port
shell: "sudo kubectl expose deployment -n awx awx-kind --type=LoadBalancer --port=30080"
- name: Wait 5 minutes
pause:
minutes: 5
- name: Wait until expose loadbalancer is working
uri:
url: "http://{{ansible_default_ipv4.address}}:30080"
validate_certs: no
follow_redirects: none
method: GET
register: expose_loadbalancer
until: "{{expose_loadbalancer.status}} == 200"
retries: 30
delay: 10
- name: Get the AWX Web UI password
shell: 'sudo kubectl get secret -n awx awx-kind-admin-password -o jsonpath="{.data.password}" | base64 --decode'
register: awx_pass
- name: Instruction to access the AWX Web UI
debug:
msg: "Access http://{{ansible_default_ipv4.address}}:30080 with the username: admin and the password: {{awx_pass.stdout}}"