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

Use ansible facts #177

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ runner_download_repository: "actions/runner"
runner_extra_config_args: ""

# Name to assign to this runner in GitHub (System hostname as default)
runner_name: "{{ ansible_hostname }}"
runner_name: "{{ ansible_facts.hostname }}"

# GitHub Repository user or Organization owner used for Runner registration
# github_account: "youruser"
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ runner_download_repository: "actions/runner"
runner_extra_config_args: ""

# Name to assign to this runner in GitHub (System hostname as default)
runner_name: "{{ ansible_hostname }}"
runner_name: "{{ ansible_facts.hostname }}"

# GitHub Repository user or Organization owner used for Runner registration
# github_account: "youruser"
Expand Down
2 changes: 1 addition & 1 deletion molecule/org/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- runner_org: yes
- github_api_url: "https://api.github.com"
- access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
- runner_name: "{{ ansible_hostname }}"
- runner_name: "{{ ansible_facts.hostname }}"

tasks:
- name: Give the runners a minute
Expand Down
2 changes: 1 addition & 1 deletion molecule/repo/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- github_account: monolithprojects-testorg
- github_api_url: "https://api.github.com"
- access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}"
- runner_name: "{{ ansible_hostname }}"
- runner_name: "{{ ansible_facts.hostname }}"

tasks:
- name: Give the runners some time
Expand Down
4 changes: 2 additions & 2 deletions tasks/collect_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

- name: Set runner_system variable
ansible.builtin.set_fact:
runner_system: "{{ 'osx' if ansible_system == 'Darwin' else 'linux' }}"
runner_system: "{{ 'osx' if ansible_facts.system == 'Darwin' else 'linux' }}"

- name: Find the latest runner version (RUN ONCE)
ansible.builtin.uri:
Expand All @@ -74,4 +74,4 @@
- name: Get systemd service facts
ansible.builtin.service_facts:
register: service_facts
when: ansible_system == "Linux"
when: ansible_facts.system == "Linux"
24 changes: 12 additions & 12 deletions tasks/install_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- libicu57
state: present
update_cache: true
when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "9")
when: (ansible_facts.distribution == "Debian" and ansible_facts.distribution_major_version == "9")

- name: Install dependencies on Debian Buster
ansible.builtin.package:
Expand All @@ -24,7 +24,7 @@
- libicu63
state: present
update_cache: true
when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "10")
when: (ansible_facts.distribution == "Debian" and ansible_facts.distribution_major_version == "10")

- name: Install dependencies on Debian Bullseye
ansible.builtin.package:
Expand All @@ -37,7 +37,7 @@
- libicu67
state: present
update_cache: true
when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "11")
when: (ansible_facts.distribution == "Debian" and ansible_facts.distribution_major_version == "11")

- name: Install dependencies on Debian Bookworm
ansible.builtin.package:
Expand All @@ -50,7 +50,7 @@
- libicu72
state: present
update_cache: true
when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "12")
when: (ansible_facts.distribution == "Debian" and ansible_facts.distribution_major_version == "12")

- name: Install dependencies on Ubuntu Xenial systems
ansible.builtin.package:
Expand All @@ -63,7 +63,7 @@
- libicu55
state: present
update_cache: true
when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "16")
when: (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version == "16")

- name: Install dependencies on Ubuntu Bionic systems
ansible.builtin.package:
Expand All @@ -76,7 +76,7 @@
- libicu60
state: present
update_cache: true
when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "18")
when: (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version == "18")

- name: Install dependencies on Ubuntu Focal systems
ansible.builtin.package:
Expand All @@ -89,7 +89,7 @@
- libicu66
state: present
update_cache: true
when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "20")
when: (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version == "20")

- name: Install dependencies on Ubuntu Jammy systems
ansible.builtin.package:
Expand All @@ -101,7 +101,7 @@
- libicu70
state: present
update_cache: true
when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "22")
when: (ansible_facts.distribution == "Ubuntu" and ansible_facts.distribution_major_version == "22")

- name: Install dependencies on RHEL/CentOS/Fedora systems
ansible.builtin.package:
Expand All @@ -113,7 +113,7 @@
- libicu
state: present
update_cache: true
when: (ansible_distribution == "RedHat") or
(ansible_distribution == "CentOS") or
(ansible_distribution == "Fedora") or
(ansible_distribution == "Rocky")
when: (ansible_facts.distribution == "RedHat") or
(ansible_facts.distribution == "CentOS") or
(ansible_facts.distribution == "Fedora") or
(ansible_facts.distribution == "Rocky")
10 changes: 5 additions & 5 deletions tasks/install_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
remote_src: true
mode: "0755"
environment:
PATH: /usr/local/bin:/opt/homebrew/bin/:{{ ansible_env.HOME }}/bin:{{ ansible_env.PATH }}
PATH: /usr/local/bin:/opt/homebrew/bin/:{{ ansible_facts.user_dir }}/bin:{{ ansible_facts.env.PATH }}
when: runner_version not in runner_installed.stdout or reinstall_runner

- name: Configure custom env file if required
Expand Down Expand Up @@ -109,7 +109,7 @@
args:
chdir: "{{ runner_dir }}"
changed_when: true
become: "{{ 'false' if ansible_system == 'Darwin' else 'true' }}"
become: "{{ 'false' if ansible_facts.system == 'Darwin' else 'true' }}"
when: not runner_service_file_path.stat.exists

- name: Read service name from file
Expand All @@ -125,7 +125,7 @@
ignore_errors: "{{ ansible_check_mode }}"
changed_when: true
when: >
ansible_system != 'Darwin' and
ansible_facts.system != 'Darwin' and
runner_state|lower == "started" and
ansible_facts.services[(runner_service.content | b64decode) | trim ]['state'] != 'running'

Expand All @@ -137,7 +137,7 @@
no_log: "{{ hide_sensitive_logs | bool }}"
ignore_errors: "{{ ansible_check_mode }}"
changed_when: true
when: ansible_system == 'Darwin' and runner_state|lower
when: ansible_facts.system == 'Darwin' and runner_state|lower

- name: STOP and disable Github Actions Runner service
ansible.builtin.command: "./svc.sh stop"
Expand All @@ -154,7 +154,7 @@
args:
chdir: "{{ runner_dir }}"
changed_when: true
become: "{{ 'false' if ansible_system == 'Darwin' else 'true' }}"
become: "{{ 'false' if ansible_facts.system == 'Darwin' else 'true' }}"
no_log: "{{ hide_sensitive_logs | bool }}"
ignore_errors: "{{ ansible_check_mode }}"
when: runner_version not in runner_installed.stdout and not runner_state|lower == "stopped"
2 changes: 1 addition & 1 deletion tasks/uninstall_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
args:
chdir: "{{ runner_dir }}"
changed_when: true
become: "{{ 'false' if ansible_system == 'Darwin' else 'true' }}"
become: "{{ 'false' if ansible_facts.system == 'Darwin' else 'true' }}"
when: runner_service_file_path.stat.exists

- name: Check GitHub Actions runner file
Expand Down
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ github_actions_architecture_map:
x86_64: x64
armv7l: arm
aarch64: arm64
github_actions_architecture: "{{ github_actions_architecture_map[ansible_architecture] }}"
github_actions_architecture: "{{ github_actions_architecture_map[ansible_facts.architecture] }}"
Loading