Im trying to set a variable based on below condition where templname is an
external variable with below options
ansible-playbook -i hosts -e "templname=CTrl03_kerbs_09"
OR
ansible-playbook -i hosts -e "templname=CTrl05"
set_fact:
dbn: "{{ CTrl03_kerbs_09 | lower }}
dbnum: "{ % 'prefix-' + templname.split('_')[-1] if '_' in templname
else 'prefix' %}" ##if templname contains "_" then dbnum should append
"prefix-" to the last digit of templname i.e I want "prefix-9"
I want vars set like below:
1)
dbn = ctrl03_kerbs_09
dbnum = prefix-9
2)
dbn = ctrl05
dbnum = prefix
But this doesngt seem to work? Any problem in syntax? I get syntax error...
Also is there a ansible way to check if the string(templname) contains
digits??
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/309b7ced-c42c-4ab9-869f-e4d57bc67e9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.