Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 15bfee7

Browse files
committed
Add remote_build_server GitHub Action
1 parent 6e49368 commit 15bfee7

File tree

4 files changed

+44
-11
lines changed

4 files changed

+44
-11
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: remote_build_server
2+
3+
on:
4+
push:
5+
paths:
6+
- tools/create_remote_build_server/**
7+
- .github/workflows/remote_build_server.yml
8+
9+
jobs:
10+
remote_build_server-check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
submodules: true
16+
17+
- name: Create ssh key and add it to authorized keys
18+
run: |
19+
chmod 0700 /home/$USER
20+
install -m 0700 -d $HOME/.ssh && ssh-keygen -b 2048 -t rsa -f $HOME/.ssh/id_rsa -q -N ""
21+
cp $HOME/.ssh/id_rsa.pub $HOME/.ssh/authorized_keys
22+
chmod 0600 $HOME/.ssh/authorized_keys
23+
24+
- name: Install Ansible packages
25+
run: |
26+
sudo apt update
27+
sudo apt install -y ansible python-jmespath
28+
29+
- name: Run ansible
30+
run: |
31+
export REMOTE_USER="${USER}"
32+
export REMOTE_IP="localhost"
33+
export ANSIBLE_HOST_KEY_CHECKING=False
34+
export ANSIBLE_SKIP_TAGS="actions-runner_registration,actions-runner_installation"
35+
cd tools/create_remote_build_server
36+
./build_remote_ssh_ubuntu.sh

tools/create_remote_build_server/build_remote_ssh_ubuntu.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22

33
# Use with Ubuntu Server 20.04
44

5-
REMOTE_IP="company-nb"
6-
REMOTE_USER="pruzicka"
7-
USER_PASSWORD="xxxxxxxxxx"
5+
REMOTE_IP="${REMOTE_IP:-company-nb}"
6+
REMOTE_USER="${REMOTE_USER:-pruzicka}"
7+
USER_PASSWORD="${USER_PASSWORD:-xxxxxxxxxx}"
88
MY_PACKER_TEMPLATES_GITHUB_REPOSITORY="https://github.com/ruzickap/packer-templates"
9-
GITHUB_SELF_HOSTED_RUNNER_TOKEN=${TOKEN:-Axxxxxxxxxxxxxxxxxxxxxxxxxxx4}
9+
GITHUB_SELF_HOSTED_RUNNER_TOKEN=${GITHUB_SELF_HOSTED_RUNNER_TOKEN:-Axxxxxxxxxxxxxxxxxxxxxxxxxxx4}
1010

1111
# Prepare remote machine for build
12-
if [ -n "$GITHUB_SELF_HOSTED_RUNNER_TOKEN" ]; then
13-
ansible-playbook -i "$REMOTE_IP," -e "ansible_sudo_pass=$USER_PASSWORD" -e GITHUB_SELF_HOSTED_RUNNER_TOKEN="$GITHUB_SELF_HOSTED_RUNNER_TOKEN" -e MY_PACKER_TEMPLATES_GITHUB_REPOSITORY="$MY_PACKER_TEMPLATES_GITHUB_REPOSITORY" --user "$REMOTE_USER" build_remote_ssh_ubuntu.yml
14-
else
15-
echo "Missing GITHUB_SELF_HOSTED_RUNNER_TOKEN"
16-
exit 1
17-
fi
12+
ansible-playbook -i "$REMOTE_IP," -e "ansible_sudo_pass=$USER_PASSWORD" -e GITHUB_SELF_HOSTED_RUNNER_TOKEN="$GITHUB_SELF_HOSTED_RUNNER_TOKEN" -e MY_PACKER_TEMPLATES_GITHUB_REPOSITORY="$MY_PACKER_TEMPLATES_GITHUB_REPOSITORY" --user "$REMOTE_USER" build_remote_ssh_ubuntu.yml

tools/create_remote_build_server/build_remote_ssh_ubuntu.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
action_runner_count: 2
2727

2828
roles:
29-
- role: ansible-role-my_common_defaults
29+
- role: my_common_defaults
3030
- role: cloudalchemy.node-exporter
3131
node_exporter_enabled_collectors:
3232
- diskstats:
@@ -222,6 +222,7 @@
222222
chdir: /home/{{ builder_username }}/actions-runner-{{ item }}
223223
creates: /home/{{ builder_username }}/actions-runner-{{ item }}/.runner
224224
loop: "{{ range(1, action_runner_count + 1) | list }}"
225+
tags: actions-runner_registration
225226

226227
become_user: "{{ builder_username }}"
227228

@@ -233,6 +234,7 @@
233234
environment:
234235
SUDO_USER: "{{ builder_username }}"
235236
loop: "{{ range(1, action_runner_count + 1) | list }}"
237+
tags: actions-runner_installation
236238

237239
handlers:
238240
- name: restart systemd-logind

0 commit comments

Comments
 (0)