Describe the bug
I'm trying to set the value of value_raw to a variable instead of hardcoding it in the task, so I can reuse the same task for multiple rules. Unfortunately I get the error "Unsupported type. Field must be string". The same task with the value_raw explicitly set works fine. Seems to be an escaping issue, and I'm not 100% the issue is with the collection honestly.. but I'm banging my head on this so any help is appreciated.
Component Name
tribe29.checkmk.rule
Ansible Version
$ ansible --version
ansible 2.10.8
python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
Checkmk Version
Checkmk Raw Edition 2.1.0p13
Collection Version
$ ansible-galaxy collection list
tribe29.checkmk 0.11.0
To Reproduce
Steps to reproduce the behavior:
Execute this task:
- name: "Create a rule."
tribe29.checkmk.rule:
server_url: "{{ hostvars['checkmk'].checkmk_url }}"
site: "{{checkmk_site}}"
automation_user: "{{ hostvars['checkmk'].checkmk_user }}"
automation_secret: "{{ hostvars['checkmk'].checkmk_secret }}"
ruleset: "checkgroup_parameters:memory_percentage_used"
rule:
properties: {
"comment": "Warning at 80%\nCritical at 90%\n",
"description": "Allow higher memory usage",
"disabled": false
}
value_raw: "{{ myvariable }}"
state: "present"
vars:
- myvariable: "{'levels': (80.0, 90.0)}"
If I replace value_raw: "{{ myvariable }}" to value_raw: "{'levels': (80.0, 90.0)}" the task works fine.
Expected behavior
Rule to be created using the value in "myvariable"
Actual behavior
The following error is printed:
"msg": "Error calling API. HTTP code 400. Details: b'{\"title\": \"Bad Request\", \"status\": 400, \"detail\": \"These fields have problems: value_raw\", \"fields\": {\"value_raw\": [\"Unsupported type. Field must be string.\"]}}', "
Additional context
I suspect the issue is caused by the curly bracket required by the API which make ansible interpret the variable's value as a dictionary instead of a string. But I couldn't find a way to escape that and make it works with the API.
Describe the bug
I'm trying to set the value of value_raw to a variable instead of hardcoding it in the task, so I can reuse the same task for multiple rules. Unfortunately I get the error "Unsupported type. Field must be string". The same task with the value_raw explicitly set works fine. Seems to be an escaping issue, and I'm not 100% the issue is with the collection honestly.. but I'm banging my head on this so any help is appreciated.
Component Name
tribe29.checkmk.rule
Ansible Version
Checkmk Version
Collection Version
To Reproduce
Steps to reproduce the behavior:
Execute this task:
If I replace
value_raw: "{{ myvariable }}"tovalue_raw: "{'levels': (80.0, 90.0)}"the task works fine.Expected behavior
Rule to be created using the value in "myvariable"
Actual behavior
The following error is printed:
Additional context
I suspect the issue is caused by the curly bracket required by the API which make ansible interpret the variable's value as a dictionary instead of a string. But I couldn't find a way to escape that and make it works with the API.