Skip to content

Commit

Permalink
Ensure target directory exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpugh-miax committed Jan 29, 2025
1 parent 3eb55d5 commit 77efb58
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions roles/operations.runner/tasks/github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
become_user: "{{ item.runner_user | default(operations_platform_user) | default('platform')}}"
set_fact:
# @TODO: Is there a better way to set defaults in a list of maps?
item_runner_path: "{{ user_facts.home }}/{{ item.runner_path | default('runner')}}"
item_runner_path: "{{ user_facts.home }}/{{ item.runner_path | default('runners/' ~ item.runner_repo )}}"
item_runner_user: "{{ item.runner_user | default(operations_platform_user) | default('platform')}}"
item_runner_name: "{{ item.runner_user | default(operations_platform_user) }}@{{ item.runner_name | default(inventory_hostname) }}"
item_runner_repo: "{{ item.runner_repo | default(operations_runner_repo_default) }}"
item_runner_labels: "{{ item.runner_user | default(operations_platform_user) }}@{{ item.runner_name | default(inventory_hostname) }},user/{{ item.runner_user | default(operations_platform_user) | default('platform') }},{{ item.runner_labels | default('') }}"
item_runner_api_token: "{{ item.api_token | default(operations_github_api_token) }}"

- name: Ensure target directory {{ item_runner_path | dirname }} exists
file:
state: directory
path: "{{ item_runner_path | dirname }}"

- name: Copy GitHub Runner
# It will fail if a job is running.
ignore_errors: true
Expand Down Expand Up @@ -50,7 +55,7 @@
failed_when:
- "'token' not in github_runner_registration_token"

- name: "{{ item_runner_repo }} | Remove existing GitHub Runner"
- name: "{{ item_runner_repo }} | Remove existing GitHub Runner from {{ item_runner_path }}"
shell:
cmd: "./svc.sh uninstall"
chdir: "{{ item_runner_path }}"
Expand All @@ -68,7 +73,7 @@
shell:
cmd: |
whoami
./svc.sh install {{ item_runner_user }}
./svc.sh install {{ item_runner_user }}
./svc.sh start
chdir: "{{ item_runner_path }}"
become: true

0 comments on commit 77efb58

Please sign in to comment.