Forms
Forms are added as YAML files in the forms folder. Each YAML file can contain a single form or a list of forms. Subfolders are supported if you want to organize your forms. Forms are the core of AnsibleForms. Each form represents a web interface that collects user input and executes an Ansible playbook or AWX/Tower template with that data.
VIDEO: Create your first form
Understanding Form Structure
Every form in AnsibleForms is a Form Object. This object contains all the configuration for a single form, including its name, type, roles, categories, and fields.
A basic form looks like this:
forms:
- name: Create VM
type: ansible
playbook: playbooks/create_vm.yml
roles:
- admin
categories:
- Provisioning
fields:
- name: vm_name
type: text
label: VM Name
See the Form Object Reference section below for all available attributes and configuration options.
How forms are loading
AnsibleForms loads forms from the following locations:
- FROM REPOSITORIES : All repositories with “use for forms” switch enabled (supports multiple repositories)
- Forms are automatically merged from all enabled repositories
- First checks for a
forms/subfolder in each repository - Falls back to repository root if
forms/subfolder doesn’t exist
- FROM LOCAL FOLDER : The local
forms/folder (FORMS_FOLDER_PATH environment variable) if no repositories are configured
Note: You can enable “use for forms” on multiple repositories and all forms will be merged together. Make sure form names are unique across repositories to avoid conflicts.
Form Object Reference
Each form in the forms list is configured with the below attributes.
| Attribute | Comments |
|---|---|
| basic | |
| name string / required / unique | The name of the form
The name of a form is also the identifier of the form and thus must be unique. |
| roles array / required | Who has access
You can have RBAC by adding roles to a form. If you want everyone to see the form, add the Examples: 1) Give access to vmware team |
| categories array | Categories
By adding one or more categories, you can group forms together in categories. Examples: 1) Category vmware |
| description string | Form description
A short description, explaining what the form does. |
| help string | Help
Using markdown you can a more detailed help message to help the operator understand the form. Examples: 1) blockquote with title, list, italic and bold |
| type string | Form type
Our form eventually sends extravars to a target. That target can be an ansible-playbook, an awx-template or a multistep (which is a list or combination of multiple playbooks/templates, executed sequentially). Choices:
Examples: 1) Run AWX Template Create VM 2) Run Delete VM playbook 3) Run multistep job |
| template string | Awx template
This attribute is only used when the form type is Note : You can also dynamically set the template by using a field called Only available with types: awx Examples: 1) Run AWX Template Helloworld 2) Use dynamic template name |
| playbook string | Ansible playbook
This attribute is only used when the form type is Note : You can also dynamically set the playbook by using a field called Only available with types: ansible Examples: 1) Run foobar playbook 2) Use dynamic playbook name |
| credentials object added in version 4.0.16 | Send credentials to your playbook/template
From the earlier versions, you could send credentials, stored in Ansible Forms, by using the field-property Examples: 1) Send vmware and microsoft credentials 2) Dynamically send credentials |
| ansibleCredentials string added in version 4.0.17 | Pass ansible_user and ansible_password to ansible playbook using stored credentials
Ansible allows to pass default ansible credentials in the form of 2 extravars ansible_user and ansible_password |
| playbookSubPath string added in version 6.0.1 | Subfolder structure for playbooks
If you have a more complex ansible setup, you might want to organize them in subfolders. Use this property to define a subfolder (or multiple levels) where you want to launch ansible-playbook from. |
| vaultCredentials string added in version 5.0.2 | Pass vault password to ansible playbook using stored credentials
Ansible can encrypt variables in a vault, to unlock the vault a password is needed. This password can be stored in Ansible Forms (as credential) and passed to the playbook.. |
| steps array | Multistep steps
A multistep form is basically an array of multiple form type destinations, defined here as steps. Only available with types: multistep |
| varsFiles array added in version 6.1.0 | Load YAML files as constants
Load one or more YAML files as constants that will be merged with the base config constants. Files must contain a dictionary (not a list) and must have .yml or .yaml extension. Path Resolution:
Use Cases:
Note: Files are merged in order. Later files override earlier ones if keys conflict. Variables from varsFiles are merged with base config constants. Examples: 1) Load single vars file 2) Load multiple vars files with absolute paths 3) Mix relative and absolute paths |
| fields array | fields
It makes sense that a form has 1 or more formfields. Read more about them in the separate formfield section. Examples: 1) Examples |
| interaction | |
| approval object | Add approval point
Ansible Forms allows to add an approval point before a job is ran. |
| notifications object | Add Notification
Add email notifications on job status events. Examples: 1) Send on success |
| onSubmit array added in version 3.1.0 | Events on submit
Once a job is launched, Ansible Forms has a few status events you can act on.
Follow the link above to learn about the possible job status actions Examples: 1) Examples |
| onSuccess array added in version 3.1.0 | Events on success
Once a job is launched, Ansible Forms has a few status events you can act on.
Follow the link above to learn about the possible job status actions Examples: 1) Examples |
| onFailure array added in version 3.1.0 | Events on failure
Once a job is launched, Ansible Forms has a few status events you can act on.
Follow the link above to learn about the possible job status actions Examples: 1) Examples |
| onAbort array added in version 3.1.0 | Events on abort
Once a job is launched, Ansible Forms has a few status events you can act on.
Follow the link above to learn about the possible job status actions Examples: 1) Examples |
| onFinish array added in version 3.1.0 | Events on finished
Once a job is launched, Ansible Forms has a few status events you can act on.
Follow the link above to learn about the possible job status actions Examples: 1) Examples |
| visualization | |
| showHelp boolean | Show Help
Show the help by default or collapse the help. Default: true |
| icon string | Form icon
You can add a nice icon to your forms. The icon name is a free fontawesome 6 icon. You can find more information at www.fontawesome.com. Examples: 1) Trash icon |
| iconColor string | Icon color
Specifies the color of the icon. Use any valid CSS color class name (e.g., primary, success, danger, warning, info, dark, white, …). Examples: 1) Red icon |
| iconSize string | Icon size
Specifies the size of the icon. Default: 3x Examples: 1) Large icon |
| overlayIcon string | Overlay icon on main icon
Adds a icon on top of the main icon for layering effects. Useful for status indicators or badges. Examples: 1) Server with check overlay |
| overlayIconTransform string | Transform for overlay icon
Specifies the transform/positioning for the overlay icon. You can use FontAwesome transform values like shrink, grow, up, down, left, right. Default: shrink-6 up-7 right-7 Examples: 1) Custom positioned overlay |
| overlayIconColor string | Color for overlay icon
Specifies the color of the overlay icon. Default: success Examples: 1) Red overlay icon |
| overlayIconCircle boolean | Show circle background behind overlay icon
When enabled, shows a colored circle background behind the overlay icon. The circle uses the overlayIconColor, and the icon inside becomes white in light mode or dark in dark mode. When disabled, the overlay icon appears without a circle background. Default: true Examples: 1) Overlay without circle |
| overlayIconText string | Text overlay on icon
Adds text as an overlay on the icon. Can be used for badges, counters, or labels. Examples: 1) New badge |
| overlayIconTextPosition string | Position for text overlay
Specifies the position of the text overlay. Default: bottom-left Examples: 1) Top right badge |
| overlayIconTextColor string | Color for text overlay
Specifies the color of the text overlay. Default: success Examples: 1) Warning badge |
| image string | Form image
You can add a nice image to your form. You can provide a local or remote url. But if you are in a secured location, you might want to go for a base64 encode image. This allows you to embed the image in the yaml file. Examples: 1) Microsoft image 2) Internet image 3) Local image |
| tileClass string | Form tile background colour
Ansible Forms uses the Bootstrap css framework to style the webapplication. Default: bg-info-subtle Examples: 1) warning color 2) success light color |
| fieldGroupClasses object | Fieldgroup background color
Ansible Forms uses the Bootstrap css framework to style the webapplication. Bootstrap has a few color helper classes you can use to give your fieldgroups a background color. You can find them here background color and foreground color. Examples: 1) Color fieldgroup |
| order integer added in version 5.1.0 | Order of the form in the list
The order of the form in the list of forms. Forms are sorted by this order, so you can have a specific order in the list. Note : If you do not set this property, it will be ordered alphabetically by name. |
| workflow | |
| inventory string | Inventory
In both awx and ansible core you can pass an inventory. In the case of ansible core, it will be a yaml file. In case of awx it will be the inventory name. Note : You can also dynamically set the inventory by using a field called |
| executionEnvironment string added in version 5.0.0 | Execution Environment
In newer versions of AWX you can choose an execution environment. Use this property to pass it to your template. Note : You can also dynamically set the executionEnvironment by using a field called |
| instanceGroups array or string added in version 5.0.0 | Instance Groups
In newer versions of AWX you can choose instance groups. Use this property to pass it to your template. Note : You can also dynamically set the instanceGroups by using a field called |
| scmBranch string added in version 5.0.0 | SCM Branch
Awx allows to pass the scm branch. Use this property to pass it to your template. Note : You can also dynamically set the scmBranch by using a field called |
| awx string added in version 6.0.0 | Add awx instance to your template
From now on you can have multiple AWX instances. The database will be updated during upgrade but you will need to set your current AWX instance to default. Note : you can also set these dynamically by using a field called Examples: 1) Add awx instance to your template |
| awxCredentials array added in version 4.0.16 | Add awx credentials to your template
In AWX you can set credentials on your template. Note : you can also set these dynamically by using the a field name awxCredentials. It must be sent as extravar. If this extravar is found it will overwrite the static awxCredentials. Examples: 1) Add awx credentials to your template 2) Dynamically send credentials |
| check boolean | Run in check mode
In both awx and ansible core you run a playbook in check mode. Enable this attribute to do so. Note : You can also dynamically set the check mode by using a field called |
| limit text | Run against a limited number of hosts
In awx and ansible core you run a playbook against limited hosts by supplying a host pattern. Use this attribute to do so. Note : You can also dynamically set the limit by using a field called |
| diff boolean | Run in diff mode
In both awx and ansible core you run a playbook in diff mode. Enable this attribute to do so. Note : You can also dynamically set the check mode by using a field called |
| verbose boolean added in version 4.0.0 | Run in verbose mode
In ansible core you run a playbook in verbose mode. Enable this attribute to do so. Note : You can also dynamically set the verbose mode by using a field called |
| keepExtravars boolean added in version 4.0.0 | Do not remove the extarvars json file
In ansible core we temporarily store the extravars in a json file. After run, this file is removed. Use this property to disable this behaviour. Note : You can also dynamically set this property by using a field called |
| abortable boolean added in version 5.0.8 | Allow aborting the job
By default you can allow the user to abort the job. Use this attribute to disable this behaviour. Default: true |
| string | Set tags
In both awx and ansible core you can pass tags. Use this attribute to pass a comma separted list of tags. Note : You can also dynamically set the tags by using a field called |