-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds setup code to initialize & use Robot servers in e2e tests. It uses installimage with autosetup to prepare the server and then uses k3sup similar to our existing setup to join the server into the existing kubernetes cluster. Right now it only supports joining Robot servers as worker nodes, not for the control-plane. Also, it only supports non-Private Network setups.
- Loading branch information
Showing
11 changed files
with
374 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[defaults] | ||
inventory = ${PWD}/inventory.yml | ||
host_key_checking = False | ||
stdout_callback = community.general.yaml | ||
|
||
[ssh_connection] | ||
pipelining = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
HOSTNAME {{ server_name }} | ||
|
||
DRIVE1 /dev/sda | ||
DRIVE2 /dev/sdb | ||
|
||
SWRAID 1 | ||
# We do not care at all about data consistency/availability, as we reprovision for every test run | ||
SWRAIDLEVEL 0 | ||
|
||
PART / ext4 all | ||
|
||
IMAGE /root/.oldroot/nfs/images/Ubuntu-2204-jammy-amd64-base.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
- name: Prepare Reinstall | ||
hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
|
||
vars: | ||
scope: dev | ||
# Additional SSH keys to add to the server for debugging. Must already exist in Robot. | ||
authorized_keys: [] | ||
|
||
module_defaults: | ||
group/community.hrobot.robot: | ||
hetzner_user: "{{ lookup('ansible.builtin.env', 'ROBOT_USER') }}" | ||
hetzner_password: "{{ lookup('ansible.builtin.env', 'ROBOT_PASSWORD') }}" | ||
|
||
tasks: | ||
- name: Get Server Info | ||
community.hrobot.server_info: | ||
server_number: "{{ server_number }}" | ||
register: server_info | ||
|
||
- name: Set Server Facts | ||
ansible.builtin.set_fact: | ||
server_ip: "{{ server_info.servers[0].server_ip }}" | ||
server_name: "{{ server_info.servers[0].server_name }}" | ||
|
||
- name: Create SSH Key | ||
community.hrobot.ssh_key: | ||
name: "hccm-{{ scope }}" | ||
public_key: "{{ lookup('file', '../.ssh-{{ scope }}.pub') }}" | ||
state: present | ||
register: ssh_key | ||
|
||
- name: Enable Rescue System | ||
community.hrobot.boot: | ||
server_number: "{{ server_number }}" | ||
rescue: | ||
authorized_keys: "{{ authorized_keys + [ ssh_key.fingerprint ] }}" | ||
os: linux | ||
|
||
- name: Reset Server (to get to Rescue System) | ||
community.hrobot.reset: | ||
server_number: "{{ server_number }}" | ||
reset_type: hardware # only type that does not require a separate reset for starting again | ||
|
||
- name: Wait for SSH | ||
ansible.builtin.wait_for: | ||
host: "{{ server_ip }}" | ||
port: "{{ 22 }}" | ||
search_regex: SSH | ||
|
||
- name: Install OS to Server | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- name: Write autosetup | ||
ansible.builtin.template: | ||
src: autosetup.j2 | ||
dest: /autosetup | ||
vars: | ||
server_name: "{{ hostvars['localhost']['server_name'] }}" | ||
|
||
- name: installimage | ||
# -t => Take over rescue system SSH public keys | ||
ansible.builtin.command: /root/.oldroot/nfs/install/installimage -t yes | ||
|
||
- name: Reboot | ||
ansible.builtin.reboot: | ||
# 5 minutes should be enough for a reboot, and in case | ||
# there is some issue, we can abort earlier. | ||
reboot_timeout: 300 | ||
|
||
- name: Create k3s directory | ||
ansible.builtin.file: | ||
path: /etc/rancher/k3s | ||
state: directory | ||
|
||
- name: Prepare Local Registry | ||
ansible.builtin.copy: | ||
src: ../k3s-registries.yaml | ||
dest: /etc/rancher/k3s/registries.yaml | ||
|
||
- name: Join Kubernetes Cluster | ||
hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
vars: | ||
control_ip: "{{ lookup('ansible.builtin.env', 'CONTROL_IP') }}" | ||
k3s_channel: stable | ||
scope: dev | ||
|
||
tasks: | ||
- name: k3sup | ||
ansible.builtin.command: >- | ||
k3sup join | ||
--server-ip={{ control_ip | ansible.builtin.mandatory }} | ||
--ip={{ server_ip }} | ||
--k3s-channel={{ k3s_channel }} | ||
--k3s-extra-args="--kubelet-arg cloud-provider=external --node-label instance.hetzner.cloud/is-root-server=true" | ||
--ssh-key ../.ssh-{{ scope }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
all: | ||
hosts: | ||
# TODO: Dynamic inventory | ||
hccm-test: | ||
ansible_host: 142.132.203.104 | ||
ansible_user: root | ||
ansible_ssh_private_key_file: ../.ssh-{{ scope }} | ||
ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
collections: | ||
- name: community.hrobot | ||
- name: community.general |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build e2e | ||
//go:build e2e && !robot | ||
|
||
package e2e | ||
|
||
|
Oops, something went wrong.