From 18488d971aa0fca8d3ca819011a7761ab6d14d35 Mon Sep 17 00:00:00 2001 From: Robin Loose Date: Tue, 7 Jun 2022 11:39:13 +0200 Subject: [PATCH] Config property keys not always in quotes to_json the keys for extra-config-options should not always be in quotes. this happens because every line is filtered with to_json. this will only apply if the key contains a dot. --- tasks/line-config-runner-windows.yml | 10 ++++++++++ tasks/line-config-runner.yml | 10 ++++++++++ 2 files changed, 20 insertions(+) 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"