Skip to content

Commit

Permalink
Fix everytime runner installing
Browse files Browse the repository at this point in the history
  • Loading branch information
cradle8810 committed Jan 11, 2025
1 parent ed44c1c commit 7ba2f72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions inventories/host_vars/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ runner:
39643236383637633663373138663961393937633764316161313337306265363662333935616436
3561323139373365326132353130626633363234666334303963
runners:
basepath: "/opt/runner"
nuc03:
- runner_name: ansible_hayaworld_03-01
github_repo: ansible_hayaworld
Expand Down
5 changes: 2 additions & 3 deletions runner03.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@
- sudo

- name: Install Runners
ansible.builtin.import_tasks:
ansible.builtin.include_tasks:
file: tasks/runner/install_runners.yml
vars:
runners_define: "{{ runner.runners.nuc03 }}"
loop: "{{ runner.runners.nuc03 }}"
tags:
- runners
16 changes: 12 additions & 4 deletions tasks/runner/install_runners.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
---
- name: "Check svc.sh exists for {{ item.runner_name }}"
ansible.builtin.stat:
path: "{{ runner.runners.basepath }}/{{ item.runner_name }}/svc.sh"
register: "is_configured"
tags:
- always

# https://github.com/MonolithProjects/ansible-github_actions_runner
- name: Install Runners
ansible.builtin.include_role:
ansible.builtin.import_role:
name: monolithprojects.github_actions_runner
vars:
runner_user: "{{ runner.user.username }}"
runner_dir: "/opt/runner/{{ item.runner_name }}"
runner_dir: "{{ runner.runners.basepath }}/{{ item.runner_name }}"
runner_version: "2.321.0"
runner_state: "started"
reinstall_runner: true
reinstall_runner: "{{ not (is_configured.stat.exists) }}"
hide_sensitive_logs: true
github_url: "https://github.com"
github_api_url: "https://api.github.com"
Expand All @@ -20,4 +27,5 @@
all_runners_in_same_repo: false
github_account: "cradle8810"
github_repo: "{{ item.github_repo }}"
loop: "{{ runners_define }}"
tags:
- always

0 comments on commit 7ba2f72

Please sign in to comment.