Skip to content

Commit

Permalink
Merge pull request #197 from vpro/feature/196-azure-cache-support
Browse files Browse the repository at this point in the history
Add support for Azure cache.
  • Loading branch information
riemers authored Aug 4, 2021
2 parents 1c47ed7 + fe6bcb7 commit ddf5cf1
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ On Linux, use `gitlab_runner_package_version` instead.
See the [`defaults/main.yml`](https://github.com/riemers/ansible-gitlab-runner/blob/master/defaults/main.yml) file listing all possible options which you can be passed to a runner registration command.

### Gitlab Runners cache
For each gitlab runner in gitlab_runner_runners you can set cache options. At the moment role support s3 or gcs types.
For each gitlab runner in gitlab_runner_runners you can set cache options. At the moment role support s3, azure and gcs types.
Example configurration for s3 can be:
```yaml
gitlab_runner:
Expand Down
12 changes: 12 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ gitlab_runner_runners:
# Cache GCS Private Key
# cache_gcs_private_key: "-----BEGIN PRIVATE KEY-----\nXXXXXX\n-----END PRIVATE KEY-----\n"
#
# Cache azure account name
# cache_azure_account_name: "<AZURE STORAGE ACCOUNT NAME>"
#
# Cache azure account key
# cache_azure_account_key: "<AZURE STORAGE ACCOUNT KEY>"
#
# Cache azure container name
# cache_azure_container_name: "runners-cache"
#
# Cache azure storage domain
# cache_azure_storage_domain: "blob.core.windows.net"
#
# Builds directory
# builds_dir: '/builds_dir'
#
Expand Down
66 changes: 66 additions & 0 deletions tasks/update-config-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,19 @@
- restart_gitlab_runner
- restart_gitlab_runner_macos

- name: Set cache azure section
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*\[runners\.cache\.azure\]'
line: ' [runners.cache.azure]'
state: "{{ 'present' if gitlab_runner.cache_type is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos

- name: Set cache type option
lineinfile:
dest: "{{ temp_runner_config.path }}"
Expand Down Expand Up @@ -520,6 +533,59 @@
- restart_gitlab_runner
- restart_gitlab_runner_macos

#### [runners.cache.azure] section ####
- name: Set cache azure account name
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*AccountName ='
line: ' AccountName = {{ gitlab_runner.cache_azure_account_name|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_azure_account_name is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.azure\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos

- name: Set cache azure account key
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*AccountKey ='
line: ' AccountKey = {{ gitlab_runner.cache_azure_account_key|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_azure_account_key is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.azure\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos

- name: Set cache azure container name
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*ContainerName ='
line: ' ContainerName = {{ gitlab_runner.cache_azure_container_name|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_azure_container_name is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.azure\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos

- name: Set cache azure storage domain
lineinfile:
dest: "{{ temp_runner_config.path }}"
regexp: '^\s*StorageDomain ='
line: ' StorageDomain = {{ gitlab_runner.cache_azure_storage_domain|default("") | to_json }}'
state: "{{ 'present' if gitlab_runner.cache_azure_storage_domain is defined else 'absent' }}"
insertafter: '^\s*\[runners\.cache\.azure\]'
backrefs: no
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos

#### [runners.ssh] section #####
- name: Set ssh user option
lineinfile:
Expand Down

0 comments on commit ddf5cf1

Please sign in to comment.