Add the ability to use multiexpression without runLocal #388
Replies: 4 comments
-
|
You can do this bywriting your own functions. there is This allows you to extent custom remote functions to query ldap, pagination rest calls, etc... you can copy and adapt the
|
Beta Was this translation helpful? Give feedback.
-
|
Additionally I could suggest to first show a filter field that allows input and requires at least 3 chars. Then using a dependency query fetch the inventory with a filter. This will allow you find hosts without pagination.. but this is just a work around. Writing your own pagination rest function is the better option. Feel free to share or create a pull request... if the function is highly reusable, I could include it in the default.js |
Beta Was this translation helpful? Give feedback.
-
|
Ok, thank you for the answer, great I read here how to do that https://ansibleforms.com/faq/ at the section of custom.js and is very easy with docker, but I cannot do that directly using the helm chart, so at this point I would like to suggest if posible to look into this pull request that I personally tested and works: If you are open to an aditional pull request I would gladly add another one to map another cm to /app/dist/src/functions/custom.js Also another cool thing would be that the when we setup a git repository in the same way we can place forms.yaml and dir forms/$whateverform.yaml we could also place at git repository another directory called functions/ with the file custom.js |
Beta Was this translation helpful? Give feedback.
-
|
Created a pull request here to enable the config map for custom.js : Take a look please, when thats merged I will begin trying to create the javascript function (probably something like awx hostname, inventoryname, groups, hostvarkeyspresent) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
Enchance feature . Currently if we want to create a form that is attached to an awx inventory enterprise grade , which usually have beetween 1000 and 3000 hosts, its not possible to show all the hosts in a menu (drop down box) using a sinble API transaction because it would require pagination .
The problem is that the awx API limits the number of results to 200 and then we need pagination .
Pagination is not posible right now without using multi expressions (not allowed) or runlocal (not desirable for security)
Describe the solution you'd like
In order to get a pagination process we would need something like this in the form (let imagine a form that allows to select a host from a big awx inventory from a drop down box) :
fields:
name: vm_name
label: VM to decommission
type: enum
required: true
default: auto
expression: >
(
() => {
const baseUrl = 'https://awx.somedomain.net/api/v2';
const cred = 'cr_awx_rest';
)()
columns:
valueColumn: name
But thats not allowed I get that errors:
2025-11-25 21:38:01:381 error: Error in expression : Error: Abuse attempt of eval function, attempt to have multi expression, try runLocal
So I could try runlocal but then the awx credential goes over the client web browser which is not desirable .
Describe alternatives you've considered
We can finetune awx API to allow more than 200 results but the documentation states is not reconmended for stability purposes
We could use runlocal probably but its also not desirable
Beta Was this translation helpful? Give feedback.
All reactions