Created
December 3, 2018 22:27
-
-
Save leonardonsantos/885a7e116d9f36ed9a98efb107794015 to your computer and use it in GitHub Desktop.
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
--- | |
- hosts: localhost | |
connection: local | |
gather_facts: no | |
vars: | |
var_name: "william" | |
var_port: "80" | |
tasks: | |
- set_fact: | |
json_str: | | |
{ | |
"title": "_NAME_", | |
"port": _PORT_ | |
} | |
- debug: var=json_str | |
- set_fact: | |
json_str_with_variables: "{{ json_str | regex_replace('_NAME_', var_name) | regex_replace('_PORT_', var_port) }}" | |
- debug: var=json_str_with_variables | |
- set_fact: | |
my_dict: | |
some: thing | |
data: "{{ json_str_with_variables }}" | |
- debug: var=my_dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: