Spaces:
No application file
No application file
Jacob Molnia
commited on
Commit
•
53b59a6
1
Parent(s):
4d91c6c
intermidate setup5/maybe done
Browse files- deployment/02_deploy_to_controller/playbooks/app_server_setup.yml +33 -0
- deployment/02_deploy_to_controller/playbooks/connection_check_setup.yml +47 -0
- deployment/02_deploy_to_controller/playbooks/git_setup.yml +32 -0
- deployment/02_deploy_to_controller/playbooks/initial_setup.yml +30 -0
- deployment/02_deploy_to_controller/playbooks/main.yml +9 -225
- deployment/02_deploy_to_controller/playbooks/ssh_setup.yml +56 -0
- deployment/02_deploy_to_controller/playbooks/system_setup.yml +19 -0
- deployment/02_deploy_to_controller/playbooks/tailscale_setup.yml +45 -0
- deployment/02_deploy_to_controller/templates/connection_check.service.j2 +10 -0
- deployment/02_deploy_to_controller/templates/connection_check.sh.j2 +26 -0
- deployment/02_deploy_to_controller/templates/connection_check.timer.j2 +9 -0
- deployment/02_deploy_to_controller/vars/secrets.yml +61 -61
deployment/02_deploy_to_controller/playbooks/app_server_setup.yml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
- name: App Server Setup
|
3 |
+
hosts: all
|
4 |
+
become: yes
|
5 |
+
vars:
|
6 |
+
repo_dest: '/opt/CS_553'
|
7 |
+
tasks:
|
8 |
+
- name: Ensure .ansible directory exists
|
9 |
+
file:
|
10 |
+
path: /home/ubuntu/.ansible
|
11 |
+
state: directory
|
12 |
+
owner: ubuntu
|
13 |
+
group: ubuntu
|
14 |
+
mode: '0700'
|
15 |
+
|
16 |
+
- name: Copy vault password file from local machine
|
17 |
+
copy:
|
18 |
+
src: ../../.secrets/password.txt
|
19 |
+
dest: /home/ubuntu/.ansible/vault_password.txt
|
20 |
+
owner: ubuntu
|
21 |
+
group: ubuntu
|
22 |
+
mode: '0600'
|
23 |
+
|
24 |
+
- name: Run Ansible playbook for app server setup
|
25 |
+
command: >
|
26 |
+
ansible-playbook -i inventory/hosts.ini
|
27 |
+
playbooks/main.yml
|
28 |
+
--vault-password-file /home/ubuntu/.ansible/vault_password.txt
|
29 |
+
args:
|
30 |
+
chdir: "{{ repo_dest }}/deployment/01_deploy_to_app"
|
31 |
+
become_user: ubuntu
|
32 |
+
environment:
|
33 |
+
ANSIBLE_CONFIG: "{{ repo_dest }}/deployment/01_deploy_to_app/ansible.cfg"
|
deployment/02_deploy_to_controller/playbooks/connection_check_setup.yml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
- name: Connection Check Setup
|
3 |
+
hosts: all
|
4 |
+
become: yes
|
5 |
+
vars:
|
6 |
+
repo_dest: '/opt/CS_553'
|
7 |
+
vars_files:
|
8 |
+
- vars/secrets.yml
|
9 |
+
tasks:
|
10 |
+
- name: Create connection check script
|
11 |
+
template:
|
12 |
+
src: templates/connection_check.sh.j2
|
13 |
+
dest: "{{ repo_dest }}/deployment/02_deploy_to_controller/scripts/connection_check.sh"
|
14 |
+
owner: ubuntu
|
15 |
+
group: ubuntu
|
16 |
+
mode: '0755'
|
17 |
+
|
18 |
+
- name: Create systemd service file for connection check
|
19 |
+
template:
|
20 |
+
src: templates/connection_check.service.j2
|
21 |
+
dest: /etc/systemd/system/connection_check.service
|
22 |
+
owner: root
|
23 |
+
group: root
|
24 |
+
mode: '0644'
|
25 |
+
|
26 |
+
- name: Store Tailscale key in a file
|
27 |
+
copy:
|
28 |
+
content: "{{ tailscale_authkey }}"
|
29 |
+
dest: /home/ubuntu/.tailscale_key
|
30 |
+
owner: ubuntu
|
31 |
+
group: ubuntu
|
32 |
+
mode: '0600'
|
33 |
+
|
34 |
+
- name: Create connection check timer file
|
35 |
+
template:
|
36 |
+
src: templates/connection_check.timer.j2
|
37 |
+
dest: /etc/systemd/system/connection_check.timer
|
38 |
+
owner: root
|
39 |
+
group: root
|
40 |
+
mode: '0644'
|
41 |
+
|
42 |
+
- name: Start and enable connection check timer
|
43 |
+
systemd:
|
44 |
+
name: connection_check.timer
|
45 |
+
state: started
|
46 |
+
enabled: yes
|
47 |
+
daemon_reload: yes
|
deployment/02_deploy_to_controller/playbooks/git_setup.yml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
- name: Git Repository Setup
|
3 |
+
hosts: all
|
4 |
+
become: yes
|
5 |
+
vars:
|
6 |
+
repo_url: 'https://github.com/jake-molnia/CS_553'
|
7 |
+
repo_dest: '/opt/CS_553'
|
8 |
+
tasks:
|
9 |
+
- name: Check if repository exists
|
10 |
+
stat:
|
11 |
+
path: "{{ repo_dest }}"
|
12 |
+
register: repo_check
|
13 |
+
|
14 |
+
- name: Remove existing repository if it exists
|
15 |
+
file:
|
16 |
+
path: "{{ repo_dest }}"
|
17 |
+
state: absent
|
18 |
+
when: repo_check.stat.exists
|
19 |
+
|
20 |
+
- name: Clone the Git repository
|
21 |
+
git:
|
22 |
+
repo: "{{ repo_url }}"
|
23 |
+
dest: "{{ repo_dest }}"
|
24 |
+
version: main
|
25 |
+
|
26 |
+
- name: Set permissions for the cloned repository
|
27 |
+
file:
|
28 |
+
path: "{{ repo_dest }}"
|
29 |
+
owner: ubuntu
|
30 |
+
group: ubuntu
|
31 |
+
mode: '0755'
|
32 |
+
recurse: yes
|
deployment/02_deploy_to_controller/playbooks/initial_setup.yml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
- name: Initial Setup
|
3 |
+
hosts: all
|
4 |
+
become: yes
|
5 |
+
vars_files:
|
6 |
+
- vars/secrets.yml
|
7 |
+
vars:
|
8 |
+
repo_dest: '/opt/CS_553'
|
9 |
+
tasks:
|
10 |
+
- name: Check if initial setup flag file exists
|
11 |
+
stat:
|
12 |
+
path: /home/ubuntu/.initial_setup_complete
|
13 |
+
register: setup_flag
|
14 |
+
|
15 |
+
- name: Run initial setup shell script with Tailscale key
|
16 |
+
command: >
|
17 |
+
{{ repo_dest }}/deployment/02_deploy_to_controller/scripts/initial_ssh_config.sh -k {{ tailscale_authkey }}
|
18 |
+
args:
|
19 |
+
chdir: "{{ repo_dest }}/deployment/02_deploy_to_controller"
|
20 |
+
become_user: ubuntu
|
21 |
+
when: not setup_flag.stat.exists
|
22 |
+
|
23 |
+
- name: Create initial setup flag file
|
24 |
+
file:
|
25 |
+
path: /home/ubuntu/.initial_setup_complete
|
26 |
+
state: touch
|
27 |
+
owner: ubuntu
|
28 |
+
group: ubuntu
|
29 |
+
mode: '0644'
|
30 |
+
when: not setup_flag.stat.exists
|
deployment/02_deploy_to_controller/playbooks/main.yml
CHANGED
@@ -3,228 +3,12 @@
|
|
3 |
hosts: all
|
4 |
become: yes
|
5 |
vars_files:
|
6 |
-
- ../vars/secrets.yml
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
become: yes
|
16 |
-
|
17 |
-
- name: Install required packages
|
18 |
-
apt:
|
19 |
-
name:
|
20 |
-
- apt-transport-https
|
21 |
-
- ca-certificates
|
22 |
-
- curl
|
23 |
-
- gnupg
|
24 |
-
- git
|
25 |
-
- ansible
|
26 |
-
state: present
|
27 |
-
become: yes
|
28 |
-
|
29 |
-
- name: Check if Tailscale GPG key exists
|
30 |
-
stat:
|
31 |
-
path: /usr/share/keyrings/tailscale-archive-keyring.gpg
|
32 |
-
register: tailscale_key
|
33 |
-
|
34 |
-
- name: Download Tailscale GPG key
|
35 |
-
get_url:
|
36 |
-
url: https://pkgs.tailscale.com/stable/ubuntu/jammy.noarmor.gpg
|
37 |
-
dest: /usr/share/keyrings/tailscale-archive-keyring.gpg
|
38 |
-
mode: '0644'
|
39 |
-
become: yes
|
40 |
-
when: not tailscale_key.stat.exists
|
41 |
-
|
42 |
-
- name: Add Tailscale repository
|
43 |
-
ansible.builtin.apt_repository:
|
44 |
-
repo: deb [signed-by=/usr/share/keyrings/tailscale-archive-keyring.gpg] https://pkgs.tailscale.com/stable/ubuntu jammy main
|
45 |
-
state: present
|
46 |
-
filename: tailscale
|
47 |
-
become: yes
|
48 |
-
|
49 |
-
- name: Update apt cache again
|
50 |
-
apt:
|
51 |
-
update_cache: yes
|
52 |
-
become: yes
|
53 |
-
|
54 |
-
- name: Install Tailscale
|
55 |
-
apt:
|
56 |
-
name: tailscale
|
57 |
-
state: present
|
58 |
-
become: yes
|
59 |
-
|
60 |
-
- name: Check Tailscale status
|
61 |
-
command: tailscale status
|
62 |
-
register: tailscale_status
|
63 |
-
changed_when: false
|
64 |
-
ignore_errors: yes
|
65 |
-
|
66 |
-
- name: Run tailscale up with pre-authentication
|
67 |
-
command: tailscale up --authkey={{ tailscale_authkey }}
|
68 |
-
register: tailscale_result
|
69 |
-
changed_when: "'Success' in tailscale_result.stdout"
|
70 |
-
become: yes
|
71 |
-
when: tailscale_status.rc != 0 or 'Tailscale is stopped' in tailscale_status.stdout
|
72 |
-
|
73 |
-
- name: Check if repository exists
|
74 |
-
stat:
|
75 |
-
path: /opt/CS_553
|
76 |
-
register: repo_check
|
77 |
-
|
78 |
-
- name: Remove existing repository if it exists
|
79 |
-
file:
|
80 |
-
path: /opt/CS_553
|
81 |
-
state: absent
|
82 |
-
become: yes
|
83 |
-
when: repo_check.stat.exists
|
84 |
-
|
85 |
-
- name: Clone the Git repository
|
86 |
-
git:
|
87 |
-
repo: 'https://github.com/jake-molnia/CS_553'
|
88 |
-
dest: /opt/CS_553
|
89 |
-
version: main
|
90 |
-
become: yes
|
91 |
-
|
92 |
-
- name: Set permissions for the cloned repository
|
93 |
-
file:
|
94 |
-
path: /opt/CS_553
|
95 |
-
owner: ubuntu
|
96 |
-
group: ubuntu
|
97 |
-
mode: '0755'
|
98 |
-
recurse: yes
|
99 |
-
become: yes
|
100 |
-
|
101 |
-
- name: Ensure .ssh directory exists
|
102 |
-
file:
|
103 |
-
path: /home/ubuntu/.ssh
|
104 |
-
state: directory
|
105 |
-
owner: ubuntu
|
106 |
-
group: ubuntu
|
107 |
-
mode: '0700'
|
108 |
-
become: yes
|
109 |
-
|
110 |
-
- name: Copy student-admin private key
|
111 |
-
copy:
|
112 |
-
content: "{{ student_admin_private_key }}"
|
113 |
-
dest: /home/ubuntu/.ssh/student-admin-key
|
114 |
-
owner: ubuntu
|
115 |
-
group: ubuntu
|
116 |
-
mode: '0600'
|
117 |
-
become: yes
|
118 |
-
|
119 |
-
- name: Copy student-admin public key
|
120 |
-
copy:
|
121 |
-
content: "{{ student_admin_public_key }}"
|
122 |
-
dest: /home/ubuntu/.ssh/student-admin-key.pub
|
123 |
-
owner: ubuntu
|
124 |
-
group: ubuntu
|
125 |
-
mode: '0644'
|
126 |
-
become: yes
|
127 |
-
|
128 |
-
- name: Write ED25519 public key
|
129 |
-
copy:
|
130 |
-
content: "{{ ed25519_public_key }}"
|
131 |
-
dest: /home/ubuntu/.ssh/id_ed25519.pub
|
132 |
-
owner: ubuntu
|
133 |
-
group: ubuntu
|
134 |
-
mode: '0644'
|
135 |
-
become: yes
|
136 |
-
|
137 |
-
- name: Copy ED25519 private SSH key
|
138 |
-
copy:
|
139 |
-
content: "{{ vault_ssh_private_key }}"
|
140 |
-
dest: /home/ubuntu/.ssh/id_ed25519
|
141 |
-
owner: ubuntu
|
142 |
-
group: ubuntu
|
143 |
-
mode: '0600'
|
144 |
-
become: yes
|
145 |
-
|
146 |
-
- name: Ensure SSH config file exists
|
147 |
-
file:
|
148 |
-
path: /home/ubuntu/.ssh/config
|
149 |
-
state: touch
|
150 |
-
owner: ubuntu
|
151 |
-
group: ubuntu
|
152 |
-
mode: '0600'
|
153 |
-
become: yes
|
154 |
-
|
155 |
-
- name: Add turing.wpi.edu to SSH config
|
156 |
-
blockinfile:
|
157 |
-
path: /home/ubuntu/.ssh/config
|
158 |
-
block: |
|
159 |
-
Host turing.wpi.edu
|
160 |
-
User jrmolnia
|
161 |
-
Hostname turing.wpi.edu
|
162 |
-
IdentityFile ~/.ssh/id_ed25519
|
163 |
-
marker: "# {mark} ANSIBLE MANAGED BLOCK FOR TURING"
|
164 |
-
become: yes
|
165 |
-
become_user: ubuntu
|
166 |
-
|
167 |
-
- name: Add app server to SSH config
|
168 |
-
blockinfile:
|
169 |
-
path: /home/ubuntu/.ssh/config
|
170 |
-
block: |
|
171 |
-
Host app
|
172 |
-
Port 22018
|
173 |
-
Hostname paffenroth-23.dyn.wpi.edu
|
174 |
-
IdentityFile ~/.ssh/id_ed25519
|
175 |
-
marker: "# {mark} ANSIBLE MANAGED BLOCK FOR APP SERVER"
|
176 |
-
become: yes
|
177 |
-
become_user: ubuntu
|
178 |
-
|
179 |
-
- name: Check if initial setup flag file exists
|
180 |
-
stat:
|
181 |
-
path: /home/ubuntu/.initial_setup_complete
|
182 |
-
register: setup_flag
|
183 |
-
|
184 |
-
- name: Run initial setup shell script with Tailscale key
|
185 |
-
command: >
|
186 |
-
/opt/CS_553/deployment/02_deploy_to_controller/scripts/initial_ssh_config.sh -k {{ tailscale_authkey }}
|
187 |
-
args:
|
188 |
-
chdir: /opt/CS_553/deployment/02_deploy_to_controller
|
189 |
-
become: yes
|
190 |
-
become_user: ubuntu
|
191 |
-
when: not setup_flag.stat.exists
|
192 |
-
|
193 |
-
- name: Create initial setup flag file
|
194 |
-
file:
|
195 |
-
path: /home/ubuntu/.initial_setup_complete
|
196 |
-
state: touch
|
197 |
-
owner: ubuntu
|
198 |
-
group: ubuntu
|
199 |
-
mode: '0644'
|
200 |
-
when: not setup_flag.stat.exists
|
201 |
-
|
202 |
-
- name: Ensure .ansible directory exists
|
203 |
-
file:
|
204 |
-
path: /home/ubuntu/.ansible
|
205 |
-
state: directory
|
206 |
-
owner: ubuntu
|
207 |
-
group: ubuntu
|
208 |
-
mode: '0700'
|
209 |
-
become: yes
|
210 |
-
|
211 |
-
- name: Copy vault password file from local machine
|
212 |
-
copy:
|
213 |
-
src: ../../.secrets/password.txt
|
214 |
-
dest: /home/ubuntu/.ansible/vault_password.txt
|
215 |
-
owner: ubuntu
|
216 |
-
group: ubuntu
|
217 |
-
mode: '0600'
|
218 |
-
become: yes
|
219 |
-
|
220 |
-
- name: Run Ansible playbook for app server setup
|
221 |
-
command: >
|
222 |
-
ansible-playbook -i inventory/hosts.ini
|
223 |
-
playbooks/main.yml
|
224 |
-
--vault-password-file /home/ubuntu/.ansible/vault_password.txt
|
225 |
-
args:
|
226 |
-
chdir: /opt/CS_553/deployment/01_deploy_to_app
|
227 |
-
become: yes
|
228 |
-
become_user: ubuntu
|
229 |
-
environment:
|
230 |
-
ANSIBLE_CONFIG: /opt/CS_553/deployment/01_deploy_to_app/ansible.cfg
|
|
|
3 |
hosts: all
|
4 |
become: yes
|
5 |
vars_files:
|
6 |
+
- ../vars/secrets.yml
|
7 |
+
|
8 |
+
- import_playbook: system_setup.yml
|
9 |
+
- import_playbook: tailscale_setup.yml
|
10 |
+
- import_playbook: git_setup.yml
|
11 |
+
- import_playbook: ssh_setup.yml
|
12 |
+
- import_playbook: initial_setup.yml
|
13 |
+
- import_playbook: app_server_setup.yml
|
14 |
+
- import_playbook: connection_check_setup.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deployment/02_deploy_to_controller/playbooks/ssh_setup.yml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
- name: SSH Configuration Setup
|
3 |
+
hosts: all
|
4 |
+
become: yes
|
5 |
+
vars_files:
|
6 |
+
- ../vars/secrets.yml
|
7 |
+
vars:
|
8 |
+
ed25519_public_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIARTYgwoPW+VpBofWGYuHIldh18EUo42PHF/e08Dzcyp admin key CS553"
|
9 |
+
tasks:
|
10 |
+
- name: Ensure .ssh directory exists
|
11 |
+
file:
|
12 |
+
path: /home/ubuntu/.ssh
|
13 |
+
state: directory
|
14 |
+
owner: ubuntu
|
15 |
+
group: ubuntu
|
16 |
+
mode: '0700'
|
17 |
+
|
18 |
+
- name: Copy SSH keys
|
19 |
+
copy:
|
20 |
+
content: "{{ item.content }}"
|
21 |
+
dest: "/home/ubuntu/.ssh/{{ item.filename }}"
|
22 |
+
owner: ubuntu
|
23 |
+
group: ubuntu
|
24 |
+
mode: "{{ item.mode }}"
|
25 |
+
loop:
|
26 |
+
- { content: "{{ student_admin_private_key }}", filename: "student-admin-key", mode: "0600" }
|
27 |
+
- { content: "{{ student_admin_public_key }}", filename: "student-admin-key.pub", mode: "0644" }
|
28 |
+
- { content: "{{ ed25519_public_key }}", filename: "id_ed25519.pub", mode: "0644" }
|
29 |
+
- { content: "{{ vault_ssh_private_key }}", filename: "id_ed25519", mode: "0600" }
|
30 |
+
|
31 |
+
- name: Ensure SSH config file exists
|
32 |
+
file:
|
33 |
+
path: /home/ubuntu/.ssh/config
|
34 |
+
state: touch
|
35 |
+
owner: ubuntu
|
36 |
+
group: ubuntu
|
37 |
+
mode: '0600'
|
38 |
+
|
39 |
+
- name: Add SSH config entries
|
40 |
+
blockinfile:
|
41 |
+
path: /home/ubuntu/.ssh/config
|
42 |
+
block: "{{ item.block }}"
|
43 |
+
marker: "# {mark} ANSIBLE MANAGED BLOCK FOR {{ item.name }}"
|
44 |
+
loop:
|
45 |
+
- name: TURING
|
46 |
+
block: |
|
47 |
+
Host turing.wpi.edu
|
48 |
+
User jrmolnia
|
49 |
+
Hostname turing.wpi.edu
|
50 |
+
IdentityFile ~/.ssh/id_ed25519
|
51 |
+
- name: APP SERVER
|
52 |
+
block: |
|
53 |
+
Host app
|
54 |
+
Port 22018
|
55 |
+
Hostname paffenroth-23.dyn.wpi.edu
|
56 |
+
IdentityFile ~/.ssh/id_ed25519
|
deployment/02_deploy_to_controller/playbooks/system_setup.yml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
- name: System Setup
|
3 |
+
hosts: all
|
4 |
+
become: yes
|
5 |
+
tasks:
|
6 |
+
- name: Update apt cache
|
7 |
+
apt:
|
8 |
+
update_cache: yes
|
9 |
+
|
10 |
+
- name: Install required packages
|
11 |
+
apt:
|
12 |
+
name:
|
13 |
+
- apt-transport-https
|
14 |
+
- ca-certificates
|
15 |
+
- curl
|
16 |
+
- gnupg
|
17 |
+
- git
|
18 |
+
- ansible
|
19 |
+
state: present
|
deployment/02_deploy_to_controller/playbooks/tailscale_setup.yml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
- name: Tailscale Setup
|
3 |
+
hosts: all
|
4 |
+
become: yes
|
5 |
+
vars_files:
|
6 |
+
- vars/secrets.yml
|
7 |
+
tasks:
|
8 |
+
- name: Check if Tailscale GPG key exists
|
9 |
+
stat:
|
10 |
+
path: /usr/share/keyrings/tailscale-archive-keyring.gpg
|
11 |
+
register: tailscale_key
|
12 |
+
|
13 |
+
- name: Download Tailscale GPG key
|
14 |
+
get_url:
|
15 |
+
url: https://pkgs.tailscale.com/stable/ubuntu/jammy.noarmor.gpg
|
16 |
+
dest: /usr/share/keyrings/tailscale-archive-keyring.gpg
|
17 |
+
mode: '0644'
|
18 |
+
when: not tailscale_key.stat.exists
|
19 |
+
|
20 |
+
- name: Add Tailscale repository
|
21 |
+
ansible.builtin.apt_repository:
|
22 |
+
repo: deb [signed-by=/usr/share/keyrings/tailscale-archive-keyring.gpg] https://pkgs.tailscale.com/stable/ubuntu jammy main
|
23 |
+
state: present
|
24 |
+
filename: tailscale
|
25 |
+
|
26 |
+
- name: Update apt cache again
|
27 |
+
apt:
|
28 |
+
update_cache: yes
|
29 |
+
|
30 |
+
- name: Install Tailscale
|
31 |
+
apt:
|
32 |
+
name: tailscale
|
33 |
+
state: present
|
34 |
+
|
35 |
+
- name: Check Tailscale status
|
36 |
+
command: tailscale status
|
37 |
+
register: tailscale_status
|
38 |
+
changed_when: false
|
39 |
+
ignore_errors: yes
|
40 |
+
|
41 |
+
- name: Run tailscale up with pre-authentication
|
42 |
+
command: tailscale up --authkey={{ tailscale_authkey }}
|
43 |
+
register: tailscale_result
|
44 |
+
changed_when: "'Success' in tailscale_result.stdout"
|
45 |
+
when: tailscale_status.rc != 0 or 'Tailscale is stopped' in tailscale_status.stdout
|
deployment/02_deploy_to_controller/templates/connection_check.service.j2
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[Unit]
|
2 |
+
Description=Check connection to app server and run initial setup if needed
|
3 |
+
After=network.target
|
4 |
+
|
5 |
+
[Service]
|
6 |
+
ExecStart=/bin/bash /opt/CS_553/deployment/02_deploy_to_controller/scripts/connection_check.sh
|
7 |
+
User=ubuntu
|
8 |
+
|
9 |
+
[Install]
|
10 |
+
WantedBy=multi-user.target
|
deployment/02_deploy_to_controller/templates/connection_check.sh.j2
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# Configuration
|
4 |
+
APP_SERVER="student-admin@group18"
|
5 |
+
INITIAL_SETUP_SCRIPT="/opt/CS_553/deployment/02_deploy_to_controller/scripts/initial_ssh_config.sh"
|
6 |
+
TAILSCALE_KEY_FILE="/home/ubuntu/.tailscale_key"
|
7 |
+
|
8 |
+
# Function to check SSH connection
|
9 |
+
check_ssh_connection() {
|
10 |
+
ssh -o BatchMode=yes -o ConnectTimeout=5 $APP_SERVER exit
|
11 |
+
return $?
|
12 |
+
}
|
13 |
+
|
14 |
+
# Main logic
|
15 |
+
if ! check_ssh_connection; then
|
16 |
+
echo "Connection failed. Running initial setup script..."
|
17 |
+
if [ -f "$TAILSCALE_KEY_FILE" ]; then
|
18 |
+
TAILSCALE_KEY=$(cat "$TAILSCALE_KEY_FILE")
|
19 |
+
$INITIAL_SETUP_SCRIPT -k "$TAILSCALE_KEY"
|
20 |
+
else
|
21 |
+
echo "Tailscale key file not found. Cannot run initial setup."
|
22 |
+
exit 1
|
23 |
+
fi
|
24 |
+
else
|
25 |
+
echo "Connection successful. No action needed."
|
26 |
+
fi
|
deployment/02_deploy_to_controller/templates/connection_check.timer.j2
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[Unit]
|
2 |
+
Description=Run connection check every minute
|
3 |
+
|
4 |
+
[Timer]
|
5 |
+
OnBootSec=1min
|
6 |
+
OnUnitActiveSec=1min
|
7 |
+
|
8 |
+
[Install]
|
9 |
+
WantedBy=timers.target
|
deployment/02_deploy_to_controller/vars/secrets.yml
CHANGED
@@ -1,62 +1,62 @@
|
|
1 |
$ANSIBLE_VAULT;1.1;AES256
|
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 |
-
|
|
|
1 |
$ANSIBLE_VAULT;1.1;AES256
|
2 |
+
34393031333834633736313935333661646234666436386534353532616636383164376265303438
|
3 |
+
3561386531353562663033316365633433366566323036320a316339646236343566396564633866
|
4 |
+
37363436353863306339393661613062346465666133373639356666633132633833616535326563
|
5 |
+
6135333531366361300a336437656332313937313530353538303761353831333139373034613633
|
6 |
+
33663564356564346464313637316634643739653337653564346665313462323334643338343732
|
7 |
+
66623532666265343663613563356239343837666435303930346264333863333961386436346532
|
8 |
+
34663063323265353731376630323137366539656631356231396636313464633762356138663630
|
9 |
+
39633932313134326536363464356436313766363364633665623866656430383230376362646533
|
10 |
+
33666565386666323861616436343433366535666264666639333133666462666364306438633662
|
11 |
+
31356163306130616537613463376664383066623666323461303462666365313031343432646235
|
12 |
+
65346238353864396634663566316532633263346139626632393538626330323237666565353139
|
13 |
+
35383939323937663037326335653433383633313063366130303666316664343632306538343234
|
14 |
+
61363764643234396630356365643732326336346262633737383837363961643033643262633233
|
15 |
+
33616434353132633566383534373836626432613933633430623166303464653765623938366533
|
16 |
+
65636136386231353635313961356161616564643637303736656230333465316435653634386138
|
17 |
+
33383061353934626665353839326465663032363163393935363766313232633738626637326139
|
18 |
+
39653336376638646162396232663465356262383235323461633436636532626566623631653962
|
19 |
+
39393134653936653935376233383333313838666365353463373933356465373231306230656530
|
20 |
+
66646463353031353361623566353934303336663166613835326538653761616165333261376266
|
21 |
+
36353438353066316631366631636532396539613930353166353531353836666335313536353261
|
22 |
+
35653630386563666334396239393264306437383837623339393536376232313565653337303738
|
23 |
+
34376433336130386338363932623638316339396665343566346236333733306135393165336364
|
24 |
+
66643539633130366432313865623631363133326261306237643734383663663665636364613163
|
25 |
+
37316664373031623438303636386461376235363136616666346262626264386661343237663530
|
26 |
+
61613837363961396432316264613337353935313364323233346131353637623533623064656330
|
27 |
+
66303932653366613339336337613663396531363964666137663762393737656430353964643431
|
28 |
+
63373133633565623133383532303363323335346633313138626536653561646565373630653031
|
29 |
+
62303761623735633034626665353237323231333533663864333137666461303861646662656564
|
30 |
+
38363661323639633332633930643233343666363964666163326666306236663163363637313565
|
31 |
+
31313366343762633231656437393131613833363661373039653334363033616362346263353964
|
32 |
+
64343530633266336130663963323731313266336362393832343364383666316630383732633266
|
33 |
+
64353238643335386338386432323436376663633866663534666135343063376261656236646663
|
34 |
+
36633236643263643666666438383733303833363137373166636531666237376163373866633833
|
35 |
+
36366362623965363830666238643562393464623264316338316231363933353436343634633931
|
36 |
+
37666265323161663437663534646163653766333035616161303332303931343333626531363538
|
37 |
+
61633131633366626637366465343265313964376466646630336132393232343863656532643932
|
38 |
+
33303061393564343533303138336261343664316464663233303637373836666661313537336635
|
39 |
+
62323233383637343631393834623636656235303536336166346637613231353231303565353738
|
40 |
+
65393666343339656530313333353737313963663763373236303532323436353862646330636364
|
41 |
+
64373561623635643031373037303662376661666334633663663733346565643738613265353138
|
42 |
+
31363465353330313935636636656665623637356530386264356564393836636434363234303137
|
43 |
+
64376363313964366364366330366635626635303239303961643562356637326663353930306233
|
44 |
+
61653436663764333531306364323133623039323566333838306339663134373363643432643364
|
45 |
+
31366432343737613265323836363765653037393934323036326531363731316634363962353465
|
46 |
+
63386632393636393762303733343561343964643664616131383832383832643465376533396531
|
47 |
+
39333036623333303439623237636564646665356532636637326630646266396437646333666237
|
48 |
+
39313031626265386431323165653934643239656337333437626130366630386361613164333736
|
49 |
+
62316162363933303830656637633036353862376461626561616439316138313839313137366662
|
50 |
+
39613830383839333662616332306566623537663734333365363861373264333364353338303366
|
51 |
+
38333761373866336531366336386262386432666439633931613034353334623466633332306631
|
52 |
+
62636131363430393633383264613536653937653536303166646265633739663863616531306662
|
53 |
+
62666135613035343362363236356566393634623863396663346538666436336339636530626539
|
54 |
+
65346235616661343036643033663135393731356539316236333661383234363730303337353634
|
55 |
+
37383266373639626238636631323365363937366431303664363134396337383635343866633035
|
56 |
+
61343436646530323462383661613334666333346465383831303763613366623766393537646634
|
57 |
+
31653534643239356631353730633931626437346330663366386164336633303230663433343464
|
58 |
+
30633534633738376134316437656539396463373733636135633565656134316632323938613161
|
59 |
+
32656338346231383364306539663138393138326361646630656266386431313536613239373264
|
60 |
+
38613835646434356266616130616130363035663363633135616137346535333463646637636266
|
61 |
+
32663134653633633736353764393130333962663436366238353738313439373438646138306630
|
62 |
+
6131
|