@@ -222,6 +222,33 @@ Deployment jobs also support _optional_ **hook scripts** from your project, loca
*`pre-ansible-playbook.sh` is executed **before** running `ansible-playbook`, to perform specific environment pre-initialization such as generating a dynamic inventory
*`post-ansible-playbook.sh` is executed **after** running `ansible-playbook`, to perform specific environment post-initialization
### Ansible commands overrides
Instead of creating hook scripts, you can also override and/or decorate the Ansible commands
using predefined `.ansible-commands` template block, referenced by the [`!reference` directive](https://docs.gitlab.com/ee/ci/yaml/#reference-tags).
By default, the `.ansible-commands`, block is composed as below:
```yaml
.ansible-commands:
deploy:
-!reference[.ansible-commands,default,deploy]
cleanup:
-!reference[.ansible-commands,default,cleanup]
```
You can override it for example in the following way:
```yaml
.ansible-commands:
deploy:
-source sandbox.env
-!reference[.ansible-commands,default,deploy]
-echo "I'm executed after the Ansible deploy command"
```
You can use this mechanism to source to the current shell your own environmental variables.
#### Static vs. Dynamic environment URLs
The Ansible template supports two ways of defining your environments url: