I have tried parsing “from_json" to the above play and ended up with the error:
“({{ rule | json_query(‘[*].definition’) | from_json }}): the JSON object must be str, bytes or ``bytearray, not ‘list’”}”
is there a way to convert list to string in ansibe? if not, any other suggestions would be appreciated to achieve “Expected output”`
I have tried parsing "*from_json"* to the above play and ended up with the error:
"({{ rule | json_query('[*].definition') | from_json }}): the JSON object must be str, bytes or ``bytearray, not 'list'"}"
is there a way to convert list to string in ansibe? if not, any other suggestions would be appreciated to achieve
"Expected output"`
As a json_query can have multiple results, the result of that filter is a list.
To get the first result you can use irules[0] or irules | first.
Thank you for your response. I have used pause module and it got printed as expected. Is there a way to store that printed content in variable? I have to copy that content to a file and add few extra lines to that file and have to apply that configuration content to firewall. Please let me now if you need any info
play
pause:
seconds: 1
prompt: “{{ irules[0] }}”
output:
Pausing for 1 seconds
(ctrl+C then ‘C’ = continue early, ctrl+C then ‘A’ = abort)
[pause]
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
“HAC” { pool char.hr.cal.ed.HAC.pool }