-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
165 lines (139 loc) · 4.64 KB
/
playbook.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
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
160
161
162
163
164
165
- name: Setup Node
hosts: all
become: yes
tasks:
- name: Update packages
apt:
update_cache: yes
cache_valid_time: 3600
- name: Install required packages
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
- build-essential
- jq
- htop
state: present
- name: Add Docker repository key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker repository
ansible.builtin.apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
- name: Install Docker
apt:
name: docker-ce
state: present
update_cache: yes
- name: Add user to docker group
user:
name: "{{ ansible_user }}"
groups: docker
append: yes
- name: Check if NVM is installed
stat:
path: "{{ ansible_env.HOME }}/.nvm/nvm.sh"
register: nvm_installed
- name: Display nvm_installed
debug:
msg: "{{ nvm_installed }}"
- name: Install NVM
shell: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
args:
executable: /bin/bash
become: no
when: not nvm_installed.stat.exists
- name: Install Node.js 16 and update npm
shell: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 16.19.1
nvm use v16.19.1
npm i -g npm
args:
executable: /bin/bash
become: no
- name: Install Minikube
block:
- name: Install conntrack (required for Minikube)
apt:
name: conntrack
state: present
become: yes
- name: Download Minikube binary
get_url:
url: https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
dest: /tmp/minikube
mode: '0755'
- name: Install Minikube binary to /usr/local/bin
command: sudo install /tmp/minikube /usr/local/bin/
args:
removes: /tmp/minikube
become: yes
- name: Check if kubectl command is available
command: kubectl version --client
register: kubectl_check_result
ignore_errors: true
become: 'no'
- name: Set kubectl_available variable
set_fact:
kubectl_available: '{{ kubectl_check_result.rc == 0 }}'
- name: Display kubectl_available variable
debug:
var: kubectl_available
- name: Install kubectl
block:
- name: Get the latest stable kubectl version
command: curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt
register: stable_kubectl_version
become: no
- name: Download kubectl binary
get_url:
url: "https://storage.googleapis.com/kubernetes-release/release/{{ stable_kubectl_version.stdout }}/bin/linux/amd64/kubectl"
dest: /usr/local/bin/kubectl
mode: '0755'
become: yes
- name: Display kubectl version
debug:
msg: "{{ stable_kubectl_version.stdout }}"
- name: Download pachctl_1.12.5_amd64.deb
get_url:
url: https://github.com/pachyderm/pachyderm/releases/download/v1.12.5/pachctl_1.12.5_amd64.deb
dest: /tmp/pachctl_1.12.5_amd64.deb
mode: 0644
- name: Install pachctl
ansible.builtin.apt:
deb: /tmp/pachctl_1.12.5_amd64.deb
- name: Create Minikube service file
copy:
content: |
[Unit]
Description=Minikube
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
Environment="MINIKUBE_HOME=/home/{{ ansible_user }}"
ExecStart=/usr/local/bin/minikube start --wait=all --cpus=2 --memory=2GB
ExecStop=/usr/local/bin/minikube stop
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/minikube.service
owner: root
group: root
mode: 0644
- name: Reload systemd daemon
systemd:
daemon_reload: yes
- name: Enable and start Minikube service
systemd:
name: minikube.service
enabled: yes
state: started