This commit is contained in:
JMARyA 2023-12-04 11:02:23 +01:00
commit c5cd492449
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
475 changed files with 27928 additions and 0 deletions

View file

@ -0,0 +1,7 @@
# Ansible Test Plugins
Ansible Test Plugins let you check a variable on a condition.
- [ansible.builtin.exists](ansible.builtin.exists.md)
- [ansible.builtin.success](ansible.builtin.success.md)
- [ansible.builtin.url](ansible.builtin.url.md)
- [ansible.builtin.search](ansible.builtin.search.md)

View file

@ -0,0 +1,9 @@
# ansible.builtin.exists
Check if the provided path maps to an existing filesystem object on the controller (localhost).
## Examples
```yml
vars:
my_etc_hosts_exists: "{{ '/etc/hosts' is exist }}"
list_of_local_files_to_copy_to_remote: "{{ list_of_all_possible_files | select('exists') }}"
```

View file

@ -0,0 +1,16 @@
# ansible.builtin.search
Compare string against regular expression using Pythons `search` function.
## Parameters
| Parameter | Type | Description |
| -------------- | -------------------------- | --------------------------------------- |
| **ignorecase** | boolean (default: `false`) | Use case insenstive matching. |
| **multiline** | boolean (default: `false`) | Match against multiple lines in string. |
| **pattern** | string / required | Regex to match against. |
## Examples
```yml
url: "https://example.com/users/foo/resources/bar"
foundmatch: url is search("https://example.com/users/.*/resources")
alsomatch: url is search("users/.*/resources")
```

View file

@ -0,0 +1,8 @@
# ansible.builtin.success
Tests if task finished successfully, opposite of `failed`. Input is a registered result from an Ansible task.
## Example
```yml
# test 'status' to know how to respond
{{ taskresults is success }}
```

View file

@ -0,0 +1,19 @@
# ansible.builtin.url
Validates a string to conform to the URL standard.
## Parameters
| Parameter | Type | Description |
| ----------- | ---------------------- | ---------------------------------------------------------------------------------------- |
| **schemes** | list / elements=string | Subset of URI schemas to validate against, otherwise **any** scheme is considered valid. |
## Examples
```yml
# simple URL
{{ 'http://example.com' is url }}
# looking only for file transfers URIs
{{ 'mailto://nowone@example.com' is not uri(schemes=['ftp', 'ftps', 'sftp', 'file']) }}
# but it is according to standard
{{ 'mailto://nowone@example.com' is not uri }}
# more complex URL
{{ 'ftp://admin:secret@example.com/path/to/myfile.yml' is url }}
```