Skip to content

Commit

Permalink
Merge pull request #253 from TankerHQ/hugo/macos-arm-installation
Browse files Browse the repository at this point in the history
Hugo/macos arm installation
  • Loading branch information
riemers committed Feb 28, 2023
2 parents 4f29720 + 30bdf06 commit 30a5ac5
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 70 deletions.
50 changes: 25 additions & 25 deletions tasks/config-runners-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,33 @@
- name: (Windows) Assemble new config.toml
when: not ansible_check_mode
block:
- name: (Windows) Create temporary file config.toml
win_tempfile:
state: file
suffix: temp
register: config_toml_temp
- name: (Windows) Create temporary file config.toml
win_tempfile:
state: file
suffix: temp
register: config_toml_temp

- name: (Windows) Write global config to file
win_lineinfile:
insertbefore: BOF
path: "{{ config_toml_temp.path }}"
line: "{{ runner_global_config }}"
- name: (Windows) Write global config to file
win_lineinfile:
insertbefore: BOF
path: "{{ config_toml_temp.path }}"
line: "{{ runner_global_config }}"

- name: (Windows) Create temporary file runners-config.toml
win_tempfile:
state: file
suffix: temp
register: runners_config_toml_temp
- name: (Windows) Create temporary file runners-config.toml
win_tempfile:
state: file
suffix: temp
register: runners_config_toml_temp

- name: (Windows) Assemble runners files in config dir
win_shell: dir -rec | gc | out-file "{{ runners_config_toml_temp.path }}"
args:
chdir: "{{ temp_runner_config_dir.path }}"
- name: (Windows) Assemble runners files in config dir
win_shell: dir -rec | gc | out-file "{{ runners_config_toml_temp.path }}"
args:
chdir: "{{ temp_runner_config_dir.path }}"

- name: (Windows) Assemble new config.toml
win_shell: gc "{{ config_toml_temp.path }}","{{ runners_config_toml_temp.path }}" | Set-Content "{{ gitlab_runner_config_file }}"
- name: (Windows) Assemble new config.toml
win_shell: gc "{{ config_toml_temp.path }}","{{ runners_config_toml_temp.path }}" | Set-Content "{{ gitlab_runner_config_file }}"

- name: (Windows) Verify config
win_command: "{{ gitlab_runner_executable }} verify"
args:
chdir: "{{ gitlab_runner_config_file_location }}"
- name: (Windows) Verify config
win_command: "{{ gitlab_runner_executable }} verify"
args:
chdir: "{{ gitlab_runner_config_file_location }}"
1 change: 1 addition & 0 deletions tasks/install-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
when: gitlab_runner_package_version is not defined

- name: (Debian) Unhold GitLab Runner version
changed_when: false
dpkg_selections:
name: "{{ gitlab_runner_package_name }}"
selection: install
Expand Down
62 changes: 34 additions & 28 deletions tasks/install-macos.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
- name: (MacOS) PRE-CHECK GitLab Runner exists
block:
- name: (MacOS) Check gitlab-runner executable exists
stat:
path: "{{ gitlab_runner_executable }}"
register: gitlab_runner_exists
- name: (MacOS) Check gitlab-runner executable exists
stat:
path: "{{ gitlab_runner_executable }}"
register: gitlab_runner_exists

- name: (MacOS) Set fact -> gitlab_runner_exists
set_fact:
gitlab_runner_exists: "{{ gitlab_runner_exists.stat.exists }}"

- name: (MacOS) Set fact -> gitlab_runner_exists
set_fact:
gitlab_runner_exists: "{{ gitlab_runner_exists.stat.exists }}"
- name: (MacOS) Get existing version
shell: "{{ gitlab_runner_executable }} --version | awk '/Version: ([\\d\\.]*)/{print $2}'"
register: existing_version_shell
failed_when: no
check_mode: no
changed_when: no

- name: (MacOS) Get existing version
shell: "{{ gitlab_runner_executable }} --version | awk '/Version: ([\\d\\.]*)/{print $2}'"
register: existing_version_shell
failed_when: no
check_mode: no
changed_when: no
- name: (MacOS) Set fact -> gitlab_runner_existing_version
set_fact:
gitlab_runner_existing_version: "{{ existing_version_shell.stdout if existing_version_shell.rc == 0 else '0' }}"

- name: (MacOS) Set fact -> gitlab_runner_existing_version
set_fact:
gitlab_runner_existing_version: "{{ existing_version_shell.stdout if existing_version_shell.rc == 0 else '0' }}"
- name: (MacOS) Precreate necessary directories for arm64 architecture
block:
- name: (MacOS) Precreate gitlab-runner log directory
become: yes
file:
path: /usr/local/var/log
state: directory
owner: "{{ ansible_user_id | string }}"

- name: (MacOS) Precreate {{ gitlab_runner_directory }} directory
become: yes
file:
mode: "755"
owner: "root"
path: "{{ gitlab_runner_directory }}"
state: "directory"

- name: (MacOS) Precreate gitlab-runner log directory
become: yes
file:
path: /usr/local/var/log
state: directory
owner: "{{ ansible_user_id | string }}"
when: gitlab_runner_arch == 'arm64'

- name: (MacOS) INSTALL GitLab Runner for macOS
block:
- name: (MacOS) Download GitLab Runner
become: true
get_url:
url: "{{ gitlab_runner_download_url }}"
dest: "{{ gitlab_runner_executable }}"
force: yes

- name: (MacOS) Setting Permissions for gitlab-runner executable
file:
path: "{{ gitlab_runner_executable }}"
owner: "{{ ansible_user_id | string }}"
group: "{{ ansible_user_gid | string }}"
mode: '+x'

- name: (MacOS) Install GitLab Runner
Expand Down
32 changes: 16 additions & 16 deletions tasks/install-windows.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
- name: (Windows) PRE-CHECK GitLab Runner exists
block:
- name: (Windows) Check gitlab-runner executable exists
win_stat:
path: "{{ gitlab_runner_executable }}"
register: gitlab_runner_exists
- name: (Windows) Check gitlab-runner executable exists
win_stat:
path: "{{ gitlab_runner_executable }}"
register: gitlab_runner_exists

- name: (Windows) Set fact -> gitlab_runner_exists
set_fact:
gitlab_runner_exists: "{{ gitlab_runner_exists.stat.exists }}"
- name: (Windows) Set fact -> gitlab_runner_exists
set_fact:
gitlab_runner_exists: "{{ gitlab_runner_exists.stat.exists }}"

- name: (Windows) Get existing version
win_shell: "{{ gitlab_runner_executable }} --version | Select-String 'Version:' -CaseSensitive | %{ $_.Line.Split(' ')[-1].Trim(); }"
register: existing_version_shell
failed_when: no
check_mode: no
changed_when: no
- name: (Windows) Get existing version
win_shell: "{{ gitlab_runner_executable }} --version | Select-String 'Version:' -CaseSensitive | %{ $_.Line.Split(' ')[-1].Trim(); }"
register: existing_version_shell
failed_when: no
check_mode: no
changed_when: no

- name: (Windows) Set fact -> gitlab_runner_existing_version
set_fact:
gitlab_runner_existing_version: "{{ existing_version_shell.stdout | trim if existing_version_shell.rc == 0 else '0' }}"
- name: (Windows) Set fact -> gitlab_runner_existing_version
set_fact:
gitlab_runner_existing_version: "{{ existing_version_shell.stdout | trim if existing_version_shell.rc == 0 else '0' }}"

- name: (Windows) INSTALL GitLab Runner for Windows
block:
Expand Down
3 changes: 2 additions & 1 deletion vars/Darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ gitlab_runner_arch: "{{ (ansible_machine == 'arm64') | ternary('arm64', 'amd64')

gitlab_runner_download_url: 'https://gitlab-runner-downloads.s3.amazonaws.com/{{ gitlab_runner_wanted_tag }}/binaries/gitlab-runner-darwin-{{ gitlab_runner_arch }}'

gitlab_runner_executable: "{{ (ansible_machine == 'arm64') | ternary('/opt/homebrew', '/usr/local') }}/bin/{{ gitlab_runner_package_name }}"
gitlab_runner_directory: "/usr/local/bin"
gitlab_runner_executable: "{{ gitlab_runner_directory }}/{{ gitlab_runner_package_name }}"

0 comments on commit 30a5ac5

Please sign in to comment.