Skip to content

Commit

Permalink
Merge pull request #241 from crazychatting/key-value-quotes
Browse files Browse the repository at this point in the history
Config property keys not always in quotes with to_json
  • Loading branch information
riemers committed Jun 27, 2022
2 parents b7e1bfb + 18488d9 commit 6282400
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tasks/line-config-runner-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 10 additions & 0 deletions tasks/line-config-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 6282400

Please sign in to comment.