Hi,
I need to replace characters in strings so i can change ‘com.bar.foo’ into ‘com/bar/foo’
common_vars.yml:
Hi,
I need to replace characters in strings so i can change ‘com.bar.foo’ into ‘com/bar/foo’
common_vars.yml:
I need to replace characters in strings so i can change 'com.bar.foo' into
'com/bar/foo'
The only thing that occurs to me is
tasks:
- local_action: shell echo "${group_id}" | sed 's|\.|/|g'
register: new_group_id
Then use ${new_group_id.stdout}
Overkill probably ...
-JP
also sprach Clifford Sanders <clifford650@gmail.com> [2013.06.20.1428 +0200]:
Did you try ${foo.replace(…)} ?
Starting with version 1.2, you should be able to use Jinja2 filters:
{{ foo | replace('.', '/') }}
You shouldn’t even need to know it’s Jinja2 since we can access the .replace method on the string itself.
{{ foo.replace(‘.’,‘/’) }}
Should you wish to store this result, the new “set_fact” module in 1.2 provides an easy way to do that without the “register” trick JP Mens showed as well.
You shouldn't even need to know it's Jinja2 since we can access the .replace
method on the string itself.{{ foo.replace('.','/') }}
Should you wish to store this result, the new "set_fact" module in 1.2
provides an easy way to do that without the "register" trick JP Mens showed
as well.
AFAIK, these solutions are *not* available with ansible 1.1
I know because I was looking for it and had to solve with a
"local_action" as well..
.a.
Correct, Ansible 1.2 is where “{{ these }}” were added, to unify the way variables and templates work between templates and playbooks.
Thank you all for your support.
I’m trying to update to 1.2 but have a problem using this version in my vagrant development environment. This could be related to https://github.com/ansible/ansible/pull/3147.
Regards,
Clifford