Skip to content

Instantly share code, notes, and snippets.

@halberom
Last active December 19, 2017 10:34
Show Gist options
  • Select an option

  • Save halberom/1755d24b7bbd5472f2487c2e4aa4ba41 to your computer and use it in GitHub Desktop.

Select an option

Save halberom/1755d24b7bbd5472f2487c2e4aa4ba41 to your computer and use it in GitHub Desktop.
ansible - using assert with regex and quotes
PLAY [localhost] **********************************************************************************************************************
TASK [assert] *************************************************************************************************************************
ok: [localhost] => (item=\') => {
"changed": false,
"item": "\\'",
"msg": "All assertions passed"
}
ok: [localhost] => (item=\") => {
"changed": false,
"item": "\\\"",
"msg": "All assertions passed"
}
PLAY RECAP ****************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
---
- hosts: localhost
connection: local
gather_facts: False
vars:
some_var: hello
tasks:
- assert:
that:
- some_var | regex_replace('(.*)', item ~ '\\1' ~ item) == item ~ some_var ~ item
with_items:
- \'
- \"
@soar

soar commented Dec 19, 2017

Copy link
Copy Markdown

Ansible syntax is awesome, like it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment