From 50fc88e29d8a062238a580379f576ab7560bcbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 22:50:05 +0300 Subject: [PATCH 01/22] feat: add docker engine installation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- galaxy.yml | 15 +++++ playbooks/setup-runner.yaml | 4 ++ roles/docker_engine/README.md | 63 ++++++++++++++++++ roles/docker_engine/defaults/main.yaml | 0 roles/docker_engine/meta/main.yaml | 0 roles/docker_engine/tasks/main.yaml | 91 ++++++++++++++++++++++++++ 6 files changed, 173 insertions(+) create mode 100644 galaxy.yml create mode 100644 playbooks/setup-runner.yaml create mode 100644 roles/docker_engine/README.md create mode 100644 roles/docker_engine/defaults/main.yaml create mode 100644 roles/docker_engine/meta/main.yaml create mode 100644 roles/docker_engine/tasks/main.yaml diff --git a/galaxy.yml b/galaxy.yml new file mode 100644 index 0000000..acbea38 --- /dev/null +++ b/galaxy.yml @@ -0,0 +1,15 @@ +namespace: autoware +name: github_runner +version: 0.1.0 +readme: README.md +authors: + - M. Fatih Cırıt +description: Sets up the GitHub runner for Autoware repositories +license: + - Apache-2.0 +tags: + - autoware + - github-runner +repository: https://github.com/autowarefoundation/autoware-github-runner-ansible +homepage: https://www.autoware.org/ +issues: https://github.com/autowarefoundation/autoware-github-runner-ansible/issues diff --git a/playbooks/setup-runner.yaml b/playbooks/setup-runner.yaml new file mode 100644 index 0000000..7cc2039 --- /dev/null +++ b/playbooks/setup-runner.yaml @@ -0,0 +1,4 @@ +- name: Install docker engine + hosts: localhost + roles: + - autoware.github_runner.docker_engine diff --git a/roles/docker_engine/README.md b/roles/docker_engine/README.md new file mode 100644 index 0000000..a79159c --- /dev/null +++ b/roles/docker_engine/README.md @@ -0,0 +1,63 @@ +# docker_engine + +This role installs [Docker Engine](https://docs.docker.com/engine/) following the [installation guide](https://docs.docker.com/engine/install/ubuntu/) and sets up execution from non-root users following the [manual](https://docs.docker.com/engine/install/linux-postinstall/). + +## Inputs + +None. + +## Manual Installation + +Install Docker Engine: + +```bash +# Taken from: https://docs.docker.com/engine/install/ubuntu/ +# And: https://docs.docker.com/engine/install/linux-postinstall/ + +# Uninstall old versions +sudo apt-get remove docker docker-engine docker.io containerd runc + +# Install using the repository +sudo apt-get update + +sudo apt-get install \ + ca-certificates \ + curl \ + gnupg \ + lsb-release + +# Add Docker’s official GPG key: +sudo mkdir -p /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + +# Use the following command to set up the repository: +echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + +# Install Docker Engine +sudo apt-get update +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin + +# Verify that Docker Engine is installed correctly by running the hello-world image. +sudo docker run hello-world +# Note: This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits. +``` + +Perform the post-installation steps: + +```bash +# Post-installation steps for Linux + +# Create the docker group. +sudo groupadd docker + +# Add your user to the docker group. +sudo usermod -aG docker $USER + +# Log out and log back in so that your group membership is re-evaluated. + +# Verify that you can run docker commands without sudo +docker run hello-world +# Note: This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits. +``` diff --git a/roles/docker_engine/defaults/main.yaml b/roles/docker_engine/defaults/main.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/docker_engine/meta/main.yaml b/roles/docker_engine/meta/main.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/docker_engine/tasks/main.yaml b/roles/docker_engine/tasks/main.yaml new file mode 100644 index 0000000..fa180a6 --- /dev/null +++ b/roles/docker_engine/tasks/main.yaml @@ -0,0 +1,91 @@ +- name: Uninstall old versions + become: true + ansible.builtin.apt: + name: + - docker + - docker-engine + - docker.io + - containerd + - runc + - docker.io + - docker-compose + - docker-compose-v2 + - docker-doc + - podman-docker + state: absent + update_cache: true + +- name: Install dependencies for setting up apt sources + become: true + ansible.builtin.apt: + name: + - ca-certificates + - curl + - gnupg + - lsb-release + update_cache: true + +# sudo mkdir -p /etc/apt/keyrings +- name: Create the directory for keyrings + become: true + ansible.builtin.file: + state: directory + path: /etc/apt/keyrings + mode: 0755 + +# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg +- name: Authorize Docker GPG key + become: true + ansible.builtin.apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + keyring: /etc/apt/keyrings/docker.gpg + +- name: Save result of 'dpkg --print-architecture' + ansible.builtin.command: dpkg --print-architecture + register: docker_engine__deb_architecture + changed_when: false + +- name: Save result of 'lsb_release -cs' + ansible.builtin.command: lsb_release -cs + register: docker_engine__lsb_release_cs + changed_when: false + +- name: Save result of 'lsb_release -is' + ansible.builtin.command: lsb_release -is + register: docker_engine__lsb_release_is + changed_when: false + +# echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +- name: Add Docker apt repository to source list + become: true + ansible.builtin.apt_repository: + repo: deb [arch={{ docker_engine__deb_architecture.stdout }} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/{{ docker_engine__lsb_release_is.stdout | lower }} {{ docker_engine__lsb_release_cs.stdout }} stable + filename: docker + state: present + update_cache: true + +- name: Install Docker Engine + become: true + ansible.builtin.apt: + name: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-buildx-plugin + - docker-compose-plugin + update_cache: true + +# sudo groupadd docker +- name: Add docker group + become: true + ansible.builtin.group: + name: docker + state: present + +# sudo usermod -aG docker $USER +- name: Add user to docker group + become: true + ansible.builtin.user: + name: "{{ ansible_user_id }}" + groups: docker + append: true From f5d48bb1d2754a408912997df017628a440d7371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 22:54:15 +0300 Subject: [PATCH 02/22] add requirements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- requirements.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 requirements.yaml diff --git a/requirements.yaml b/requirements.yaml new file mode 100644 index 0000000..db185e8 --- /dev/null +++ b/requirements.yaml @@ -0,0 +1,3 @@ +collections: + - source: ./ + type: dir From 18c153f0b9885e657744360a15271ef4602018c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 23:03:21 +0300 Subject: [PATCH 03/22] rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- playbooks/{setup-runner.yaml => setup_runner.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename playbooks/{setup-runner.yaml => setup_runner.yaml} (100%) diff --git a/playbooks/setup-runner.yaml b/playbooks/setup_runner.yaml similarity index 100% rename from playbooks/setup-runner.yaml rename to playbooks/setup_runner.yaml From c7a1181fcbd6726c2a68fa65ed380a71029a8970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 23:45:25 +0300 Subject: [PATCH 04/22] install runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- README.md | 48 +++++++++++++++++++ .../{setup_runner.yaml => docker_setup.yaml} | 0 playbooks/runner_setup.yaml | 16 +++++++ 3 files changed, 64 insertions(+) rename playbooks/{setup_runner.yaml => docker_setup.yaml} (100%) create mode 100644 playbooks/runner_setup.yaml diff --git a/README.md b/README.md index 3609804..b2a7f41 100644 --- a/README.md +++ b/README.md @@ -1 +1,49 @@ # autoware-github-runner-ansible + +## Installation steps + +### Install ansible + +```bash +sudo apt update +sudo apt dist-upgrade -y + +# Remove apt installed ansible (In Ubuntu 22.04, ansible the version is old) +sudo apt-get purge ansible + +# Install pipx +sudo apt-get -y install pipx + +# Add pipx to the system PATH +python3 -m pipx ensurepath + +# Install ansible +pipx install --include-deps --force ansible +``` + +### Install ansible collections + +```bash +ansible-galaxy collection install -f -r "requirements.yaml" + +ansible-galaxy role install git+https://github.com/MonolithProjects/ansible-github_actions_runner.git,1.21.1 +``` + +### Playbooks + +#### Docker setup + +```bash +ansible-playbook autoware.github_runner.docker_setup --ask-become-pass + +# Restart to apply post-installation changes +sudo reboot +``` + +#### Runner setup + +```bash +export PERSONAL_ACCESS_TOKEN= + +ansible-playbook autoware.github_runner.runner_setup --ask-become-pass +``` diff --git a/playbooks/setup_runner.yaml b/playbooks/docker_setup.yaml similarity index 100% rename from playbooks/setup_runner.yaml rename to playbooks/docker_setup.yaml diff --git a/playbooks/runner_setup.yaml b/playbooks/runner_setup.yaml new file mode 100644 index 0000000..fbd5aae --- /dev/null +++ b/playbooks/runner_setup.yaml @@ -0,0 +1,16 @@ +- name: Install docker engine + roles: + - autoware.github_runner.docker_engine + +- name: Install GitHub Actions Runner + hosts: localhost + become: yes + vars: + - github_account: "xmfcx" + - github_owner: "autowarefoundation" + - runner_org: yes + - runner_group: "Default" + - runner_labels: [self-hosted, Linux, X64] + - runner_dir: "{{ ansible_env.HOME }}/actions-runner" + roles: + - role: monolithprojects.github_actions_runner From caee994f16064d7c42c9fa0afb79cc685ae03f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 23:49:25 +0300 Subject: [PATCH 05/22] add requirement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- requirements.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.yaml b/requirements.yaml index db185e8..064793d 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -1,3 +1,6 @@ collections: + - source: git+https://github.com/MonolithProjects/ansible-github_actions_runner.git + version: 1.21.1 + name: monolithprojects.github_actions_runner - source: ./ type: dir From e9b526f3491ffda7dc00a619b6408be975e1f7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 23:50:21 +0300 Subject: [PATCH 06/22] https MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- requirements.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.yaml b/requirements.yaml index 064793d..9eec06f 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -1,5 +1,5 @@ collections: - - source: git+https://github.com/MonolithProjects/ansible-github_actions_runner.git + - source: https://github.com/MonolithProjects/ansible-github_actions_runner.git version: 1.21.1 name: monolithprojects.github_actions_runner - source: ./ From 0ccefc0a52ba91eff9a7bbcbc6a5c15676647726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 23:53:00 +0300 Subject: [PATCH 07/22] a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- requirements.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.yaml b/requirements.yaml index 9eec06f..d270502 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -1,6 +1,7 @@ -collections: +roles: - source: https://github.com/MonolithProjects/ansible-github_actions_runner.git version: 1.21.1 name: monolithprojects.github_actions_runner +collections: - source: ./ type: dir From a3a2e0c62a7b011562dd01d3f71417fb76575afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 23:55:21 +0300 Subject: [PATCH 08/22] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- playbooks/runner_setup.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/playbooks/runner_setup.yaml b/playbooks/runner_setup.yaml index fbd5aae..2693c08 100644 --- a/playbooks/runner_setup.yaml +++ b/playbooks/runner_setup.yaml @@ -1,7 +1,3 @@ -- name: Install docker engine - roles: - - autoware.github_runner.docker_engine - - name: Install GitHub Actions Runner hosts: localhost become: yes From f268996938024a4dcdbef00bf23b83e64ae6f074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Mon, 9 Dec 2024 23:56:54 +0300 Subject: [PATCH 09/22] a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- playbooks/runner_setup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/runner_setup.yaml b/playbooks/runner_setup.yaml index 2693c08..a39974b 100644 --- a/playbooks/runner_setup.yaml +++ b/playbooks/runner_setup.yaml @@ -9,4 +9,4 @@ - runner_labels: [self-hosted, Linux, X64] - runner_dir: "{{ ansible_env.HOME }}/actions-runner" roles: - - role: monolithprojects.github_actions_runner + - monolithprojects.github_actions_runner From c163dcf324ee8882e286e546aa9166618d428323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:01:20 +0300 Subject: [PATCH 10/22] req MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- playbooks/runner_setup.yaml | 2 +- requirements.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/playbooks/runner_setup.yaml b/playbooks/runner_setup.yaml index a39974b..2693c08 100644 --- a/playbooks/runner_setup.yaml +++ b/playbooks/runner_setup.yaml @@ -9,4 +9,4 @@ - runner_labels: [self-hosted, Linux, X64] - runner_dir: "{{ ansible_env.HOME }}/actions-runner" roles: - - monolithprojects.github_actions_runner + - role: monolithprojects.github_actions_runner diff --git a/requirements.yaml b/requirements.yaml index d270502..7272ecd 100644 --- a/requirements.yaml +++ b/requirements.yaml @@ -1,7 +1,7 @@ roles: - - source: https://github.com/MonolithProjects/ansible-github_actions_runner.git + - name: monolithprojects.github_actions_runner version: 1.21.1 - name: monolithprojects.github_actions_runner + src: https://github.com/MonolithProjects/ansible-github_actions_runner collections: - source: ./ type: dir From 41477ef5a499446dbf6277819432082a4e3e1316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:04:08 +0300 Subject: [PATCH 11/22] readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index b2a7f41..c782d2b 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,7 @@ pipx install --include-deps --force ansible ### Install ansible collections ```bash -ansible-galaxy collection install -f -r "requirements.yaml" - -ansible-galaxy role install git+https://github.com/MonolithProjects/ansible-github_actions_runner.git,1.21.1 +ansible-galaxy install -f -r requirements.yaml ``` ### Playbooks From 49547b1c37688d8ae75cb423061c085f7e896a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:07:47 +0300 Subject: [PATCH 12/22] runner opt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- playbooks/runner_setup.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/playbooks/runner_setup.yaml b/playbooks/runner_setup.yaml index 2693c08..daa3377 100644 --- a/playbooks/runner_setup.yaml +++ b/playbooks/runner_setup.yaml @@ -7,6 +7,5 @@ - runner_org: yes - runner_group: "Default" - runner_labels: [self-hosted, Linux, X64] - - runner_dir: "{{ ansible_env.HOME }}/actions-runner" roles: - role: monolithprojects.github_actions_runner From 08d81f5d49bd84fb1dd50e668f82f04cb1ad4861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:16:19 +0300 Subject: [PATCH 13/22] user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- playbooks/runner_setup.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/playbooks/runner_setup.yaml b/playbooks/runner_setup.yaml index daa3377..2444e61 100644 --- a/playbooks/runner_setup.yaml +++ b/playbooks/runner_setup.yaml @@ -1,5 +1,6 @@ - name: Install GitHub Actions Runner hosts: localhost + runner_user: "ubuntu" become: yes vars: - github_account: "xmfcx" From 3a3b81a4f26be76684fc9837d3535dd77a58d73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:44:35 +0300 Subject: [PATCH 14/22] runner config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- README.md | 11 ++++++++++- playbooks/runner_configuration.yaml | 4 ++++ roles/runner_configuration/README.md | 1 + roles/runner_configuration/defaults/main.yaml | 0 .../files/cleanup_script.sh | 5 +++++ roles/runner_configuration/meta/main.yaml | 0 roles/runner_configuration/tasks/main.yaml | 17 +++++++++++++++++ 7 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 playbooks/runner_configuration.yaml create mode 100644 roles/runner_configuration/README.md create mode 100644 roles/runner_configuration/defaults/main.yaml create mode 100644 roles/runner_configuration/files/cleanup_script.sh create mode 100644 roles/runner_configuration/meta/main.yaml create mode 100644 roles/runner_configuration/tasks/main.yaml diff --git a/README.md b/README.md index c782d2b..b4bbb5e 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,17 @@ sudo reboot #### Runner setup +- 🔴 Modify the PAT according to https://github.com/MonolithProjects/ansible-github_actions_runner?tab=readme-ov-file#requirements . +- 🔴 Modify the runner name. + ```bash export PERSONAL_ACCESS_TOKEN= -ansible-playbook autoware.github_runner.runner_setup --ask-become-pass +ansible-playbook autoware.github_runner.runner_setup --ask-become-pass --extra-vars "runner_name=ovh-runner-01 reinstall_runner=true" +``` + +Now we'll set up the clean-up script. + +```bash +ansible-playbook autoware.github_runner.runner_configuration --ask-become-pass ``` diff --git a/playbooks/runner_configuration.yaml b/playbooks/runner_configuration.yaml new file mode 100644 index 0000000..58045e6 --- /dev/null +++ b/playbooks/runner_configuration.yaml @@ -0,0 +1,4 @@ +- name: Configure the runner + hosts: localhost + roles: + - autoware.github_runner.runner_configuration diff --git a/roles/runner_configuration/README.md b/roles/runner_configuration/README.md new file mode 100644 index 0000000..98f2293 --- /dev/null +++ b/roles/runner_configuration/README.md @@ -0,0 +1 @@ +# runner_configuration diff --git a/roles/runner_configuration/defaults/main.yaml b/roles/runner_configuration/defaults/main.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/runner_configuration/files/cleanup_script.sh b/roles/runner_configuration/files/cleanup_script.sh new file mode 100644 index 0000000..1409209 --- /dev/null +++ b/roles/runner_configuration/files/cleanup_script.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +keep_last_x=4 +# List all images, sort by creation date, get the image IDs, skip the last x, and remove the rest +docker images --format "{{.CreatedAt}} {{.ID}}" | sort -r | awk '{print $5}' | tail -n +$((keep_last_x + 1)) | xargs -r docker rmi -f diff --git a/roles/runner_configuration/meta/main.yaml b/roles/runner_configuration/meta/main.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/runner_configuration/tasks/main.yaml b/roles/runner_configuration/tasks/main.yaml new file mode 100644 index 0000000..7da5890 --- /dev/null +++ b/roles/runner_configuration/tasks/main.yaml @@ -0,0 +1,17 @@ +- name: Create directory for runner scripts + file: + path: /opt/runner-scripts + state: directory + mode: '0755' + +- name: Install the cleanup script + copy: + src: "{{ role_path }}/files/cleanup_script.sh" + dest: "/opt/runner-scripts/cleanup_script.sh" + mode: '0755' + +- name: Append cleanup script to actions-runner .env + lineinfile: + path: /opt/actions-runner/.env + line: "ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh" + create: true From 6766bdb5ef8c0691603d3c063dc5700d4e91c5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:45:51 +0300 Subject: [PATCH 15/22] become: true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- roles/runner_configuration/tasks/main.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roles/runner_configuration/tasks/main.yaml b/roles/runner_configuration/tasks/main.yaml index 7da5890..633d783 100644 --- a/roles/runner_configuration/tasks/main.yaml +++ b/roles/runner_configuration/tasks/main.yaml @@ -3,15 +3,18 @@ path: /opt/runner-scripts state: directory mode: '0755' + become: true - name: Install the cleanup script copy: src: "{{ role_path }}/files/cleanup_script.sh" dest: "/opt/runner-scripts/cleanup_script.sh" mode: '0755' + become: true - name: Append cleanup script to actions-runner .env lineinfile: path: /opt/actions-runner/.env line: "ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh" create: true + become: true From c98eb12982501bd0379df4ac7ea45ba082be12d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:49:16 +0300 Subject: [PATCH 16/22] a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- roles/runner_configuration/tasks/main.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/roles/runner_configuration/tasks/main.yaml b/roles/runner_configuration/tasks/main.yaml index 633d783..a399ff9 100644 --- a/roles/runner_configuration/tasks/main.yaml +++ b/roles/runner_configuration/tasks/main.yaml @@ -1,20 +1,17 @@ - name: Create directory for runner scripts - file: + ansible.builtin.file: path: /opt/runner-scripts state: directory mode: '0755' - become: true - name: Install the cleanup script - copy: + ansible.builtin.copy: src: "{{ role_path }}/files/cleanup_script.sh" dest: "/opt/runner-scripts/cleanup_script.sh" mode: '0755' - become: true - name: Append cleanup script to actions-runner .env - lineinfile: + ansible.builtin.lineinfile: path: /opt/actions-runner/.env line: "ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh" create: true - become: true From b2ba486dc44adb611c487760c6a337f5ea8e094e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:51:29 +0300 Subject: [PATCH 17/22] become. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- roles/runner_configuration/tasks/main.yaml | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/roles/runner_configuration/tasks/main.yaml b/roles/runner_configuration/tasks/main.yaml index a399ff9..3fb2bc6 100644 --- a/roles/runner_configuration/tasks/main.yaml +++ b/roles/runner_configuration/tasks/main.yaml @@ -1,17 +1,21 @@ -- name: Create directory for runner scripts - ansible.builtin.file: - path: /opt/runner-scripts - state: directory - mode: '0755' +- name: Configure the runner + hosts: localhost + become: true + tasks: + - name: Create directory for runner scripts + ansible.builtin.file: + path: /opt/runner-scripts + state: directory + mode: '0755' -- name: Install the cleanup script - ansible.builtin.copy: - src: "{{ role_path }}/files/cleanup_script.sh" - dest: "/opt/runner-scripts/cleanup_script.sh" - mode: '0755' + - name: Install the cleanup script + ansible.builtin.copy: + src: "{{ role_path }}/files/cleanup_script.sh" + dest: "/opt/runner-scripts/cleanup_script.sh" + mode: '0755' -- name: Append cleanup script to actions-runner .env - ansible.builtin.lineinfile: - path: /opt/actions-runner/.env - line: "ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh" - create: true + - name: Append cleanup script to actions-runner .env + ansible.builtin.lineinfile: + path: /opt/actions-runner/.env + line: "ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh" + create: true From eb2ac6df0098ec741b3a74e2673e401b67dab879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:53:56 +0300 Subject: [PATCH 18/22] become MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- roles/runner_configuration/tasks/main.yaml | 37 +++++++++++----------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/roles/runner_configuration/tasks/main.yaml b/roles/runner_configuration/tasks/main.yaml index 3fb2bc6..62f586a 100644 --- a/roles/runner_configuration/tasks/main.yaml +++ b/roles/runner_configuration/tasks/main.yaml @@ -1,21 +1,20 @@ -- name: Configure the runner - hosts: localhost - become: true - tasks: - - name: Create directory for runner scripts - ansible.builtin.file: - path: /opt/runner-scripts - state: directory - mode: '0755' +- name: Create directory for runner scripts + become: yes + ansible.builtin.file: + path: /opt/runner-scripts + state: directory + mode: '0755' - - name: Install the cleanup script - ansible.builtin.copy: - src: "{{ role_path }}/files/cleanup_script.sh" - dest: "/opt/runner-scripts/cleanup_script.sh" - mode: '0755' +- name: Install the cleanup script + become: yes + ansible.builtin.copy: + src: "{{ role_path }}/files/cleanup_script.sh" + dest: "/opt/runner-scripts/cleanup_script.sh" + mode: '0755' - - name: Append cleanup script to actions-runner .env - ansible.builtin.lineinfile: - path: /opt/actions-runner/.env - line: "ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh" - create: true +- name: Append cleanup script to actions-runner .env + become: yes + ansible.builtin.lineinfile: + path: /opt/actions-runner/.env + line: "ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh" + create: true From d2312695f256494d50fe02d34974e2e613fd4e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 00:57:34 +0300 Subject: [PATCH 19/22] readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b4bbb5e..a5d4512 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # autoware-github-runner-ansible -## Installation steps +## Installation ### Install ansible @@ -49,8 +49,11 @@ export PERSONAL_ACCESS_TOKEN= ansible-playbook autoware.github_runner.runner_setup --ask-become-pass --extra-vars "runner_name=ovh-runner-01 reinstall_runner=true" ``` -Now we'll set up the clean-up script. +Set up the clean-up script. ```bash ansible-playbook autoware.github_runner.runner_configuration --ask-become-pass + +# Restart and check if everything is working +sudo reboot ``` From c9590b5516948636aadd344a5830024ee5de66e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 01:00:57 +0300 Subject: [PATCH 20/22] improve readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- README.md | 3 ++- playbooks/runner_setup.yaml | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a5d4512..58f4000 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,12 @@ sudo reboot - 🔴 Modify the PAT according to https://github.com/MonolithProjects/ansible-github_actions_runner?tab=readme-ov-file#requirements . - 🔴 Modify the runner name. +- 🔴 Modify the GitHub account. ```bash export PERSONAL_ACCESS_TOKEN= -ansible-playbook autoware.github_runner.runner_setup --ask-become-pass --extra-vars "runner_name=ovh-runner-01 reinstall_runner=true" +ansible-playbook autoware.github_runner.runner_setup --ask-become-pass --extra-vars "runner_name=ovh-runner-01 reinstall_runner=true github_account=xmfcx" ``` Set up the clean-up script. diff --git a/playbooks/runner_setup.yaml b/playbooks/runner_setup.yaml index 2444e61..a34b934 100644 --- a/playbooks/runner_setup.yaml +++ b/playbooks/runner_setup.yaml @@ -3,7 +3,6 @@ runner_user: "ubuntu" become: yes vars: - - github_account: "xmfcx" - github_owner: "autowarefoundation" - runner_org: yes - runner_group: "Default" From 314fb99dddb695949d09943796462cd57ff6bb85 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:04:27 +0000 Subject: [PATCH 21/22] style(pre-commit): autofix --- README.md | 2 +- roles/runner_configuration/tasks/main.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 58f4000..8bd5b86 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ sudo reboot #### Runner setup -- 🔴 Modify the PAT according to https://github.com/MonolithProjects/ansible-github_actions_runner?tab=readme-ov-file#requirements . +- 🔴 Modify the PAT according to . - 🔴 Modify the runner name. - 🔴 Modify the GitHub account. diff --git a/roles/runner_configuration/tasks/main.yaml b/roles/runner_configuration/tasks/main.yaml index 62f586a..ee4d076 100644 --- a/roles/runner_configuration/tasks/main.yaml +++ b/roles/runner_configuration/tasks/main.yaml @@ -3,14 +3,14 @@ ansible.builtin.file: path: /opt/runner-scripts state: directory - mode: '0755' + mode: "0755" - name: Install the cleanup script become: yes ansible.builtin.copy: src: "{{ role_path }}/files/cleanup_script.sh" dest: "/opt/runner-scripts/cleanup_script.sh" - mode: '0755' + mode: "0755" - name: Append cleanup script to actions-runner .env become: yes From 129f83f893db72e4610f80e56b1aa7b7dc03fe36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 10 Dec 2024 01:09:33 +0300 Subject: [PATCH 22/22] yamllint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- playbooks/runner_setup.yaml | 10 +++++----- roles/runner_configuration/tasks/main.yaml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/playbooks/runner_setup.yaml b/playbooks/runner_setup.yaml index a34b934..717ebe5 100644 --- a/playbooks/runner_setup.yaml +++ b/playbooks/runner_setup.yaml @@ -1,11 +1,11 @@ - name: Install GitHub Actions Runner hosts: localhost - runner_user: "ubuntu" - become: yes + runner_user: ubuntu + become: true vars: - - github_owner: "autowarefoundation" - - runner_org: yes - - runner_group: "Default" + - github_owner: autowarefoundation + - runner_org: true + - runner_group: Default - runner_labels: [self-hosted, Linux, X64] roles: - role: monolithprojects.github_actions_runner diff --git a/roles/runner_configuration/tasks/main.yaml b/roles/runner_configuration/tasks/main.yaml index ee4d076..8458d09 100644 --- a/roles/runner_configuration/tasks/main.yaml +++ b/roles/runner_configuration/tasks/main.yaml @@ -1,20 +1,20 @@ - name: Create directory for runner scripts - become: yes + become: true ansible.builtin.file: path: /opt/runner-scripts state: directory mode: "0755" - name: Install the cleanup script - become: yes + become: true ansible.builtin.copy: src: "{{ role_path }}/files/cleanup_script.sh" - dest: "/opt/runner-scripts/cleanup_script.sh" + dest: /opt/runner-scripts/cleanup_script.sh mode: "0755" - name: Append cleanup script to actions-runner .env - become: yes + become: true ansible.builtin.lineinfile: path: /opt/actions-runner/.env - line: "ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh" + line: ACTIONS_RUNNER_HOOK_JOB_STARTED=/opt/runner-scripts/cleanup_script.sh create: true