From fe6c5945ffd81062a0971b54e7a8ad4af412c2e7 Mon Sep 17 00:00:00 2001 From: guenhter Date: Sat, 7 Oct 2023 11:49:14 +0200 Subject: [PATCH] Fix some easy linter findings --- .github/workflows/stale.yml | 12 +- .travis.yml | 3 +- defaults/main.yml | 42 +- handlers/main.yml | 4 +- meta/main.yml | 31 +- tasks/config-runner-container.yml | 6 +- tasks/config-runner-windows.yml | 12 +- tasks/config-runner.yml | 7 +- tasks/config-runners-container.yml | 8 +- tasks/config-runners-windows.yml | 2 +- tasks/config-runners.yml | 8 +- tasks/global-setup-windows.yml | 34 +- tasks/global-setup.yml | 40 +- tasks/install-arch.yml | 3 +- tasks/install-debian.yml | 10 +- tasks/install-macos.yml | 25 +- tasks/install-redhat.yml | 11 +- tasks/install-windows.yml | 16 +- tasks/line-config-runner-windows.yml | 18 +- tasks/line-config-runner.yml | 12 +- tasks/list-configured-runners-container.yml | 13 +- tasks/list-configured-runners-unix.yml | 5 +- tasks/list-configured-runners-windows.yml | 5 +- tasks/main-container.yml | 22 +- tasks/main-unix.yml | 3 +- tasks/main-windows.yml | 4 +- tasks/main.yml | 8 +- tasks/register-runner-container.yml | 15 +- tasks/register-runner-windows.yml | 3 +- tasks/register-runner.yml | 7 +- tasks/systemd-reload.yml | 15 +- ...gister-runner-if-not-longer-configured.yml | 2 +- tasks/unregister-runner.yml | 26 +- tasks/update-ca-bundle.yml | 3 +- tasks/update-config-runner-windows.yml | 357 ++++--- tasks/update-config-runner.yml | 935 +++++++++--------- tests/test.yml | 18 +- tests/vars/Windows.yml | 19 +- tests/vars/default.yml | 29 +- vars/Archlinux.yml | 2 +- vars/Darwin.yml | 4 +- vars/Debian.yml | 2 +- vars/RedHat.yml | 2 +- vars/Windows.yml | 8 +- vars/main.yml | 4 +- 45 files changed, 903 insertions(+), 912 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index c0c055e..220e271 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,13 +1,14 @@ +--- # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. # # You can adjust the behavior by modifying this file. # For more information, see: # https://github.com/actions/stale -name: 'Close stale issues and PRs' -on: +name: Close stale issues and PRs +true: schedule: - - cron: '30 1 * * *' + - cron: 30 1 * * * jobs: stale: @@ -15,8 +16,9 @@ jobs: steps: - uses: actions/stale@v8 with: - stale-issue-message: 'Seems this message did not get a lot of love. This does not mean it was not seen but time wise might not have made it to proper attention. This is just the clean up action ;)' - stale-pr-message: 'Although PRs are appreciated, if it sits for too long nothing happens. Can always update and do again :) This is just the automation talking' + stale-issue-message: Seems this message did not get a lot of love. This does not mean it was not seen but time wise might not have made it to proper attention. + This is just the clean up action ;) + stale-pr-message: Although PRs are appreciated, if it sits for too long nothing happens. Can always update and do again :) This is just the automation talking days-before-issue-stale: 30 days-before-pr-stale: 45 days-before-issue-close: 5 diff --git a/.travis.yml b/.travis.yml index 1710081..1989d34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,6 +59,7 @@ jobs: - cd ../../ - wsl ansible-playbook test.yml -i inventory --syntax-check # Running tests - - wsl ansible-playbook test.yml -i inventory --extra-vars 'ansible_user=ansible ansible_password=Ans1ble_User! ansible_connection=winrm ansible_winrm_server_cert_validation=ignore ansible_ssh_port=5986' + - wsl ansible-playbook test.yml -i inventory --extra-vars 'ansible_user=ansible ansible_password=Ans1ble_User! ansible_connection=winrm ansible_winrm_server_cert_validation=ignore + ansible_ssh_port=5986' notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/defaults/main.yml b/defaults/main.yml index 341f969..1baefb6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,8 +1,8 @@ --- # for versions >= 10.x -gitlab_runner_package_name: 'gitlab-runner' +gitlab_runner_package_name: gitlab-runner -gitlab_runner_system_mode: yes +gitlab_runner_system_mode: true # gitlab_runner_package_version for version pinning on debian/redhat # The following are for version pinning on MacOSX @@ -17,27 +17,27 @@ gitlab_runner_config_file_location: "{{ gitlab_runner_config_file | dirname }}" gitlab_runner_executable: "{{ gitlab_runner_package_name }}" # Maximum number of global jobs to run concurrently -gitlab_runner_concurrent: '{{ ansible_processor_vcpus }}' +gitlab_runner_concurrent: "{{ ansible_processor_vcpus }}" # GitLab coordinator URL -gitlab_runner_coordinator_url: 'https://gitlab.com' +gitlab_runner_coordinator_url: https://gitlab.com # GitLab registration token -gitlab_runner_registration_token: '' +gitlab_runner_registration_token: "" -gitlab_runner_sentry_dsn: '' +gitlab_runner_sentry_dsn: "" # GitLab server IP -gitlab_server_ip: '' +gitlab_server_ip: "" # GitLab TLS CA file -tls_ca_file: '' +tls_ca_file: "" # Prometheus Metrics & Monitoring -gitlab_runner_listen_address: '' +gitlab_runner_listen_address: "" # Session server configuration -gitlab_runner_session_server_listen_address: '' -gitlab_runner_session_server_advertise_address: '' +gitlab_runner_session_server_listen_address: "" +gitlab_runner_session_server_advertise_address: "" gitlab_runner_session_server_session_timeout: 1800 # Skip the APT or YUM repository installation @@ -51,8 +51,8 @@ gitlab_unregister_runner_executors_which_are_not_longer_configured: false # The credentials for the Windows user used to run the gitlab-runner service. # Those credentials will be passed to `gitlab-runner.exe install`. # https://docs.gitlab.com/runner/install/windows.html -gitlab_runner_windows_service_user: '' -gitlab_runner_windows_service_password: '' +gitlab_runner_windows_service_user: "" +gitlab_runner_windows_service_password: "" # Whether to try to start the runner on MacOS. # If set to `false`, it should be started manually. @@ -68,7 +68,7 @@ gitlab_runner_container_install: false gitlab_runner_container_image: gitlab/gitlab-runner gitlab_runner_container_tag: latest gitlab_runner_container_name: gitlab-runner -gitlab_runner_container_mount_path: '' +gitlab_runner_container_mount_path: "" gitlab_runner_container_restart_policy: unless-stopped gitlab_runner_container_latest_update: false # you can define a network which the container connects to @@ -85,26 +85,26 @@ gitlab_runner_restart_state: restarted force_accept_gitlab_server_self_signed: false # controls diffs for assemble config file -gitlab_runner_show_config_diff: no +gitlab_runner_show_config_diff: false # controls logs on ansible configuration tasks, uncomment to prevent secret leaks (Unix support only). # gitlab_runner_no_log_secrets: yes # A list of runners to register and configure gitlab_runner_runners: - # The identifier of the runner. - - name: '{{ ansible_hostname }}' + # The identifier of the runner. + - name: "{{ ansible_hostname }}" # set to 'absent' if you want to delete the runner. Defaults to 'present'. state: present # The executor used by the runner. - executor: 'shell' + executor: shell # Set maximum build log size in kilobytes. output_limit: 4096 # Maximum number of jobs to run concurrently on this specific runner. # Defaults to 0, simply means don't limit. - concurrent_specific: '0' + concurrent_specific: "0" # The default Docker image to use. Required when executor is `docker`. - docker_image: '' + docker_image: "" # Set to override the default helper image that is used. # docker_helper_image: 'gitlab/gitlab-runner-helper-linux:latest' # @@ -117,7 +117,7 @@ gitlab_runner_runners: # Docker privileged mode docker_privileged: false # Runner Locked. When a runner is locked, it cannot be assigned to other projects - locked: 'false' + locked: "false" # Add container to a custom network docker_network_mode: bridge # Change the services startup timeout diff --git a/handlers/main.yml b/handlers/main.yml index a051908..8835c70 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -2,7 +2,7 @@ # non macOS - name: restart_gitlab_runner service: name=gitlab-runner state={{ gitlab_runner_restart_state }} - become: yes + become: true when: ansible_os_family != 'Darwin' and ansible_os_family != 'Windows' and not gitlab_runner_container_install # macOS @@ -21,5 +21,5 @@ - name: restart_gitlab_runner_container docker_container: name: "{{ gitlab_runner_container_name }}" - restart: yes + restart: true when: gitlab_runner_container_install diff --git a/meta/main.yml b/meta/main.yml index 012b764..ef3f21f 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,25 +1,26 @@ --- galaxy_info: author: Erik-jan Riemers + namespace: riemers description: GitLab Runner license: MIT min_ansible_version: 2.7 platforms: - - name: EL - versions: - - all - - name: Ubuntu - versions: - - all - - name: Debian - version: - - all - - name: MacOSX - versions: - - all - - name: Windows - versions: - - all + - name: EL + versions: + - all + - name: Ubuntu + versions: + - all + - name: Debian + version: + - all + - name: MacOSX + versions: + - all + - name: Windows + versions: + - all galaxy_tags: - gitlab - runner diff --git a/tasks/config-runner-container.yml b/tasks/config-runner-container.yml index bf3419b..9fc4693 100644 --- a/tasks/config-runner-container.yml +++ b/tasks/config-runner-container.yml @@ -3,16 +3,16 @@ tempfile: state: file path: "{{ temp_runner_config_dir.path }}" - prefix: "gitlab-runner.{{ runner_config_index }}." + prefix: gitlab-runner.{{ runner_config_index }}. register: temp_runner_config - check_mode: no + check_mode: false changed_when: false - name: "{{ conf_name_prefix }} Isolate runner configuration" copy: dest: "{{ temp_runner_config.path }}" content: "{{ runner_config }}" - check_mode: no + check_mode: false changed_when: false - include_tasks: update-config-runner.yml diff --git a/tasks/config-runner-windows.yml b/tasks/config-runner-windows.yml index 1ba9e8e..1805eff 100644 --- a/tasks/config-runner-windows.yml +++ b/tasks/config-runner-windows.yml @@ -1,18 +1,18 @@ --- -- name: "(Windows) {{ conf_name_prefix }} Create temporary file" +- name: (Windows) {{ conf_name_prefix }} Create temporary file win_tempfile: state: file path: "{{ temp_runner_config_dir.path }}" - prefix: "gitlab-runner.{{ runner_config_index }}." + prefix: gitlab-runner.{{ runner_config_index }}. register: temp_runner_config - check_mode: no + check_mode: false changed_when: false -- name: "(Windows) {{ conf_name_prefix }} Isolate runner configuration" +- name: (Windows) {{ conf_name_prefix }} Isolate runner configuration win_copy: dest: "{{ temp_runner_config.path }}" content: "{{ runner_config }}" - check_mode: no + check_mode: false changed_when: false - include_tasks: update-config-runner-windows.yml @@ -26,7 +26,7 @@ index_var: gitlab_runner_index loop_var: gitlab_runner -- name: "(Windows) {{ conf_name_prefix }} Remove runner config" +- name: (Windows) {{ conf_name_prefix }} Remove runner config win_file: path: "{{ temp_runner_config.path }}" state: absent diff --git a/tasks/config-runner.yml b/tasks/config-runner.yml index 8bc51dc..3df6cef 100644 --- a/tasks/config-runner.yml +++ b/tasks/config-runner.yml @@ -1,19 +1,18 @@ --- - - name: "{{ conf_name_prefix }} Create temporary file" tempfile: state: file path: "{{ temp_runner_config_dir.path }}" - prefix: "gitlab-runner.{{ runner_config_index }}." + prefix: gitlab-runner.{{ runner_config_index }}. register: temp_runner_config - check_mode: no + check_mode: false changed_when: false - name: "{{ conf_name_prefix }} Isolate runner configuration" copy: dest: "{{ temp_runner_config.path }}" content: "{{ runner_config }}" - check_mode: no + check_mode: false changed_when: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" diff --git a/tasks/config-runners-container.yml b/tasks/config-runners-container.yml index 230088d..f0b0479 100644 --- a/tasks/config-runners-container.yml +++ b/tasks/config-runners-container.yml @@ -13,7 +13,7 @@ state: directory suffix: gitlab-runner-config register: temp_runner_config_dir - check_mode: no + check_mode: false changed_when: false - name: Write config section for each runner @@ -29,10 +29,10 @@ assemble: src: "{{ temp_runner_config_dir.path }}" dest: "{{ gitlab_runner_config_file }}" - delimiter: '[[runners]]\n' - backup: yes + delimiter: "[[runners]]\\n" + backup: true validate: | docker run -i --rm -v %s:/gitlab-runner.conf {{ gitlab_runner_container_image }}:{{ gitlab_runner_container_tag }} verify -c /gitlab-runner.conf - mode: 0600 + mode: "0600" diff --git a/tasks/config-runners-windows.yml b/tasks/config-runners-windows.yml index 959657c..e3522e5 100644 --- a/tasks/config-runners-windows.yml +++ b/tasks/config-runners-windows.yml @@ -17,7 +17,7 @@ state: directory suffix: gitlab-runner-config register: temp_runner_config_dir - check_mode: no + check_mode: false changed_when: false - name: (Windows) Write config section for each runner diff --git a/tasks/config-runners.yml b/tasks/config-runners.yml index ee219a6..1054eed 100644 --- a/tasks/config-runners.yml +++ b/tasks/config-runners.yml @@ -15,7 +15,7 @@ state: directory suffix: gitlab-runner-config register: temp_runner_config_dir - check_mode: no + check_mode: false changed_when: false - name: Write config section for each runner @@ -32,9 +32,9 @@ assemble: src: "{{ temp_runner_config_dir.path }}" dest: "{{ gitlab_runner_config_file }}" - delimiter: '[[runners]]\n' - backup: yes + delimiter: "[[runners]]\\n" + backup: true validate: "{{ gitlab_runner_executable }} verify -c %s" - mode: 0600 + mode: "0600" become: "{{ gitlab_runner_system_mode }}" diff: "{{ gitlab_runner_show_config_diff|bool }}" diff --git a/tasks/global-setup-windows.yml b/tasks/global-setup-windows.yml index 0d4d677..50fdcb1 100644 --- a/tasks/global-setup-windows.yml +++ b/tasks/global-setup-windows.yml @@ -14,10 +14,10 @@ - name: (Windows) Set concurrent option win_lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^(\s*)concurrent =.*' - line: '$1concurrent = {{ gitlab_runner_concurrent }}' + regexp: ^(\s*)concurrent =.* + line: $1concurrent = {{ gitlab_runner_concurrent }} state: present - backrefs: yes + backrefs: true notify: - restart_gitlab_runner - restart_gitlab_runner_macos @@ -26,11 +26,11 @@ - name: (Windows) Add listen_address to config win_lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^listen_address =.*' - line: 'listen_address = "{{ gitlab_runner_listen_address }}"' - insertafter: '\s*concurrent.*' + regexp: ^listen_address =.* + line: listen_address = "{{ gitlab_runner_listen_address }}" + insertafter: \s*concurrent.* state: present - when: gitlab_runner_listen_address | length > 0 # Ensure value is set + when: gitlab_runner_listen_address | length > 0 # Ensure value is set notify: - restart_gitlab_runner - restart_gitlab_runner_windows @@ -38,11 +38,11 @@ - name: (Windows) Add sentry dsn to config win_lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^sentry_dsn =.*' - line: 'sentry_dsn = "{{ gitlab_runner_sentry_dsn }}"' - insertafter: '\s*concurrent.*' + regexp: ^sentry_dsn =.* + line: sentry_dsn = "{{ gitlab_runner_sentry_dsn }}" + insertafter: \s*concurrent.* state: present - when: gitlab_runner_sentry_dsn | length > 0 # Ensure value is set + when: gitlab_runner_sentry_dsn | length > 0 # Ensure value is set notify: - restart_gitlab_runner - restart_gitlab_runner_macos @@ -51,9 +51,9 @@ - name: (Windows) Add session server listen_address to config win_lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^(\s+)listen_address =' + regexp: ^(\s+)listen_address = line: ' listen_address = "{{ gitlab_runner_session_server_listen_address }}"' - insertafter: '^\s*\[session_server\]' + insertafter: ^\s*\[session_server\] state: "{{ 'present' if gitlab_runner_session_server_listen_address | length > 0 else 'absent' }}" notify: - restart_gitlab_runner @@ -63,9 +63,9 @@ - name: (Windows) Add session server advertise_address to config win_lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^\s*advertise_address =' + regexp: ^\s*advertise_address = line: ' advertise_address = "{{ gitlab_runner_session_server_advertise_address }}"' - insertafter: '^\s*\[session_server\]' + insertafter: ^\s*\[session_server\] state: "{{ 'present' if gitlab_runner_session_server_advertise_address | length > 0 else 'absent' }}" notify: - restart_gitlab_runner @@ -75,9 +75,9 @@ - name: (Windows) Add session server session_timeout to config win_lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^\s*session_timeout =' + regexp: ^\s*session_timeout = line: " session_timeout = {{ gitlab_runner_session_server_session_timeout }}" - insertafter: '^\s*\[session_server\]' + insertafter: ^\s*\[session_server\] state: present when: gitlab_runner_session_server_session_timeout notify: diff --git a/tasks/global-setup.yml b/tasks/global-setup.yml index 8a7ba44..cc279f3 100644 --- a/tasks/global-setup.yml +++ b/tasks/global-setup.yml @@ -3,7 +3,7 @@ file: path: "{{ gitlab_runner_config_file_location }}" state: directory - mode: '0700' + mode: "0700" become: "{{ gitlab_runner_system_mode }}" - name: Ensure config.toml exists @@ -17,10 +17,10 @@ - name: Set concurrent option lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^(\s*)concurrent =' - line: '\1concurrent = {{ gitlab_runner_concurrent }}' + regexp: ^(\s*)concurrent = + line: \1concurrent = {{ gitlab_runner_concurrent }} state: present - backrefs: yes + backrefs: true no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" become: "{{ gitlab_runner_system_mode }}" notify: @@ -30,12 +30,12 @@ - name: Add listen_address to config lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^listen_address =' - line: 'listen_address = "{{ gitlab_runner_listen_address }}"' - insertafter: '\s*concurrent.*' + regexp: ^listen_address = + line: listen_address = "{{ gitlab_runner_listen_address }}" + insertafter: \s*concurrent.* state: present no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" - when: gitlab_runner_listen_address | length > 0 # Ensure value is set + when: gitlab_runner_listen_address | length > 0 # Ensure value is set become: "{{ gitlab_runner_system_mode }}" notify: - restart_gitlab_runner @@ -44,8 +44,8 @@ - name: Add log_format to config lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^log_format =' - line: 'log_format = "{{ gitlab_runner_log_format|default("runner") }}"' + regexp: ^log_format = + line: log_format = "{{ gitlab_runner_log_format|default("runner") }}" insertbefore: BOF state: present no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" @@ -58,12 +58,12 @@ - name: Add sentry dsn to config lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^sentry_dsn =' - line: 'sentry_dsn = "{{ gitlab_runner_sentry_dsn }}"' - insertafter: '\s*concurrent.*' + regexp: ^sentry_dsn = + line: sentry_dsn = "{{ gitlab_runner_sentry_dsn }}" + insertafter: \s*concurrent.* state: present no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" - when: gitlab_runner_sentry_dsn | length > 0 # Ensure value is set + when: gitlab_runner_sentry_dsn | length > 0 # Ensure value is set become: "{{ gitlab_runner_system_mode }}" notify: - restart_gitlab_runner @@ -72,9 +72,9 @@ - name: Add session server listen_address to config lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^(\s+)listen_address =' + regexp: ^(\s+)listen_address = line: ' listen_address = "{{ gitlab_runner_session_server_listen_address }}"' - insertafter: '^\s*\[session_server\]' + insertafter: ^\s*\[session_server\] state: "{{ 'present' if gitlab_runner_session_server_listen_address | length > 0 else 'absent' }}" no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" become: "{{ gitlab_runner_system_mode }}" @@ -85,9 +85,9 @@ - name: Add session server advertise_address to config lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^\s*advertise_address =' + regexp: ^\s*advertise_address = line: ' advertise_address = "{{ gitlab_runner_session_server_advertise_address }}"' - insertafter: '^\s*\[session_server\]' + insertafter: ^\s*\[session_server\] state: "{{ 'present' if gitlab_runner_session_server_advertise_address | length > 0 else 'absent' }}" become: "{{ gitlab_runner_system_mode }}" no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" @@ -98,9 +98,9 @@ - name: Add session server session_timeout to config lineinfile: dest: "{{ gitlab_runner_config_file }}" - regexp: '^\s*session_timeout =' + regexp: ^\s*session_timeout = line: " session_timeout = {{ gitlab_runner_session_server_session_timeout }}" - insertafter: '^\s*\[session_server\]' + insertafter: ^\s*\[session_server\] state: present no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" when: gitlab_runner_session_server_session_timeout diff --git a/tasks/install-arch.yml b/tasks/install-arch.yml index 221c798..41073e8 100644 --- a/tasks/install-arch.yml +++ b/tasks/install-arch.yml @@ -1,9 +1,8 @@ --- - - name: (Arch) Set gitlab_runner_package_name set_fact: gitlab_runner_package: "{{ gitlab_runner_package_name }}" - gitlab_runner_package_state: "latest" + gitlab_runner_package_state: latest when: gitlab_runner_package_version is not defined - name: (Arch) Install GitLab Runner diff --git a/tasks/install-debian.yml b/tasks/install-debian.yml index bed1dc7..a041111 100644 --- a/tasks/install-debian.yml +++ b/tasks/install-debian.yml @@ -6,28 +6,28 @@ - name: (Debian) Get Gitlab repository installation script get_url: - url: "https://packages.gitlab.com/install/repositories/runner/{{ gitlab_runner_package_name }}/script.deb.sh" + url: https://packages.gitlab.com/install/repositories/runner/{{ gitlab_runner_package_name }}/script.deb.sh dest: /tmp/gitlab-runner.script.deb.sh - mode: 0744 + mode: "0744" when: gitlab_runner_skip_package_repo_install is not defined or not gitlab_runner_skip_package_repo_install - name: (Debian) Install Gitlab repository command: bash /tmp/gitlab-runner.script.deb.sh args: - creates: "/etc/apt/sources.list.d/runner_{{ gitlab_runner_package_name }}.list" + creates: /etc/apt/sources.list.d/runner_{{ gitlab_runner_package_name }}.list become: true when: gitlab_runner_skip_package_repo_install is not defined or not gitlab_runner_skip_package_repo_install - name: (Debian) Update gitlab_runner_package_name set_fact: gitlab_runner_package: "{{ gitlab_runner_package_name }}={{ gitlab_runner_package_version }}" - gitlab_runner_package_state: "present" + gitlab_runner_package_state: present when: gitlab_runner_package_version is defined - name: (Debian) Set gitlab_runner_package_name set_fact: gitlab_runner_package: "{{ gitlab_runner_package_name }}" - gitlab_runner_package_state: "latest" + gitlab_runner_package_state: latest when: gitlab_runner_package_version is not defined - name: (Debian) Unhold GitLab Runner version diff --git a/tasks/install-macos.yml b/tasks/install-macos.yml index 5b345ff..bd108e7 100644 --- a/tasks/install-macos.yml +++ b/tasks/install-macos.yml @@ -1,3 +1,4 @@ +--- - name: (MacOS) PRE-CHECK GitLab Runner exists block: - name: (MacOS) Check gitlab-runner executable exists @@ -12,9 +13,9 @@ - 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 + failed_when: false + check_mode: false + changed_when: false - name: (MacOS) Set fact -> gitlab_runner_existing_version set_fact: @@ -23,19 +24,19 @@ - name: (MacOS) Precreate necessary directories for arm64 architecture block: - name: (MacOS) Precreate gitlab-runner log directory - become: yes + become: true file: path: /usr/local/var/log state: directory owner: "{{ ansible_user_id | string }}" - name: (MacOS) Precreate {{ gitlab_runner_directory }} directory - become: yes + become: true file: mode: "755" - owner: "root" + owner: root path: "{{ gitlab_runner_directory }}" - state: "directory" + state: directory when: gitlab_runner_arch == 'arm64' @@ -46,8 +47,8 @@ get_url: url: "{{ gitlab_runner_download_url }}" dest: "{{ gitlab_runner_executable }}" - force: yes - mode: '+x' + force: true + mode: +x - name: (MacOS) Install GitLab Runner command: "{{ gitlab_runner_executable }} install" @@ -67,15 +68,15 @@ get_url: url: "{{ gitlab_runner_download_url }}" dest: "{{ gitlab_runner_executable }}" - force: yes + force: true - 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' - become: yes + mode: +x + become: true - name: (MacOS) Start GitLab Runner command: "{{ gitlab_runner_executable }} start" diff --git a/tasks/install-redhat.yml b/tasks/install-redhat.yml index 566b11b..a97c0d3 100644 --- a/tasks/install-redhat.yml +++ b/tasks/install-redhat.yml @@ -1,10 +1,9 @@ --- - - name: (RedHat) Get Gitlab repository installation script get_url: - url: "https://packages.gitlab.com/install/repositories/runner/{{ gitlab_runner_package_name }}/script.rpm.sh" + url: https://packages.gitlab.com/install/repositories/runner/{{ gitlab_runner_package_name }}/script.rpm.sh dest: /tmp/gitlab-runner.script.rpm.sh - mode: 0744 + mode: "0744" when: gitlab_runner_skip_package_repo_install is not defined or not gitlab_runner_skip_package_repo_install - name: (RedHat) Install Gitlab repository @@ -14,20 +13,20 @@ {% endif %} bash /tmp/gitlab-runner.script.rpm.sh args: - creates: "/etc/yum.repos.d/runner_{{ gitlab_runner_package_name }}.repo" + creates: /etc/yum.repos.d/runner_{{ gitlab_runner_package_name }}.repo become: true when: gitlab_runner_skip_package_repo_install is not defined or not gitlab_runner_skip_package_repo_install - name: (RedHat) Update gitlab_runner_package_name set_fact: gitlab_runner_package: "{{ gitlab_runner_package_name }}-{{ gitlab_runner_package_version }}" - gitlab_runner_package_state: "present" + gitlab_runner_package_state: present when: gitlab_runner_package_version is defined - name: (RedHat) Set gitlab_runner_package_name set_fact: gitlab_runner_package: "{{ gitlab_runner_package_name }}" - gitlab_runner_package_state: "latest" + gitlab_runner_package_state: latest when: gitlab_runner_package_version is not defined - name: (RedHat) Install GitLab Runner diff --git a/tasks/install-windows.yml b/tasks/install-windows.yml index 8ce7bd9..61d19aa 100644 --- a/tasks/install-windows.yml +++ b/tasks/install-windows.yml @@ -1,3 +1,4 @@ +--- - name: (Windows) PRE-CHECK GitLab Runner exists block: - name: (Windows) Check gitlab-runner executable exists @@ -12,9 +13,9 @@ - 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 + failed_when: false + check_mode: false + changed_when: false - name: (Windows) Set fact -> gitlab_runner_existing_version set_fact: @@ -31,7 +32,7 @@ win_get_url: url: "{{ gitlab_runner_download_url }}" dest: "{{ gitlab_runner_executable }}" - force: yes + force: true - name: (Windows) Install GitLab Runner win_command: "{{ gitlab_runner_executable }} install" @@ -40,7 +41,8 @@ when: (gitlab_runner_windows_service_user | length == 0) or (gitlab_runner_windows_service_password | length == 0) - name: (Windows) Install GitLab Runner - win_command: "{{ gitlab_runner_executable }} install --user \"{{ gitlab_runner_windows_service_user }}\" --password \"{{ gitlab_runner_windows_service_password }}\"" # noqa 204 + win_command: '{{ gitlab_runner_executable }} install --user "{{ gitlab_runner_windows_service_user }}" --password "{{ gitlab_runner_windows_service_password + }}"' # noqa 204 args: chdir: "{{ gitlab_runner_config_file_location }}" when: @@ -51,7 +53,7 @@ - name: (Windows) Make sure runner is stopped win_command: "{{ gitlab_runner_executable }} stop" - ignore_errors: yes + ignore_errors: true when: - gitlab_runner_exists @@ -61,7 +63,7 @@ win_get_url: url: "{{ gitlab_runner_download_url }}" dest: "{{ gitlab_runner_executable }}" - force: yes + force: true when: - gitlab_runner_exists - gitlab_runner_existing_version != gitlab_runner_wanted_version or gitlab_runner_wanted_version == 'latest' diff --git a/tasks/line-config-runner-windows.yml b/tasks/line-config-runner-windows.yml index c00a8cf..0f2de57 100644 --- a/tasks/line-config-runner-windows.yml +++ b/tasks/line-config-runner-windows.yml @@ -1,24 +1,24 @@ --- -- name: "(Windows) {{ line_name_prefix }} Ensure section exists" +- name: (Windows) {{ line_name_prefix }} Ensure section exists win_lineinfile: path: "{{ temp_runner_config.path }}" - regexp: '^(\s*)\[{{ section|regex_escape }}\]$' + regexp: ^(\s*)\[{{ section|regex_escape }}\]$ line: '{{ " " * (section.split(".")|length -1) }}[{{ section }}]' -- name: "(Windows) {{ line_name_prefix }} Modify existing line" +- name: (Windows) {{ line_name_prefix }} Modify existing line win_lineinfile: path: "{{ temp_runner_config.path }}" - insertafter: '\s+\[{{ section | regex_escape }}\]' - regexp: '^(\s*)({{ line | regex_escape }}|{{ line | regex_escape }}) =.*' + insertafter: \s+\[{{ section | regex_escape }}\] + regexp: ^(\s*)({{ line | regex_escape }}|{{ line | regex_escape }}) =.* line: '{{ " " * (section.split(".")|length) }}{{ line }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}' register: modified_config_line - when: "not '.' in line" + when: not '.' in line -- name: "(Windows) {{ line_name_prefix }} Modify existing line to_json" +- name: (Windows) {{ line_name_prefix }} Modify existing line to_json win_lineinfile: path: "{{ temp_runner_config.path }}" - insertafter: '\s+\[{{ section | regex_escape }}\]' - regexp: '^(\s*)({{ line | to_json | regex_escape }}|{{ line | regex_escape }}) =.*' + insertafter: \s+\[{{ section | regex_escape }}\] + regexp: ^(\s*)({{ line | to_json | regex_escape }}|{{ line | regex_escape }}) =.* line: '{{ " " * (section.split(".")|length) }}{{ line | to_json }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}' register: modified_config_line when: "'.' in line" diff --git a/tasks/line-config-runner.yml b/tasks/line-config-runner.yml index 6b149cf..bd51021 100644 --- a/tasks/line-config-runner.yml +++ b/tasks/line-config-runner.yml @@ -2,23 +2,23 @@ - name: "{{ line_name_prefix }} Ensure section exists" lineinfile: path: "{{ temp_runner_config.path }}" - regexp: '^(\s*)\[{{ section|regex_escape }}\]$' + regexp: ^(\s*)\[{{ section|regex_escape }}\]$ line: '{{ " " * (section.split(".")|length -1) }}[{{ section }}]' - name: "{{ line_name_prefix }} Modify existing line" lineinfile: path: "{{ temp_runner_config.path }}" - insertafter: '\s+\[{{ section | regex_escape }}\]' - regexp: '^(\s*)({{ line | regex_escape }}|{{ line | regex_escape }}) =' + insertafter: \s+\[{{ section | regex_escape }}\] + regexp: ^(\s*)({{ line | regex_escape }}|{{ line | regex_escape }}) = line: '{{ " " * (section.split(".")|length) }}{{ line }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}' register: modified_config_line - when: "not '.' in line" + when: not '.' in line - name: "{{ line_name_prefix }} Modify existing line to_json" lineinfile: path: "{{ temp_runner_config.path }}" - insertafter: '\s+\[{{ section | regex_escape }}\]' - regexp: '^(\s*)({{ line | to_json | regex_escape }}|{{ line | regex_escape }}) =' + insertafter: \s+\[{{ section | regex_escape }}\] + regexp: ^(\s*)({{ line | to_json | regex_escape }}|{{ line | regex_escape }}) = line: '{{ " " * (section.split(".")|length) }}{{ line | to_json }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}' register: modified_config_line when: "'.' in line" diff --git a/tasks/list-configured-runners-container.yml b/tasks/list-configured-runners-container.yml index b72d187..8e54a8f 100644 --- a/tasks/list-configured-runners-container.yml +++ b/tasks/list-configured-runners-container.yml @@ -1,5 +1,4 @@ --- - - name: List configured runners as json docker_container: name: "{{ gitlab_runner_container_name }}-list" @@ -9,13 +8,13 @@ - type: bind source: "{{ gitlab_runner_container_mount_path }}" target: /etc/gitlab-runner - cleanup: yes - interactive: yes - tty: yes - detach: no + cleanup: true + interactive: true + tty: true + detach: false register: registered_runners_json_result - changed_when: False - check_mode: no + changed_when: false + check_mode: false - name: Initialze runner list set_fact: diff --git a/tasks/list-configured-runners-unix.yml b/tasks/list-configured-runners-unix.yml index 3b46bd1..d8816b1 100644 --- a/tasks/list-configured-runners-unix.yml +++ b/tasks/list-configured-runners-unix.yml @@ -1,10 +1,9 @@ --- - - name: List configured runners as json command: "{{ gitlab_runner_executable }} --log-format json list" register: registered_runners_json_result - changed_when: False - check_mode: no + changed_when: false + check_mode: false become: "{{ gitlab_runner_system_mode }}" - name: Initialze runner list diff --git a/tasks/list-configured-runners-windows.yml b/tasks/list-configured-runners-windows.yml index de9de54..628ad0f 100644 --- a/tasks/list-configured-runners-windows.yml +++ b/tasks/list-configured-runners-windows.yml @@ -1,12 +1,11 @@ --- - - name: List configured runners as json win_command: "{{ gitlab_runner_executable }} --log-format json list" args: chdir: "{{ gitlab_runner_config_file_location }}" register: registered_runners_json_result - changed_when: False - check_mode: no + changed_when: false + check_mode: false - name: Initialze runner list set_fact: diff --git a/tasks/main-container.yml b/tasks/main-container.yml index c3bfd5c..8514f2d 100644 --- a/tasks/main-container.yml +++ b/tasks/main-container.yml @@ -12,13 +12,13 @@ - type: bind source: "{{ gitlab_runner_container_mount_path }}" target: /etc/gitlab-runner - cleanup: yes - interactive: yes - tty: yes - detach: no + cleanup: true + interactive: true + tty: true + detach: false register: verified_runners changed_when: '"Updated " in verified_runners.container.Output' - check_mode: no + check_mode: false - import_tasks: list-configured-runners-container.yml @@ -49,10 +49,10 @@ image: "{{ gitlab_runner_container_image }}:{{ gitlab_runner_container_tag }}" restart_policy: "{{ gitlab_runner_container_restart_policy }}" mounts: - - type: bind - source: "{{ gitlab_runner_container_mount_path }}" - target: /etc/gitlab-runner - - type: bind - source: /var/run/docker.sock - target: /var/run/docker.sock + - type: bind + source: "{{ gitlab_runner_container_mount_path }}" + target: /etc/gitlab-runner + - type: bind + source: /var/run/docker.sock + target: /var/run/docker.sock network_mode: "{{ gitlab_runner_container_network }}" diff --git a/tasks/main-unix.yml b/tasks/main-unix.yml index 7cd21f6..47d5db7 100644 --- a/tasks/main-unix.yml +++ b/tasks/main-unix.yml @@ -1,3 +1,4 @@ +--- - name: Install GitLab Runner (Debian) include_tasks: install-debian.yml when: ansible_os_family == 'Debian' @@ -18,7 +19,7 @@ command: "{{ gitlab_runner_executable }} verify --delete" register: verified_runners changed_when: '"Updated " in verified_runners.stderr' - check_mode: no + check_mode: false become: "{{ gitlab_runner_system_mode }}" - import_tasks: list-configured-runners-unix.yml diff --git a/tasks/main-windows.yml b/tasks/main-windows.yml index 87e26f5..9eef70c 100644 --- a/tasks/main-windows.yml +++ b/tasks/main-windows.yml @@ -1,3 +1,4 @@ +--- - name: Install GitLab Runner (Windows) import_tasks: install-windows.yml @@ -7,7 +8,7 @@ chdir: "{{ gitlab_runner_config_file_location }}" register: verified_runners changed_when: '"Updated " in verified_runners.stderr' - check_mode: no + check_mode: false - import_tasks: list-configured-runners-windows.yml @@ -37,4 +38,3 @@ args: chdir: "{{ gitlab_runner_config_file_location }}" when: gitlab_runner_windows_start_runner - \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 5c2d769..38ae63e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,11 +4,11 @@ vars: possible_files: files: - - '{{ ansible_distribution }}.yml' - - '{{ ansible_os_family }}.yml' - - 'default.yml' + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + - default.yml paths: - - 'vars' + - vars - name: Validate GitLab Runner configurations include_tasks: validate-runner-config.yml diff --git a/tasks/register-runner-container.yml b/tasks/register-runner-container.yml index 5d5e6ac..06b3533 100644 --- a/tasks/register-runner-container.yml +++ b/tasks/register-runner-container.yml @@ -1,5 +1,4 @@ --- - - name: Construct the runner command without secrets set_fact: register_runner_cmd: >- @@ -103,7 +102,7 @@ {% if gitlab_runner.ssh_password is defined %} --ssh-password '{{ gitlab_runner.ssh_password|hash("sha1") }}' {% endif %} - dest: '{{ gitlab_runner_config_file_location }}/last-runner-config-{{ actual_gitlab_runner_name }}' + dest: "{{ gitlab_runner_config_file_location }}/last-runner-config-{{ actual_gitlab_runner_name }}" register: runner_config_state - import_tasks: unregister-runner.yml @@ -128,13 +127,13 @@ --ssh-password '{{ gitlab_runner.ssh_password }}' {% endif %} mounts: - - type: bind - source: "{{ gitlab_runner_container_mount_path }}" - target: /etc/gitlab-runner - cleanup: yes - auto_remove: yes + - type: bind + source: "{{ gitlab_runner_container_mount_path }}" + target: /etc/gitlab-runner + cleanup: true + auto_remove: true network_mode: "{{ gitlab_runner_container_network }}" - when: + when: - actual_gitlab_runner_name not in registered_gitlab_runner_names - gitlab_runner.state|default('present') == 'present' no_log: false diff --git a/tasks/register-runner-windows.yml b/tasks/register-runner-windows.yml index 530e5a8..614bceb 100644 --- a/tasks/register-runner-windows.yml +++ b/tasks/register-runner-windows.yml @@ -1,5 +1,4 @@ --- - - name: Construct the runner command without secrets set_fact: register_runner_cmd: >- @@ -102,7 +101,7 @@ {% if gitlab_runner.ssh_password is defined %} --ssh-password '{{ gitlab_runner.ssh_password|hash("sha1") }}' {% endif %} - dest: '{{ gitlab_runner_config_file_location }}/last-runner-config-{{ actual_gitlab_runner_name }}' + dest: "{{ gitlab_runner_config_file_location }}/last-runner-config-{{ actual_gitlab_runner_name }}" register: runner_config_state - import_tasks: unregister-runner.yml diff --git a/tasks/register-runner.yml b/tasks/register-runner.yml index cf75ec7..d76e9aa 100644 --- a/tasks/register-runner.yml +++ b/tasks/register-runner.yml @@ -1,7 +1,6 @@ --- - - name: Accept gitlab server self signed cert as valid CA - shell: "openssl s_client -connect {{gitlab_server_ip}}:443 -showcerts /dev/null | sed -e '/-----BEGIN/,/-----END/!d' | tee {{tls_ca_file}} >/dev/null" + shell: openssl s_client -connect {{gitlab_server_ip}}:443 -showcerts /dev/null | sed -e '/-----BEGIN/,/-----END/!d' | tee {{tls_ca_file}} >/dev/null when: force_accept_gitlab_server_self_signed - name: Update CA bundle with self signe cert of the gitlab server @@ -138,7 +137,7 @@ {% if gitlab_runner.ssh_password is defined %} --ssh-password '{{ gitlab_runner.ssh_password|hash("sha1") }}' {% endif %} - dest: '{{ gitlab_runner_config_file_location }}/last-runner-config-{{ actual_gitlab_runner_name }}' + dest: "{{ gitlab_runner_config_file_location }}/last-runner-config-{{ actual_gitlab_runner_name }}" register: runner_config_state - import_tasks: unregister-runner.yml @@ -159,7 +158,7 @@ {% if gitlab_runner.ssh_password is defined %} --ssh-password '{{ gitlab_runner.ssh_password }}' {% endif %} - when: + when: - actual_gitlab_runner_name not in registered_gitlab_runner_names - gitlab_runner.state|default('present') == 'present' no_log: true diff --git a/tasks/systemd-reload.yml b/tasks/systemd-reload.yml index a66638b..a493b10 100644 --- a/tasks/systemd-reload.yml +++ b/tasks/systemd-reload.yml @@ -1,16 +1,15 @@ --- - - name: Ensure /etc/systemd/system/gitlab-runner.service.d/ exists - become: yes + become: true file: path: /etc/systemd/system/gitlab-runner.service.d state: directory owner: root group: root - mode: 0755 + mode: "0755" - name: Add reload command to GitLab Runner system service - become: yes + become: true copy: dest: /etc/systemd/system/gitlab-runner.service.d/exec-reload.conf content: | @@ -20,7 +19,7 @@ # https://docs.gitlab.com/runner/configuration/init.html#overriding-systemd - name: Configure graceful stop for GitLab Runner system service - become: yes + become: true copy: dest: /etc/systemd/system/gitlab-runner.service.d/kill.conf content: | @@ -30,8 +29,8 @@ when: gitlab_runner_timeout_stop_seconds > 0 register: gitlab_runner_kill_timeout -- name: Force systemd to reread configs # noqa 503 - become: yes +- name: Force systemd to reread configs + become: true systemd: - daemon_reload: yes + daemon_reload: true when: gitlab_runner_exec_reload.changed or gitlab_runner_kill_timeout diff --git a/tasks/unregister-runner-if-not-longer-configured.yml b/tasks/unregister-runner-if-not-longer-configured.yml index a89735a..3a4e527 100644 --- a/tasks/unregister-runner-if-not-longer-configured.yml +++ b/tasks/unregister-runner-if-not-longer-configured.yml @@ -1,4 +1,4 @@ - +--- - name: Get the names of all configured runner executors set_fact: local_gitlab_executor_names: "{{ gitlab_runner_runners | map(attribute='name') | list }}" diff --git a/tasks/unregister-runner.yml b/tasks/unregister-runner.yml index 69e5236..579a09f 100644 --- a/tasks/unregister-runner.yml +++ b/tasks/unregister-runner.yml @@ -1,6 +1,4 @@ - - - +--- - name: (Container) Unregister runner docker_container: name: "{{ gitlab_runner_container_name }}-list" @@ -10,25 +8,23 @@ - type: bind source: "{{ gitlab_runner_container_mount_path }}" target: /etc/gitlab-runner - cleanup: yes - interactive: yes - tty: yes - detach: no - changed_when: False - check_mode: no - when: + cleanup: true + interactive: true + tty: true + detach: false + changed_when: false + check_mode: false + when: - gitlab_install_target_platform == 'container' - - name: (Windows) Unregister runner - win_command: '{{ gitlab_runner_executable }} unregister --name {{ actual_gitlab_runner_name }}' + win_command: "{{ gitlab_runner_executable }} unregister --name {{ actual_gitlab_runner_name }}" args: chdir: "{{ gitlab_runner_config_file_location }}" when: - gitlab_install_target_platform == 'windows' - - name: Unregister runner - ansible.builtin.command: '{{ gitlab_runner_executable }} unregister --name {{ actual_gitlab_runner_name }}' - when: + ansible.builtin.command: "{{ gitlab_runner_executable }} unregister --name {{ actual_gitlab_runner_name }}" + when: - gitlab_install_target_platform == 'unix' diff --git a/tasks/update-ca-bundle.yml b/tasks/update-ca-bundle.yml index c84d8b9..91fd666 100644 --- a/tasks/update-ca-bundle.yml +++ b/tasks/update-ca-bundle.yml @@ -1,3 +1,4 @@ +--- - name: install ca package on rhel systems yum: name: ca-certificates @@ -8,7 +9,7 @@ apt: name: ca-certificates state: present - update_cache: yes + update_cache: true when: ansible_os_family == "Debian" - name: enable dynamic ca configuration on rhel6 diff --git a/tasks/update-config-runner-windows.yml b/tasks/update-config-runner-windows.yml index 264f0e1..dbbe4f2 100644 --- a/tasks/update-config-runner-windows.yml +++ b/tasks/update-config-runner-windows.yml @@ -1,371 +1,370 @@ --- -- name: "(Windows) {{ runn_name_prefix }} Set \"[[runners]]\" section" +- name: (Windows) {{ runn_name_prefix }} Set "[[runners]]" section win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '\n' - line: '[[runners]]' + regexp: \n + line: "[[runners]]" state: present - insertbefore: '^\s*name =' - backrefs: no - check_mode: no + insertbefore: ^\s*name = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set concurrent limit option" +- name: (Windows) {{ runn_name_prefix }} Set concurrent limit option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*limit =.*' - line: ' limit = {{ gitlab_runner.concurrent_specific|default(0) }}' + regexp: ^\s*limit =.* + line: " limit = {{ gitlab_runner.concurrent_specific|default(0) }}" state: present - insertafter: '^\s*name =' - backrefs: no - check_mode: no + insertafter: ^\s*name = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set coordinator URL" +- name: (Windows) {{ runn_name_prefix }} Set coordinator URL win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*url =.*' - line: ' url = {{ gitlab_runner.url|default(gitlab_runner_coordinator_url) | to_json }}' + regexp: ^\s*url =.* + line: " url = {{ gitlab_runner.url|default(gitlab_runner_coordinator_url) | to_json }}" state: present - insertafter: '^\s*limit =' - backrefs: no - check_mode: no + insertafter: ^\s*limit = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set clone URL" +- name: (Windows) {{ runn_name_prefix }} Set clone URL win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*clone_url =' - line: ' clone_url = {{ gitlab_runner.clone_url | to_json }}' + regexp: ^\s*clone_url = + line: " clone_url = {{ gitlab_runner.clone_url | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false notify: restart_gitlab_runner when: gitlab_runner.clone_url is defined -- name: "(Windows) {{ runn_name_prefix }} Set environment option" +- name: (Windows) {{ runn_name_prefix }} Set environment option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*environment =.*' - line: ' environment = {{ gitlab_runner.env_vars|default([]) | to_json }}' + regexp: ^\s*environment =.* + line: " environment = {{ gitlab_runner.env_vars|default([]) | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set pre_get_sources_script" +- name: (Windows) {{ runn_name_prefix }} Set pre_get_sources_script win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*pre_get_sources_script =' - line: ' pre_get_sources_script = {{ gitlab_runner.pre_get_sources_script | to_json }}' + regexp: ^\s*pre_get_sources_script = + line: " pre_get_sources_script = {{ gitlab_runner.pre_get_sources_script | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false notify: restart_gitlab_runner when: gitlab_runner.pre_get_sources_script is defined -- name: "(Windows) {{ runn_name_prefix }} Set post_get_sources_script" +- name: (Windows) {{ runn_name_prefix }} Set post_get_sources_script win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*post_get_sources_script =' - line: ' post_get_sources_script = {{ gitlab_runner.post_get_sources_script | to_json }}' + regexp: ^\s*post_get_sources_script = + line: " post_get_sources_script = {{ gitlab_runner.post_get_sources_script | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false notify: restart_gitlab_runner when: gitlab_runner.post_get_sources_script is defined -- name: "(Windows) {{ runn_name_prefix }} Set pre_build_script" +- name: (Windows) {{ runn_name_prefix }} Set pre_build_script win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*pre_build_script =' - line: ' pre_build_script = {{ gitlab_runner.pre_build_script | to_json }}' + regexp: ^\s*pre_build_script = + line: " pre_build_script = {{ gitlab_runner.pre_build_script | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false notify: restart_gitlab_runner when: gitlab_runner.pre_build_script is defined -- name: "(Windows) {{ runn_name_prefix }} Set post_build_script" +- name: (Windows) {{ runn_name_prefix }} Set post_build_script win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*post_build_script =' - line: ' post_build_script = {{ gitlab_runner.post_build_script | to_json }}' + regexp: ^\s*post_build_script = + line: " post_build_script = {{ gitlab_runner.post_build_script | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false notify: restart_gitlab_runner when: gitlab_runner.post_build_script is defined -- name: "(Windows) {{ runn_name_prefix }} Set runner executor option" +- name: (Windows) {{ runn_name_prefix }} Set runner executor option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*executor =.*' + regexp: ^\s*executor =.* line: ' executor = {{ gitlab_runner.executor|default("shell") | to_json }}' state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set runner shell option" +- name: (Windows) {{ runn_name_prefix }} Set runner shell option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*shell =.*' + regexp: ^\s*shell =.* line: ' shell = {{ gitlab_runner.shell|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.shell is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set output_limit option" +- name: (Windows) {{ runn_name_prefix }} Set output_limit option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*output_limit =.*' - line: ' output_limit = {{ gitlab_runner.output_limit|default(4096) }}' + regexp: ^\s*output_limit =.* + line: " output_limit = {{ gitlab_runner.output_limit|default(4096) }}" state: present - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set runner docker image option" +- name: (Windows) {{ runn_name_prefix }} Set runner docker image option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*image =.*' + regexp: ^\s*image =.* line: ' image = {{ gitlab_runner.docker_image|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.docker_image is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set docker privileged option" +- name: (Windows) {{ runn_name_prefix }} Set docker privileged option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*privileged =.*' - line: ' privileged = {{ gitlab_runner.docker_privileged|default(false) | lower }}' + regexp: ^\s*privileged =.* + line: " privileged = {{ gitlab_runner.docker_privileged|default(false) | lower }}" state: "{{ 'present' if gitlab_runner.docker_privileged is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set docker volumes option" +- name: (Windows) {{ runn_name_prefix }} Set docker volumes option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*volumes =.*' - line: ' volumes = {{ gitlab_runner.docker_volumes|default([])|to_json }}' + regexp: ^\s*volumes =.* + line: " volumes = {{ gitlab_runner.docker_volumes|default([])|to_json }}" state: "{{ 'present' if gitlab_runner.docker_volumes is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set docker devices option" +- name: (Windows) {{ runn_name_prefix }} Set docker devices option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*devices =.*' - line: ' devices = {{ gitlab_runner.docker_devices|default([])|to_json }}' + regexp: ^\s*devices =.* + line: " devices = {{ gitlab_runner.docker_devices|default([])|to_json }}" state: "{{ 'present' if gitlab_runner.docker_devices is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set docker network_mode option" +- name: (Windows) {{ runn_name_prefix }} Set docker network_mode option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*network_mode =.*' + regexp: ^\s*network_mode =.* line: ' network_mode = {{ gitlab_runner.docker_network_mode|default("bridge") | to_json }}' state: "{{ 'present' if gitlab_runner.docker_network_mode is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache type option" +- name: (Windows) {{ runn_name_prefix }} Set cache type option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*Type =.*' + regexp: ^\s*Type =.* line: ' Type = {{ gitlab_runner.cache_type|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_type is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache path option" +- name: (Windows) {{ runn_name_prefix }} Set cache path option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*Path =.*' + regexp: ^\s*Path =.* line: ' Path = {{ gitlab_runner.cache_path|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_path is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache s3 server address" +- name: (Windows) {{ runn_name_prefix }} Set cache s3 server address win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*ServerAddress =.*' + regexp: ^\s*ServerAddress =.* line: ' ServerAddress = {{ gitlab_runner.cache_s3_server_address|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_server_address is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache s3 access key" +- name: (Windows) {{ runn_name_prefix }} Set cache s3 access key win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*AccessKey =.*' + regexp: ^\s*AccessKey =.* line: ' AccessKey = {{ gitlab_runner.cache_s3_access_key|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_access_key is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache s3 secret key" +- name: (Windows) {{ runn_name_prefix }} Set cache s3 secret key win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*SecretKey =.*' + regexp: ^\s*SecretKey =.* line: ' SecretKey = {{ gitlab_runner.cache_s3_secret_key|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_secret_key is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows - -- name: "(Windows) {{ runn_name_prefix }} Set cache shared option" +- name: (Windows) {{ runn_name_prefix }} Set cache shared option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*Shared =.*' + regexp: ^\s*Shared =.* line: ' Shared = {{ gitlab_runner.cache_shared|default("") | lower }}' state: "{{ 'present' if gitlab_runner.cache_shared is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache s3 bucket name option" +- name: (Windows) {{ runn_name_prefix }} Set cache s3 bucket name option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*BucketName =.*' + regexp: ^\s*BucketName =.* line: ' BucketName = {{ gitlab_runner.cache_s3_bucket_name|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_bucket_name is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache s3 bucket location option" +- name: (Windows) {{ runn_name_prefix }} Set cache s3 bucket location option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*BucketLocation =.*' + regexp: ^\s*BucketLocation =.* line: ' BucketLocation = {{ gitlab_runner.cache_s3_bucket_location|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_bucket_location is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache s3 insecure option" +- name: (Windows) {{ runn_name_prefix }} Set cache s3 insecure option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*Insecure =.*' + regexp: ^\s*Insecure =.* line: ' Insecure = {{ gitlab_runner.cache_s3_insecure|default("") | lower }}' state: "{{ 'present' if gitlab_runner.cache_s3_insecure is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set ssh user option" +- name: (Windows) {{ runn_name_prefix }} Set ssh user option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*user =.*' + regexp: ^\s*user =.* line: ' user = {{ gitlab_runner.ssh_user|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_user is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set ssh host option" +- name: (Windows) {{ runn_name_prefix }} Set ssh host option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*host =.*' + regexp: ^\s*host =.* line: ' host = {{ gitlab_runner.ssh_host|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_host is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set ssh port option" +- name: (Windows) {{ runn_name_prefix }} Set ssh port option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*port =.*' + regexp: ^\s*port =.* line: ' port = {{ gitlab_runner.ssh_port|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_port is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set ssh password option" +- name: (Windows) {{ runn_name_prefix }} Set ssh password option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*password =.*' + regexp: ^\s*password =.* line: ' password = {{ gitlab_runner.ssh_password|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_password is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set ssh identity file option" +- name: (Windows) {{ runn_name_prefix }} Set ssh identity file option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*identity_file =.*' + regexp: ^\s*identity_file =.* line: ' identity_file = {{ gitlab_runner.ssh_identity_file|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_identity_file is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set builds dir file option" +- name: (Windows) {{ runn_name_prefix }} Set builds dir file option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*builds_dir =.*' + regexp: ^\s*builds_dir =.* line: ' builds_dir = {{ gitlab_runner.builds_dir|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.builds_dir is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows -- name: "(Windows) {{ runn_name_prefix }} Set cache dir file option" +- name: (Windows) {{ runn_name_prefix }} Set cache dir file option win_lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*cache_dir =.*' + regexp: ^\s*cache_dir =.* line: ' cache_dir = {{ gitlab_runner.cache_dir|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_dir is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false notify: restart_gitlab_runner_windows - name: (Windows) Remove empty lines diff --git a/tasks/update-config-runner.yml b/tasks/update-config-runner.yml index 01a5d0c..0a932da 100644 --- a/tasks/update-config-runner.yml +++ b/tasks/update-config-runner.yml @@ -1,935 +1,932 @@ --- -- name: "{{ runn_name_prefix }} Set concurrent limit option" +- name: "{{ runn_name_prefix }} Set concurrent limit option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*limit =' - line: ' limit = {{ gitlab_runner.concurrent_specific|default(0) }}' + regexp: ^\s*limit = + line: " limit = {{ gitlab_runner.concurrent_specific|default(0) }}" state: present - insertafter: '^\s*name =' - backrefs: no - check_mode: no + insertafter: ^\s*name = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set coordinator URL" +- name: "{{ runn_name_prefix }} Set coordinator URL" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*url =' - line: ' url = {{ gitlab_runner.url|default(gitlab_runner_coordinator_url) | to_json }}' + regexp: ^\s*url = + line: " url = {{ gitlab_runner.url|default(gitlab_runner_coordinator_url) | to_json }}" state: present - insertafter: '^\s*limit =' - backrefs: no - check_mode: no + insertafter: ^\s*limit = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set clone URL" +- name: "{{ runn_name_prefix }} Set clone URL" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*clone_url =' - line: ' clone_url = {{ gitlab_runner.clone_url | to_json }}' + regexp: ^\s*clone_url = + line: " clone_url = {{ gitlab_runner.clone_url | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos when: gitlab_runner.clone_url is defined -- name: "{{ runn_name_prefix }} Set environment option" +- name: "{{ runn_name_prefix }} Set environment option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*environment =' - line: ' environment = {{ gitlab_runner.env_vars|default([]) | to_json }}' + regexp: ^\s*environment = + line: " environment = {{ gitlab_runner.env_vars|default([]) | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set pre_get_sources_script" +- name: "{{ runn_name_prefix }} Set pre_get_sources_script" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*pre_get_sources_script =' - line: ' pre_get_sources_script = {{ gitlab_runner.pre_get_sources_script | to_json }}' + regexp: ^\s*pre_get_sources_script = + line: " pre_get_sources_script = {{ gitlab_runner.pre_get_sources_script | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos when: gitlab_runner.pre_get_sources_script is defined -- name: "{{ runn_name_prefix }} Set post_get_sources_script" +- name: "{{ runn_name_prefix }} Set post_get_sources_script" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*post_get_sources_script =' - line: ' post_get_sources_script = {{ gitlab_runner.post_get_sources_script | to_json }}' + regexp: ^\s*post_get_sources_script = + line: " post_get_sources_script = {{ gitlab_runner.post_get_sources_script | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos when: gitlab_runner.post_get_sources_script is defined -- name: "{{ runn_name_prefix }} Set pre_build_script" +- name: "{{ runn_name_prefix }} Set pre_build_script" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*pre_build_script =' - line: ' pre_build_script = {{ gitlab_runner.pre_build_script | to_json }}' + regexp: ^\s*pre_build_script = + line: " pre_build_script = {{ gitlab_runner.pre_build_script | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos when: gitlab_runner.pre_build_script is defined - name: "{{ runn_name_prefix }} Set tls_ca_file" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*tls-ca-file =' - line: ' tls-ca-file = {{ gitlab_runner.tls_ca_file | to_json }}' + regexp: ^\s*tls-ca-file = + line: " tls-ca-file = {{ gitlab_runner.tls_ca_file | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos when: gitlab_runner.tls_ca_file is defined -- name: "{{ runn_name_prefix }} Set post_build_script" +- name: "{{ runn_name_prefix }} Set post_build_script" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*post_build_script =' - line: ' post_build_script = {{ gitlab_runner.post_build_script | to_json }}' + regexp: ^\s*post_build_script = + line: " post_build_script = {{ gitlab_runner.post_build_script | to_json }}" state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos when: gitlab_runner.post_build_script is defined -- name: "{{ runn_name_prefix }} Set runner executor option" +- name: "{{ runn_name_prefix }} Set runner executor option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*executor =' + regexp: ^\s*executor = line: ' executor = {{ gitlab_runner.executor|default("shell") | to_json }}' state: present - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set runner shell option" +- name: "{{ runn_name_prefix }} Set runner shell option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*shell =' + regexp: ^\s*shell = line: ' shell = {{ gitlab_runner.shell|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.shell is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set runner executor section" +- name: "{{ runn_name_prefix }} Set runner executor section" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*\[runners\.{{ gitlab_runner.executor|default("shell") }}\]' + regexp: ^\s*\[runners\.{{ gitlab_runner.executor|default("shell") }}\] line: ' [runners.{{ gitlab_runner.executor|replace("docker+machine","machine")|default("shell") }}]' state: "{{ 'absent' if (gitlab_runner.executor|default('shell')) == 'shell' else 'present' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set output_limit option" +- name: "{{ runn_name_prefix }} Set output_limit option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*output_limit =' - line: ' output_limit = {{ gitlab_runner.output_limit|default(4096) }}' + regexp: ^\s*output_limit = + line: " output_limit = {{ gitlab_runner.output_limit|default(4096) }}" state: present - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos - + - restart_gitlab_runner + - restart_gitlab_runner_macos #### [runners.docker] section #### -- name: "{{ runn_name_prefix }} Set runner docker image option" +- name: "{{ runn_name_prefix }} Set runner docker image option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*image =' + regexp: ^\s*image = line: ' image = {{ gitlab_runner.docker_image|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.docker_image is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker helper image option" +- name: "{{ runn_name_prefix }} Set docker helper image option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*helper_image =' + regexp: ^\s*helper_image = line: ' helper_image = {{ gitlab_runner.docker_helper_image|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.docker_helper_image is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker privileged option" +- name: "{{ runn_name_prefix }} Set docker privileged option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*privileged =' - line: ' privileged = {{ gitlab_runner.docker_privileged|default(false) | lower }}' + regexp: ^\s*privileged = + line: " privileged = {{ gitlab_runner.docker_privileged|default(false) | lower }}" state: "{{ 'present' if gitlab_runner.docker_privileged is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker wait_for_services_timeout option" +- name: "{{ runn_name_prefix }} Set docker wait_for_services_timeout option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*wait_for_services_timeout =' - line: ' wait_for_services_timeout = {{ gitlab_runner.docker_wait_for_services_timeout|default(30) }}' + regexp: ^\s*wait_for_services_timeout = + line: " wait_for_services_timeout = {{ gitlab_runner.docker_wait_for_services_timeout|default(30) }}" state: "{{ 'present' if gitlab_runner.docker_wait_for_services_timeout is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - restart_gitlab_runner - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker tlsverify option" +- name: "{{ runn_name_prefix }} Set docker tlsverify option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*tls_verify =' - line: ' tls_verify = {{ gitlab_runner.docker_tlsverify|default(false) | lower }}' + regexp: ^\s*tls_verify = + line: " tls_verify = {{ gitlab_runner.docker_tlsverify|default(false) | lower }}" state: "{{ 'present' if gitlab_runner.docker_tlsverify is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos - name: "{{ runn_name_prefix }} Set docker shm_size option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*shm_size =' - line: ' shm_size = {{ gitlab_runner.docker_shm_size|default(false) | lower }}' + regexp: ^\s*shm_size = + line: " shm_size = {{ gitlab_runner.docker_shm_size|default(false) | lower }}" state: "{{ 'present' if gitlab_runner.docker_shm_size is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker disable_cache option" +- name: "{{ runn_name_prefix }} Set docker disable_cache option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*disable_cache =' - line: ' disable_cache = {{ gitlab_runner.docker_disable_cache|default(false) | lower }}' + regexp: ^\s*disable_cache = + line: " disable_cache = {{ gitlab_runner.docker_disable_cache|default(false) | lower }}" state: "{{ 'present' if gitlab_runner.docker_disable_cache is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker DNS option" +- name: "{{ runn_name_prefix }} Set docker DNS option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*dns =' - line: ' dns = {{ gitlab_runner.docker_dns|default(false) | to_json }}' + regexp: ^\s*dns = + line: " dns = {{ gitlab_runner.docker_dns|default(false) | to_json }}" state: "{{ 'present' if gitlab_runner.docker_dns is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker DNS search option" +- name: "{{ runn_name_prefix }} Set docker DNS search option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*dns_search =' - line: ' dns_search = {{ gitlab_runner.docker_dns_search|default(false) | to_json }}' + regexp: ^\s*dns_search = + line: " dns_search = {{ gitlab_runner.docker_dns_search|default(false) | to_json }}" state: "{{ 'present' if gitlab_runner.docker_dns_search is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker pull_policy option" +- name: "{{ runn_name_prefix }} Set docker pull_policy option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*pull_policy =' - line: ' pull_policy = {{ gitlab_runner.docker_pull_policy|default([])|to_json }}' + regexp: ^\s*pull_policy = + line: " pull_policy = {{ gitlab_runner.docker_pull_policy|default([])|to_json }}" state: "{{ 'present' if gitlab_runner.docker_pull_policy is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker volumes option" +- name: "{{ runn_name_prefix }} Set docker volumes option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*volumes =' - line: ' volumes = {{ gitlab_runner.docker_volumes|default([])|to_json }}' + regexp: ^\s*volumes = + line: " volumes = {{ gitlab_runner.docker_volumes|default([])|to_json }}" state: "{{ 'present' if gitlab_runner.docker_volumes is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker devices option" +- name: "{{ runn_name_prefix }} Set docker devices option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*devices =' - line: ' devices = {{ gitlab_runner.docker_devices|default([])|to_json }}' + regexp: ^\s*devices = + line: " devices = {{ gitlab_runner.docker_devices|default([])|to_json }}" state: "{{ 'present' if gitlab_runner.docker_devices is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set runner docker network option" +- name: "{{ runn_name_prefix }} Set runner docker network option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*network_mode =' + regexp: ^\s*network_mode = line: ' network_mode = {{ gitlab_runner.docker_network_mode|default("bridge") | to_json }}' state: "{{ 'present' if gitlab_runner.docker_network_mode is defined else 'absent' }}" - insertafter: '^\s*\[runners\.docker\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.docker\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set tls-cert-file option" +- name: "{{ runn_name_prefix }} Set tls-cert-file option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*tls-cert-file =' - line: ' tls-cert-file = {{ gitlab_runner.tls_cert_file|default([]) | to_json }}' + regexp: ^\s*tls-cert-file = + line: " tls-cert-file = {{ gitlab_runner.tls_cert_file|default([]) | to_json }}" state: "{{ 'present' if gitlab_runner.tls_cert_file is defined else 'absent' }}" - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set tls-key-file option" +- name: "{{ runn_name_prefix }} Set tls-key-file option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*tls-key-file =' - line: ' tls-key-file = {{ gitlab_runner.tls_key_file|default([]) | to_json }}' + regexp: ^\s*tls-key-file = + line: " tls-key-file = {{ gitlab_runner.tls_key_file|default([]) | to_json }}" state: "{{ 'present' if gitlab_runner.tls_key_file is defined else 'absent' }}" - insertafter: '^\s*url =' - backrefs: no - check_mode: no + insertafter: ^\s*url = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos #### [[runners.docker.services]] section #### -- name: "{{ runn_name_prefix }} Set additional services" +- name: "{{ runn_name_prefix }} Set additional services" blockinfile: dest: "{{ temp_runner_config.path }}" content: "{{ lookup('template', 'config.runners.docker.services.j2') if gitlab_runner.docker_services is defined }}" state: "{{ 'present' if gitlab_runner.docker_services is defined else 'absent' }}" marker: "# {mark} runners.docker.services" insertafter: EOF - check_mode: no + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos #### [runners.custom_build_dir] section ##### -- name: "{{ runn_name_prefix }} Set custom_build_dir section" +- name: "{{ runn_name_prefix }} Set custom_build_dir section" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*\[runners\.custom_build_dir\]' - line: ' [runners.custom_build_dir]' + regexp: ^\s*\[runners\.custom_build_dir\] + line: " [runners.custom_build_dir]" state: "{{ 'present' if gitlab_runner.custom_build_dir_enabled is defined else 'absent' }}" insertafter: EOF - backrefs: no - check_mode: no + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set docker custom_build_dir-enabled option" +- name: "{{ runn_name_prefix }} Set docker custom_build_dir-enabled option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*enabled =' - line: ' enabled = {{ gitlab_runner.custom_build_dir_enabled|default(false) | lower }}' + regexp: ^\s*enabled = + line: " enabled = {{ gitlab_runner.custom_build_dir_enabled|default(false) | lower }}" state: "{{ 'present' if gitlab_runner.custom_build_dir_enabled is defined else 'absent' }}" - insertafter: '^\s*\[runners\.custom_build_dir\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.custom_build_dir\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos #### [runners.cache] section #### -- name: "{{ runn_name_prefix }} Set cache section" +- name: "{{ runn_name_prefix }} Set cache section" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*\[runners\.cache\]' - line: ' [runners.cache]' + regexp: ^\s*\[runners\.cache\] + line: " [runners.cache]" state: present insertafter: EOF - backrefs: no - check_mode: no + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache s3 section" +- name: "{{ runn_name_prefix }} Set cache s3 section" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*\[runners\.cache\.s3\]' - line: ' [runners.cache.s3]' + regexp: ^\s*\[runners\.cache\.s3\] + line: " [runners.cache.s3]" state: "{{ 'present' if gitlab_runner.cache_s3_bucket_name is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache gcs section" +- name: "{{ runn_name_prefix }} Set cache gcs section" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*\[runners\.cache\.gcs\]' - line: ' [runners.cache.gcs]' + regexp: ^\s*\[runners\.cache\.gcs\] + line: " [runners.cache.gcs]" state: "{{ 'present' if gitlab_runner.cache_gcs_bucket_name is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache azure section" +- name: "{{ runn_name_prefix }} Set cache azure section" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*\[runners\.cache\.azure\]' - line: ' [runners.cache.azure]' + regexp: ^\s*\[runners\.cache\.azure\] + line: " [runners.cache.azure]" state: "{{ 'present' if gitlab_runner.cache_azure_account_name is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - restart_gitlab_runner - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache type option" +- name: "{{ runn_name_prefix }} Set cache type option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*Type =' + regexp: ^\s*Type = line: ' Type = {{ gitlab_runner.cache_type|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_type is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache path option" +- name: "{{ runn_name_prefix }} Set cache path option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*Path =' + regexp: ^\s*Path = line: ' Path = {{ gitlab_runner.cache_path|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_path is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache shared option" +- name: "{{ runn_name_prefix }} Set cache shared option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*Shared =' + regexp: ^\s*Shared = line: ' Shared = {{ gitlab_runner.cache_shared|default("") | lower }}' state: "{{ 'present' if gitlab_runner.cache_shared is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos - + - restart_gitlab_runner + - restart_gitlab_runner_macos #### [runners.cache.s3] section #### -- name: "{{ runn_name_prefix }} Set cache s3 server addresss" +- name: "{{ runn_name_prefix }} Set cache s3 server addresss" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*ServerAddress =' + regexp: ^\s*ServerAddress = line: ' ServerAddress = {{ gitlab_runner.cache_s3_server_address|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_server_address is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache s3 access key" +- name: "{{ runn_name_prefix }} Set cache s3 access key" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*AccessKey =' + regexp: ^\s*AccessKey = line: ' AccessKey = {{ gitlab_runner.cache_s3_access_key|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_access_key is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache s3 secret key" +- name: "{{ runn_name_prefix }} Set cache s3 secret key" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*SecretKey =' + regexp: ^\s*SecretKey = line: ' SecretKey = {{ gitlab_runner.cache_s3_secret_key|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_secret_key is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache s3 bucket name option" +- name: "{{ runn_name_prefix }} Set cache s3 bucket name option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*BucketName =' + regexp: ^\s*BucketName = line: ' BucketName = {{ gitlab_runner.cache_s3_bucket_name|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_bucket_name is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos when: gitlab_runner.cache_type is defined and gitlab_runner.cache_type == 's3' -- name: "{{ runn_name_prefix }} Set cache s3 bucket location option" +- name: "{{ runn_name_prefix }} Set cache s3 bucket location option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*BucketLocation =' + regexp: ^\s*BucketLocation = line: ' BucketLocation = {{ gitlab_runner.cache_s3_bucket_location|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_s3_bucket_location is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache s3 insecure option" +- name: "{{ runn_name_prefix }} Set cache s3 insecure option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*Insecure =' + regexp: ^\s*Insecure = line: ' Insecure = {{ gitlab_runner.cache_s3_insecure|default("") | lower }}' state: "{{ 'present' if gitlab_runner.cache_s3_insecure is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.s3\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.s3\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos - + - restart_gitlab_runner + - restart_gitlab_runner_macos #### [runners.cache.gcs] section #### -- name: "{{ runn_name_prefix }} Set cache gcs bucket name" +- name: "{{ runn_name_prefix }} Set cache gcs bucket name" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*BucketName =' + regexp: ^\s*BucketName = line: ' BucketName = {{ gitlab_runner.cache_gcs_bucket_name|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_gcs_bucket_name is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.gcs\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.gcs\] + backrefs: false + check_mode: false notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos when: gitlab_runner.cache_type is defined and gitlab_runner.cache_type == 'gcs' -- name: "{{ runn_name_prefix }} Set cache gcs credentials file" +- name: "{{ runn_name_prefix }} Set cache gcs credentials file" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*CredentialsFile =' + regexp: ^\s*CredentialsFile = line: ' CredentialsFile = {{ gitlab_runner.cache_gcs_credentials_file|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_gcs_credentials_file is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.gcs\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.gcs\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache gcs access id" +- name: "{{ runn_name_prefix }} Set cache gcs access id" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*AccessID =' + regexp: ^\s*AccessID = line: ' AccessID = {{ gitlab_runner.cache_gcs_access_id|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_gcs_access_id is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.gcs\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.gcs\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache gcs private key" +- name: "{{ runn_name_prefix }} Set cache gcs private key" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*PrivateKey =' + regexp: ^\s*PrivateKey = line: ' PrivateKey = {{ gitlab_runner.cache_gcs_private_key|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_gcs_private_key is defined else 'absent' }}" - insertafter: '^\s*\[runners\.cache\.gcs\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.cache\.gcs\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos #### [runners.cache.azure] section #### -- name: "{{ runn_name_prefix }} Set cache azure account name" +- name: "{{ runn_name_prefix }} Set cache azure account name" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*AccountName =' + 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 + insertafter: ^\s*\[runners\.cache\.azure\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - restart_gitlab_runner - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache azure account key" +- name: "{{ runn_name_prefix }} Set cache azure account key" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*AccountKey =' + 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 + insertafter: ^\s*\[runners\.cache\.azure\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - restart_gitlab_runner - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache azure container name" +- name: "{{ runn_name_prefix }} Set cache azure container name" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*ContainerName =' + 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 + insertafter: ^\s*\[runners\.cache\.azure\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - restart_gitlab_runner - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache azure storage domain" +- name: "{{ runn_name_prefix }} Set cache azure storage domain" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*StorageDomain =' + 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 + insertafter: ^\s*\[runners\.cache\.azure\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - restart_gitlab_runner - restart_gitlab_runner_macos #### [runners.ssh] section ##### -- name: "{{ runn_name_prefix }} Set ssh user option" +- name: "{{ runn_name_prefix }} Set ssh user option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*user =' + regexp: ^\s*user = line: ' user = {{ gitlab_runner.ssh_user|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_user is defined else 'absent' }}" - insertafter: '^\s*\[runners\.ssh\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.ssh\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set ssh host option" +- name: "{{ runn_name_prefix }} Set ssh host option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*host =' + regexp: ^\s*host = line: ' host = {{ gitlab_runner.ssh_host|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_host is defined else 'absent' }}" - insertafter: '^\s*\[runners\.ssh\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.ssh\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set ssh port option" +- name: "{{ runn_name_prefix }} Set ssh port option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*port =' + regexp: ^\s*port = line: ' port = "{{ gitlab_runner.ssh_port|default("") | to_json }}"' state: "{{ 'present' if gitlab_runner.ssh_port is defined else 'absent' }}" - insertafter: '^\s*\[runners\.ssh\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.ssh\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set ssh password option" +- name: "{{ runn_name_prefix }} Set ssh password option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*password =' + regexp: ^\s*password = line: ' password = {{ gitlab_runner.ssh_password|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_password is defined else 'absent' }}" - insertafter: '^\s*\[runners\.ssh\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.ssh\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set ssh identity file option" +- name: "{{ runn_name_prefix }} Set ssh identity file option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*identity_file =' + regexp: ^\s*identity_file = line: ' identity_file = {{ gitlab_runner.ssh_identity_file|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.ssh_identity_file is defined else 'absent' }}" - insertafter: '^\s*\[runners\.ssh\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.ssh\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos #### [runners.virtualbox] section ##### -- name: "{{ runn_name_prefix }} Set virtualbox base name option" +- name: "{{ runn_name_prefix }} Set virtualbox base name option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*base_name =' - line: ' base_name = {{ gitlab_runner.virtualbox_base_name | to_json }}' + regexp: ^\s*base_name = + line: " base_name = {{ gitlab_runner.virtualbox_base_name | to_json }}" state: "{{ 'present' if gitlab_runner.virtualbox_base_name is defined else 'absent' }}" - insertafter: '^\s*\[runners\.virtualbox\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.virtualbox\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" when: gitlab_runner.executor == 'virtualbox' and gitlab_runner.virtualbox_base_name is defined notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set virtualbox base snapshot option" +- name: "{{ runn_name_prefix }} Set virtualbox base snapshot option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*base_snapshot =' - line: ' base_snapshot = {{ gitlab_runner.virtualbox_base_snapshot | to_json }}' + regexp: ^\s*base_snapshot = + line: " base_snapshot = {{ gitlab_runner.virtualbox_base_snapshot | to_json }}" state: "{{ 'present' if gitlab_runner.virtualbox_base_snapshot is defined else 'absent' }}" - insertafter: '^\s*\[runners\.virtualbox\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.virtualbox\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" when: gitlab_runner.executor == 'virtualbox' and gitlab_runner.virtualbox_base_name is defined notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set virtualbox base folder option" +- name: "{{ runn_name_prefix }} Set virtualbox base folder option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*base_folder =' - line: ' base_folder = {{ gitlab_runner.virtualbox_base_folder | to_json }}' + regexp: ^\s*base_folder = + line: " base_folder = {{ gitlab_runner.virtualbox_base_folder | to_json }}" state: "{{ 'present' if gitlab_runner.virtualbox_base_folder is defined else 'absent' }}" - insertafter: '^\s*\[runners\.virtualbox\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.virtualbox\] + backrefs: false + check_mode: false when: gitlab_runner.executor == 'virtualbox' and gitlab_runner.virtualbox_base_name is defined no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set virtualbox disable snapshots option" +- name: "{{ runn_name_prefix }} Set virtualbox disable snapshots option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*disable_snapshots =' - line: ' disable_snapshots = {{ gitlab_runner.virtualbox_disable_snapshots|default(false) | to_json }}' + regexp: ^\s*disable_snapshots = + line: " disable_snapshots = {{ gitlab_runner.virtualbox_disable_snapshots|default(false) | to_json }}" state: "{{ 'present' if gitlab_runner.virtualbox_disable_snapshots is defined else 'absent' }}" - insertafter: '^\s*\[runners\.virtualbox\]' - backrefs: no - check_mode: no + insertafter: ^\s*\[runners\.virtualbox\] + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" when: gitlab_runner.executor == 'virtualbox' and gitlab_runner.virtualbox_base_name is defined notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set builds dir file option" +- name: "{{ runn_name_prefix }} Set builds dir file option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*builds_dir =' + regexp: ^\s*builds_dir = line: ' builds_dir = {{ gitlab_runner.builds_dir|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.builds_dir is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Set cache dir file option" +- name: "{{ runn_name_prefix }} Set cache dir file option" lineinfile: dest: "{{ temp_runner_config.path }}" - regexp: '^\s*cache_dir =' + regexp: ^\s*cache_dir = line: ' cache_dir = {{ gitlab_runner.cache_dir|default("") | to_json }}' state: "{{ 'present' if gitlab_runner.cache_dir is defined else 'absent' }}" - insertafter: '^\s*executor =' - backrefs: no - check_mode: no + insertafter: ^\s*executor = + backrefs: false + check_mode: false no_log: "{{ gitlab_runner_no_log_secrets | default(omit) }}" notify: - - restart_gitlab_runner - - restart_gitlab_runner_macos + - restart_gitlab_runner + - restart_gitlab_runner_macos -- name: "{{ runn_name_prefix }} Ensure directory permissions" +- name: "{{ runn_name_prefix }} Ensure directory permissions" file: dest: "{{ item }}" state: directory owner: "{{ gitlab_runner_runtime_owner|default(omit) }}" group: "{{ gitlab_runner_runtime_group|default(omit) }}" - mode: 0770 + mode: "0770" modification_time: preserve access_time: preserve - recurse: yes + recurse: true loop: - - "{{ gitlab_runner.builds_dir | default(\"\") }}" - - "{{ gitlab_runner.cache_dir | default(\"\") }}" + - '{{ gitlab_runner.builds_dir | default("") }}' + - '{{ gitlab_runner.cache_dir | default("") }}' when: item|length -- name: "{{ runn_name_prefix }} Ensure directory access test" - command: "/usr/bin/test -r {{ item }}" +- name: "{{ runn_name_prefix }} Ensure directory access test" + command: /usr/bin/test -r {{ item }} loop: - - "{{ gitlab_runner.builds_dir | default(\"\") }}" - - "{{ gitlab_runner.cache_dir | default(\"\") }}" + - '{{ gitlab_runner.builds_dir | default("") }}' + - '{{ gitlab_runner.cache_dir | default("") }}' when: item|length - changed_when: False - become: yes + changed_when: false + become: true become_user: "{{ gitlab_runner_runtime_owner|default(omit) }}" register: ensure_directory_access ignore_errors: true -- name: "{{ runn_name_prefix }} Ensure directory access fail on error" +- name: "{{ runn_name_prefix }} Ensure directory access fail on error" fail: msg: "Error: user gitlab-runner failed to test access to {{ item.item }}. Check parent folder(s) permissions" loop: "{{ ensure_directory_access.results }}" diff --git a/tests/test.yml b/tests/test.yml index fc7d6a9..8016fdd 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -6,23 +6,23 @@ vars: possible_files: files: - - '{{ ansible_distribution }}.yml' - - '{{ ansible_os_family }}.yml' - - 'default.yml' + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" + - default.yml paths: - - 'vars' + - vars - name: Copy the mock gitlab CI server copy: src: mock_gitlab_runner_ci.py - dest: "~/mock_gitlab_runner_ci.py" + dest: ~/mock_gitlab_runner_ci.py when: run_mock_server - name: Ensure mock CI pidfile is absent file: - path: "~/mock_ci.pid" + path: ~/mock_ci.pid state: absent when: run_mock_server - name: Start the mock CI - shell: "python ~/mock_gitlab_runner_ci.py ~/mock_ci.pid 6060 >~/mock_ci.log 2>&1" + shell: python ~/mock_gitlab_runner_ci.py ~/mock_ci.pid 6060 >~/mock_ci.log 2>&1 async: 3600 poll: 0 register: mock_server @@ -43,9 +43,9 @@ tasks: - name: Get pid mock gitlab CI server slurp: - src: "~/mock_ci.pid" + src: ~/mock_ci.pid register: pidfile_b64 when: run_mock_server - name: kill the mock CI - command: "kill {{ pidfile_b64.content | b64decode }}" + command: kill {{ pidfile_b64.content | b64decode }} when: run_mock_server diff --git a/tests/vars/Windows.yml b/tests/vars/Windows.yml index fdfcce3..cdd38e3 100644 --- a/tests/vars/Windows.yml +++ b/tests/vars/Windows.yml @@ -1,11 +1,12 @@ +--- gitlab_runner_runners: - - name: "Shell Runner" + - name: Shell Runner tags: - windows - shell executor: shell state: present - - name: "Shell Bash Runner" + - name: Shell Bash Runner tags: - windows - shell @@ -13,7 +14,7 @@ gitlab_runner_runners: executor: shell shell: bash state: present - - name: "Shell Cmd Runner" + - name: Shell Cmd Runner tags: - windows - shell @@ -21,7 +22,7 @@ gitlab_runner_runners: executor: shell shell: cmd state: present - - name: "Shell Runner S3 Cache" + - name: Shell Runner S3 Cache tags: - windows - shell @@ -34,15 +35,15 @@ gitlab_runner_runners: cache_s3_bucket_name: build-cache-bucket cache_s3_insecure: false state: present - - name: "Docker Runner" + - name: Docker Runner tags: - windows - docker executor: docker-windows state: present -gitlab_runner_listen_address: '0.0.0.0:9001' +gitlab_runner_listen_address: "0.0.0.0:9001" -run_mock_server: no -gitlab_runner_coordinator_url: "http://localhost:7070/" -gitlab_runner_registration_token: '' +run_mock_server: false +gitlab_runner_coordinator_url: http://localhost:7070/ +gitlab_runner_registration_token: "" diff --git a/tests/vars/default.yml b/tests/vars/default.yml index b4973f7..440d6e9 100644 --- a/tests/vars/default.yml +++ b/tests/vars/default.yml @@ -1,26 +1,26 @@ --- gitlab_runner_runners: - - name: 'vagrant-shell' + - name: vagrant-shell executor: shell tags: - node - ruby - mysql - - name: 'vagrant-shell-sh' + - name: vagrant-shell-sh executor: shell shell: sh tags: - sh - - name: 'vagrant-docker' + - name: vagrant-docker executor: docker - docker_image: 'docker:stable' + docker_image: docker:stable tags: - node - ruby - mysql - - name: 'vagrant-docker-cache' + - name: vagrant-docker-cache executor: docker - docker_image: 'docker:stable' + docker_image: docker:stable tags: - node - ruby @@ -34,9 +34,9 @@ gitlab_runner_runners: cache_s3_bucket_name: build-cache-bucket cache_s3_insecure: false - - name: 'vagrant-docker-cache-gcs' + - name: vagrant-docker-cache-gcs executor: docker - docker_image: 'docker:stable' + docker_image: docker:stable tags: - node - ruby @@ -45,13 +45,12 @@ gitlab_runner_runners: cache_type: gcs cache_shared: true cache_gcs_bucket_name: gcs-cache-bucket - cache_gcs_credentials_file: '/etc/gitlab-runner/credentials.json' - cache_gcs_access_id: 'cache-access-account@project.iam.gserviceaccount.com' + cache_gcs_credentials_file: /etc/gitlab-runner/credentials.json + cache_gcs_access_id: cache-access-account@project.iam.gserviceaccount.com cache_gcs_private_key: "-----BEGIN PRIVATE KEY-----\nXXXXXX\n-----END PRIVATE KEY-----\n" -run_mock_server: yes -gitlab_runner_coordinator_url: "http://localhost:6060/" -gitlab_runner_registration_token: 'notreal' +run_mock_server: true +gitlab_runner_coordinator_url: http://localhost:6060/ +gitlab_runner_registration_token: notreal -gitlab_runner_system_mode: yes -... +gitlab_runner_system_mode: true diff --git a/vars/Archlinux.yml b/vars/Archlinux.yml index 9b7bd96..e20f8c2 100644 --- a/vars/Archlinux.yml +++ b/vars/Archlinux.yml @@ -1,6 +1,6 @@ --- -gitlab_runner_executable: "/usr/bin/{{ gitlab_runner_package_name }}" +gitlab_runner_executable: /usr/bin/{{ gitlab_runner_package_name }} gitlab_runner_runtime_owner: gitlab-runner gitlab_runner_runtime_group: gitlab-runner diff --git a/vars/Darwin.yml b/vars/Darwin.yml index 65b8fc6..05d4aaf 100644 --- a/vars/Darwin.yml +++ b/vars/Darwin.yml @@ -2,7 +2,7 @@ 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_download_url: https://gitlab-runner-downloads.s3.amazonaws.com/{{ gitlab_runner_wanted_tag }}/binaries/gitlab-runner-darwin-{{ gitlab_runner_arch }} -gitlab_runner_directory: "/usr/local/bin" +gitlab_runner_directory: /usr/local/bin gitlab_runner_executable: "{{ gitlab_runner_directory }}/{{ gitlab_runner_package_name }}" diff --git a/vars/Debian.yml b/vars/Debian.yml index 9b7bd96..e20f8c2 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,6 +1,6 @@ --- -gitlab_runner_executable: "/usr/bin/{{ gitlab_runner_package_name }}" +gitlab_runner_executable: /usr/bin/{{ gitlab_runner_package_name }} gitlab_runner_runtime_owner: gitlab-runner gitlab_runner_runtime_group: gitlab-runner diff --git a/vars/RedHat.yml b/vars/RedHat.yml index e6c089d..e2004c4 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -1,6 +1,6 @@ --- -gitlab_runner_executable: "/usr/bin/{{ gitlab_runner_package_name }}" +gitlab_runner_executable: /usr/bin/{{ gitlab_runner_package_name }} gitlab_runner_runtime_owner: gitlab-runner gitlab_runner_runtime_group: gitlab-runner diff --git a/vars/Windows.yml b/vars/Windows.yml index 22fcd1a..ad6b85f 100644 --- a/vars/Windows.yml +++ b/vars/Windows.yml @@ -1,9 +1,9 @@ --- -gitlab_runner_download_url: 'https://gitlab-runner-downloads.s3.amazonaws.com/{{ gitlab_runner_wanted_tag }}/binaries/gitlab-runner-windows-amd64.exe' +gitlab_runner_download_url: https://gitlab-runner-downloads.s3.amazonaws.com/{{ gitlab_runner_wanted_tag }}/binaries/gitlab-runner-windows-amd64.exe -gitlab_runner_install_directory: "c:/gitlab-runner/" +gitlab_runner_install_directory: c:/gitlab-runner/ gitlab_runner_config_file_location: "{{ gitlab_runner_install_directory }}" -gitlab_runner_config_file: "{{ gitlab_runner_config_file_location }}/config.toml" # on Windows +gitlab_runner_config_file: "{{ gitlab_runner_config_file_location }}/config.toml" # on Windows -gitlab_runner_executable: "{{gitlab_runner_install_directory}}/{{ gitlab_runner_package_name }}.exe" \ No newline at end of file +gitlab_runner_executable: "{{gitlab_runner_install_directory}}/{{ gitlab_runner_package_name }}.exe" diff --git a/vars/main.yml b/vars/main.yml index af1e5c9..13c0664 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -2,5 +2,5 @@ # vars file for gitlab-runner # Useful default paths for config files on Mac/Linux platforms -__gitlab_runner_config_file_system_mode: "/etc/gitlab-runner/config.toml" -__gitlab_runner_config_file_user_mode: "~/.gitlab-runner/config.toml" +__gitlab_runner_config_file_system_mode: /etc/gitlab-runner/config.toml +__gitlab_runner_config_file_user_mode: ~/.gitlab-runner/config.toml