ansibleguy76 / ansibleforms

A webapplication to create pretty advanced forms to run ansible playbooks or awx templates.
https://ansibleforms.com/
GNU General Public License v3.0
66 stars 10 forks source link

SSH expression returning 2 extra values - "" and "exit(0)" #138

Closed checkifexist closed 7 months ago

checkifexist commented 7 months ago

Describe the bug I am using enum field, and in expression I am get ls from remote ssh, its returning all file correctly, but 2 fields are extra - one is blank and other is exit(0). Also can we filter these through jq-expression, if yes, can anyone tell how?

To Reproduce Steps to reproduce the behavior:

Create below form label

Expected behavior enum dropdown containing only file that are actually present for eg - in my case files v1, v2.... v5 were present in that directory but it shows 2 extra selectable field empty and exit(0) Screenshots image on clicking eye button below json is shown image

Version ansibleforms:latest

Deployment Deployed ansibleforms with :- using ansibleforms-dockercompose

Additional context You can ask for more info

checkifexist commented 7 months ago

Updates: I have explicitly disabled to show last two rows, using jq-expression. Its working fine Used jq-expression : fn.fnSsh('<username>','<ipaddress>','ls' /home/files/','.[:-2]')

ansibleguy76 commented 7 months ago

This is by design. It is not necessarily returning an array. this is by design. It is not necessarily returning an array. it is simply returning the output, followed with the exit code. It is up to you to parse the content parse the exit code, and drop it if needed.