octoprint: allow additional user configuration of octoprint

Signed-off-by: Thomas Schmid <tom@lfence.de>
This commit is contained in:
Thomas 2022-01-11 20:22:29 +01:00
parent 3dfff93c0e
commit f4b6192bc1

View File

@ -52,11 +52,16 @@
- name: Default octoprint config - name: Default octoprint config
set_fact: set_fact:
octoprint_config: "{{ lookup('template', 'config.yaml.j2') | from_yaml }}" octoprint_default_config: "{{ lookup('template', 'config.yaml.j2') | from_yaml }}"
- name: Apply user config
set_fact:
octoprint_config_combined: "{{ octoprint_default_config | combine(octoprint_config, recursive=True)}}"
when: octoprint_config is defined
- name: Initial configuration of octoprint - name: Initial configuration of octoprint
copy: copy:
content: "{{ octoprint_config | to_nice_yaml }}" content: "{{ octoprint_config_combined | to_nice_yaml }}"
dest: "/home/{{ octoprint_user }}/.octoprint/config.yaml" dest: "/home/{{ octoprint_user }}/.octoprint/config.yaml"
when: not octoprint_register_config_stat.stat.exists when: not octoprint_register_config_stat.stat.exists
@ -73,7 +78,7 @@
- name: Write updated octoprint configuration - name: Write updated octoprint configuration
copy: copy:
content: "{{ octoprint_config | combine(current_octoprint_config, recursive=True) | to_nice_yaml}}" content: "{{ current_octoprint_config | combine(octoprint_config_combined, recursive=True) | to_nice_yaml}}"
dest: "/home/{{octoprint_user}}/.octoprint/config.yaml" dest: "/home/{{octoprint_user}}/.octoprint/config.yaml"
notify: Restart octoprint notify: Restart octoprint