Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop to Master #220

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,26 @@
roles:
- robertdebock.epel
- monolithprojects.github_actions_runner

# Run the playbook again with different labels to test
- name: Dev test playbook second run
user: ansible
hosts: all
gather_facts: yes
become: yes
vars:
runner_user: ansible
github_repo: "{{ lookup('env', 'GITHUB_REPO') }}"
github_account: "{{ lookup('env', 'GITHUB_ACCOUNT') }}"
runner_version: "latest"
runner_name: test_name
runner_on_ghes: yes
reinstall_runner: false
hide_sensitive_logs: no
runner_labels:
- label1
- repo-runner
- label2
roles:
- robertdebock.epel
- monolithprojects.github_actions_runner
4 changes: 2 additions & 2 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@

- name: Check Labels (skipped if labels are OK)
ansible.builtin.fail:
msg: Woops some labels differ "{{ (registered_runners.json.runners.0 | json_query('labels[*].name') | difference(['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner'])) }}"
when: not (registered_runners.json.runners.0 | json_query('labels[*].name') | list ) == (['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner'] | list)
msg: Woops some labels differ "{{ (registered_runners.json.runners.0 | json_query('labels[*].name') | difference(['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner', 'label2'])) }}"
when: not (registered_runners.json.runners.0 | json_query('labels[*].name') | list ) == (['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner', 'label2'] | list)
19 changes: 19 additions & 0 deletions molecule/repo/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,22 @@
roles:
- robertdebock.epel
- monolithprojects.github_actions_runner

# Run the playbook again with different labels to test
- name: Update Repo runner
user: ansible
hosts: all
gather_facts: yes
become: yes
vars:
runner_user: ansible
github_repo: "{{ lookup('env', 'GITHUB_REPO') }}"
github_account: "{{ lookup('env', 'GITHUB_ACCOUNT') }}"
runner_version: "latest"
runner_labels:
- label1
- repo-runner
- label2
roles:
- robertdebock.epel
- monolithprojects.github_actions_runner
4 changes: 2 additions & 2 deletions molecule/repo/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@

- name: Check Labels (skipped if labels are OK)
ansible.builtin.fail:
msg: Woops some labels differ "{{ (registered_runners.json.runners.0 | json_query('labels[*].name') | difference(['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner'])) }}"
when: not (registered_runners.json.runners.0 | json_query('labels[*].name') | list ) == (['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner'] | list)
msg: Woops some labels differ "{{ (registered_runners.json.runners.0 | json_query('labels[*].name') | difference(['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner', 'label2'])) }}"
when: not (registered_runners.json.runners.0 | json_query('labels[*].name') | list ) == (['self-hosted', 'Linux', 'X64', 'label1', 'repo-runner', 'label2'] | list)
19 changes: 19 additions & 0 deletions tasks/install_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@
no_log: "{{ hide_sensitive_logs | bool }}"
when: runner_name not in registered_runners.json.runners|map(attribute='name')|list

- name: Update runner labels if changed
ansible.builtin.uri:
url: "{{ github_full_api_url }}/{{ (registered_runners.json.runners | selectattr('name', 'equalto', runner_name) | first).id }}/labels"
headers:
Authorization: "Bearer {{ access_token }}"
Accept: "application/vnd.github+json"
method: PUT
body_format: json
body:
labels: "{{ runner_labels }}"
status_code: 200
force_basic_auth: true
when:
- runner_name in registered_runners.json.runners|map(attribute='name')|list
- (runner_labels | sort) != (registered_runners.json.runners | selectattr('name', 'equalto', runner_name) | first).labels |
selectattr('type', 'equalto', 'custom') |
map(attribute='name') |
list

- name: Replace registered runner # noqa no-changed-when
environment:
RUNNER_ALLOW_RUNASROOT: "1"
Expand Down
Loading