Ansible Tutorial
we can use "in" operator in ansible to check whether one string is matched partially or entirely another string in ansible expressions or conditions.
Lets us see the simple example to find the partial string match in another string using the "in" operator.
- hosts: localhost connection: local gather_facts: no vars: string1: "teststring-0" string2: "teststring-0-additional-string" tasks: - name: Checks partial string set_fact: result: "{{ string1 in string2}}" register: result - name: Print the var debug: var: result
Output:
$ ansible-playbook test3.yml PLAY [localhost] ************************************************************************************************************************************************************ TASK [Checks partial string] ********************************************************************************************************************************************************* ok: [localhost] TASK [Print the var] ******************************************************************************************************************************************************** ok: [localhost] => { "result": true }
Ansible Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page