mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 16:02:19 +00:00
017c3d3343
Ansible scripts previously lacked the AI assistant and the contextual
variable helper that other scripting languages expose in the script editor.
- Add 'ansible' to SUPPORTED_CHAT_SCRIPT_LANGUAGES so the AI chat button
shows in the editor toolbar and the AI chat opens in SCRIPT mode without
the "language not supported" warning.
- Add an Ansible system prompt (system_prompts/languages/ansible.md) plus a
LANGUAGE_METADATA entry, and regenerate the auto-generated prompts/skills
so the AI has tailored Ansible context.
- Show the contextual variable picker for ansible and insert references as
`{{ lookup('env', 'NAME') }}`, matching how Windmill exposes reserved
variables as environment variables to the ansible-playbook process.
Fixes WIN-2072
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2.4 KiB
2.4 KiB
Ansible
Windmill runs Ansible playbooks with ansible-playbook. A script is a single YAML
document made of two parts separated by a --- line: a Windmill header and one or
more standard Ansible plays.
Structure
---
# Windmill header: configures inventories, file resources, arguments and dependencies
extra_vars:
world_qualifier:
type: string
dependencies:
galaxy:
collections:
- name: community.general
python:
- jmespath
---
# Standard Ansible plays
- name: Echo
hosts: 127.0.0.1
connection: local
tasks:
- name: Print debug message
debug:
msg: "Hello, {{ world_qualifier }} world!"
Header
The header is not standard Ansible — it is parsed by Windmill to build the script's inputs and runtime environment. Supported keys:
extra_vars: defines the script arguments. Each entry is passed to the playbook via--extra-varsand becomes a Jinja variable usable as{{ name }}in the plays. Give each argument atype(string,number,boolean,object, ...) so Windmill can generate the input form.inventory: lists inventories. Useresource_type: ansible_inventory(optionally pinned withresource: u/user/your_resource) orresource_type: dynamic_inventory.files: writes Windmill resources/variables to files before the run, e.g.- resource: u/user/templatewithtarget: ./config.j2, or- variable: u/user/ssh_keywithtarget: ./ssh_keyandmode: '0600'.dependencies:galaxycollections/roles (installed withansible-galaxy) andpythonpip packages available to the playbook.options: extraansible-playbookflags such as- verbosity: vvv.vault_password: a Windmill variable path to use as the Ansible Vault password.
Arguments
Reference header extra_vars directly as Jinja variables in the plays:
extra_vars:
name:
type: string
count:
type: number
---
- hosts: localhost
tasks:
- debug:
msg: "{{ name }} x {{ count }}"
Environment variables
Windmill contextual variables are available as environment variables and read with the
env lookup:
- debug:
msg: "Running in workspace {{ lookup('env', 'WM_WORKSPACE') }}"
Output
To return a result, write JSON to a result.json file in the job directory:
- hosts: localhost
tasks:
- name: Write result
copy:
content: "{{ { 'ok': true, 'value': 42 } | to_json }}"
dest: result.json