Ansible: Using Python string substituition in variables
Advertisement
Scenario: Utilize Pythons string substitution in Ansible variables
- hosts: localhost
connection: local
vars:
foobar: ">>%s<<"
substitution: "adminswerk.de"
tasks:
- debug:
msg: "{{ foobar % substitution }}"
Output (slightly truncated):
$ ansible-playbook string_format.yml
PLAY [localhost] **********************************************************************************************************************************************
TASK [debug] **************************************************************************************************************************************************
ok: [localhost] => {
"msg": ">>adminswerk.de<<"
}
PLAY RECAP ****************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0