i am trying to set a variable based on the value of a variable in the config file but unable to do so.
here’s my config file:
sql_ver: “2012” # available sql versions are: 2008 | 2012 | 2014 | 2016
sp_ver: “2010” # available sp versions are: 2007 | 2010 | 2013 | 2016
sp2k10: en_sharepoint_server_2010_with_service_pack_2_x64_dvd_4178583.iso
sp2k13: en_sharepoint_server_2013_with_sp1_x64_dvd_3823428.iso
sp2k16: en_sharepoint_server_2016_x64_dvd_8419458-003.iso
sql2k12: en_sql_server_2012_standard_edition_with_service_pack_3_x64_dvd_7286878.iso
sql2k14: en_sql_server_2014_standard_edition_with_service_pack_2_x64_dvd_8961564
sql2k16: en_sql_server_2016_standard_with_service_pack_1_x64_dvd_9540929
and my ansible file is:
- name: Software Version Selection
hosts: localhost
vars_files: - testcfg.yml
gather_facts: false
tasks:
-
debug:
msg: “{{sp_ver}}” -
set_fact:
sp : “{{sp2k10}}”
when: “{{sp_ver}} == 2010”
sp : “{{sp2k13}}”
when: “{{sp_ver}} == 2013”
sp : “{{sp2k16}}”
when: “{{sp_ver}} is match(2016)”
- debug:
msg: “{{sp}}”
i have tried many things: “{{sp_ver}} == 2010” , “{{sp_ver}}” == 2010, “{{sp_ver}} is match(2016)” but nothing worked. i dont know why there is a syntax error for this: “{{sp_ver}}” is match(2016)
basically what is want is for the selected sp_ver, the proper variable gets selected.
Thanks in advance
Ali