diff --git a/docs/getting_started/0_scripts_quickstart/9_ansible_quickstart/index.mdx b/docs/getting_started/0_scripts_quickstart/9_ansible_quickstart/index.mdx index 53cb35e0..7fd72c94 100644 --- a/docs/getting_started/0_scripts_quickstart/9_ansible_quickstart/index.mdx +++ b/docs/getting_started/0_scripts_quickstart/9_ansible_quickstart/index.mdx @@ -97,7 +97,7 @@ inventory: # File resources will be written in the relative \`target\` location before # running the playbook -file_resources: +files: - resource: u/user/fabulous_jinja_template target: ./config_template.j2 @@ -164,6 +164,16 @@ extra_vars: The type definition is inspired and tries to follow the [OpenAPI Data Types standard](https://swagger.io/docs/specification/data-models/data-types/). Note that not all features / types are supported, the best way to know what is supported is to test it out in the Web IDE. +:::tip Argument defaults +You can set a default value for your arguments by using a `default:` field, for example: +```yml +extra_vars: + my_string: + type: string + default: 'Fascinating String of Words' +``` +::: + To use windmill resources as types you can use the following type definition: ```yaml @@ -175,7 +185,28 @@ extra_vars: ![Postgres Resource UI](./postgres_ui.png) -Under the hood, Windmill will pass these variables using the `--extra-args` flag to Ansible, so you can expect the according behavior. +Under the hood, Windmill will pass these variables using the `--extra-vars` flag to Ansible, so you can expect the according behavior. + +### Static resources and variables + +Resources and variables that are hardcoded to a particular script can also be defined in the `extra-vars` section. This is because they are similarly passed through the `--extra-vars` flag in the ansible playbook. + +This is what the syntax looks like: +```yml +extra_vars: + my_variable: + type: windmill_variable + variable: u/user/my_variable + my_resource: + type: windmill_resource + resource: u/user/my_resource +``` + +Under `resource` or `variable` you can statically link the path to the resource/variable. As you do, you will notice the UI update and hide the resource input as it is now static. + +:::tip About static and non-static variables +Note that Variables defined this way can only be static. If you want to use non-static Variables, define a normal argument with `type: string` and from the UI fill it with one of your Variables or Secrets. +::: ### Return Values @@ -227,7 +258,7 @@ Then the UI will not prompt you for the inventory but will use this resource at It sometimes happens that your Ansible playbook depends on some text file existing at a relative path to the playbook. This can be a configuration file, a template, some other file that you can't inline or otherwise is simpler to keep as a separate file. In this case, Windmill offers a feature to create these files at the specified path before running the playbook. The syntax will be the following: ```yaml -file_resources: +files: - resource: u/user/fabulous_jinja_template target: ./config_template.j2 ``` @@ -236,7 +267,22 @@ To create text file resource type and resources, refer to [creating plain text r In the example above, the resource `u/user/faboulous_jinja_template` is a special plain text file resource. The target `./config_template.j2` is the path relative to the playbook where the file will be created and where the playbook can access it. -Now you can write your notebook assuming that this file will exist at the time of execution. +Now you can write your playbook assuming that this file will exist at the time of execution. + +#### Variable inside files + +If you want to achieve a similar effect with a variable or a secret, you can use a similar syntax: + +```yaml +files: + - resource: u/user/my_ssh_key + target: ./id_rsa +``` + +And the content of the variable will be written to the file. + +This is useful when you want to store the data in a secret for example, like you would do for ssh keys. + ### Dependencies