diff --git a/tasks/line-config-runner-windows.yml b/tasks/line-config-runner-windows.yml index 85dbf21..c00a8cf 100644 --- a/tasks/line-config-runner-windows.yml +++ b/tasks/line-config-runner-windows.yml @@ -6,9 +6,19 @@ line: '{{ " " * (section.split(".")|length -1) }}[{{ section }}]' - 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 }}) =.*' + line: '{{ " " * (section.split(".")|length) }}{{ line }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}' + register: modified_config_line + when: "not '.' in line" + +- 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 }}) =.*' 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 2475344..6b149cf 100644 --- a/tasks/line-config-runner.yml +++ b/tasks/line-config-runner.yml @@ -6,9 +6,19 @@ 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 }}) =' + line: '{{ " " * (section.split(".")|length) }}{{ line }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}' + register: modified_config_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 }}) =' line: '{{ " " * (section.split(".")|length) }}{{ line | to_json }} = {{ gitlab_runner.extra_configs[section][line] | to_json }}' register: modified_config_line + when: "'.' in line"