Last active
May 21, 2019 12:20
-
-
Save zeitounator/0725f6006101e28a5edd889f8132632e to your computer and use it in GitHub Desktop.
ansible complex string example proof for https://stackoverflow.com/a/56234698/9401096
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: complex string | |
hosts: localhost | |
gather_facts: false | |
vars: | |
DATABASE_LISTDELETED_RESOURCEGROUP: my_ressource_group | |
DATABASE_LISTDELETED_SQLSERVER: my_sql_server | |
DATABASE_LISTDELETED_QUERY: this is a line of text which mimics an actual query I don't have | |
tasks: | |
- name: Store my command in a var | |
set_fact: | |
my_command: >- | |
az sql db list-deleted | |
--resource-group "{{ DATABASE_LISTDELETED_RESOURCEGROUP }}" | |
--server "{{ DATABASE_LISTDELETED_SQLSERVER }}" | |
{% if DATABASE_LISTDELETED_QUERY is defined %} | |
--query "{{ DATABASE_LISTDELETED_QUERY }}" | |
{% endif %} | |
--output json | |
- debug: | |
var: my_command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [complex string] ********************************************************** | |
TASK [Store my command in a var] *********************************************** | |
ok: [localhost] | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"my_command": "az sql db list-deleted --resource-group \"my_ressource_group\" --server \"my_sql_server\" --query \"this is a line of text which mimics an actual query I don't have\" --output json" | |
} | |
PLAY RECAP ********************************************************************* | |
localhost : ok=2 changed=0 unreachable=0 failed=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: complex string | |
hosts: localhost | |
gather_facts: false | |
vars: | |
DATABASE_LISTDELETED_RESOURCEGROUP: my_ressource_group | |
DATABASE_LISTDELETED_SQLSERVER: my_sql_server | |
tasks: | |
- name: Store my command in a var | |
set_fact: | |
my_command: >- | |
az sql db list-deleted | |
--resource-group "{{ DATABASE_LISTDELETED_RESOURCEGROUP }}" | |
--server "{{ DATABASE_LISTDELETED_SQLSERVER }}" | |
{% if DATABASE_LISTDELETED_QUERY is defined %} | |
--query "{{ DATABASE_LISTDELETED_QUERY }}" | |
{% endif %} | |
--output json | |
- debug: | |
var: my_command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [complex string] ********************************************************** | |
TASK [Store my command in a var] *********************************************** | |
ok: [localhost] | |
TASK [debug] ******************************************************************* | |
ok: [localhost] => { | |
"my_command": "az sql db list-deleted --resource-group \"my_ressource_group\" --server \"my_sql_server\" --output json" | |
} | |
PLAY RECAP ********************************************************************* | |
localhost : ok=2 changed=0 unreachable=0 failed=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment