# `hermes config get` prints the value as YAML, so it's compared # structurally; `hermes config set` takes JSON for lists and booleans. # Settings are always set explicitly: for a key that isn't in config.yaml, # `config get` (non-interactive) prints just the default, so "unset" can't be # detected. - name: Read Hermes settings ansible.builtin.command: argv: ["{{ hermes_cli }}", config, get, "{{ item.key }}"] loop: "{{ hermes_settings | dict2items }}" register: hermes_settings_current changed_when: false check_mode: false - name: Set Hermes settings ansible.builtin.command: argv: >- {{ [hermes_cli, 'config', 'set', item.item.key, item.item.value if item.item.value is string else item.item.value | to_json] }} loop: "{{ hermes_settings_current.results }}" loop_control: label: "{{ item.item.key }} = {{ item.item.value | to_json }}" when: (item.stdout | from_yaml) != item.item.value # The dashboard is a separate process with its own copy of the settings. notify: [Restart Hermes gateway, Restart Hermes dashboard]