EVAL OF Variable

23 views
Skip to first unread message

Michael Burch

unread,
Aug 17, 2022, 1:19:45 PM8/17/22
to Ansible Project
Good afternoon Group.  Any help is appreciated.

I have a survey that collects the name of a project (project_name).  Lets call it SKILL

I have variables set in the playbook for all the projects to save their USER and Password Info.
- SKILL_UNAME
- SKILL_PWORD

I have a task that has to account for the project name and pull the values from those variables to set a temp variable in the task. Unfortunately, I keep getting an error when attempting to do a lookup and get the value of the variable:
set_fact:
   temp_uname: "{{ lookup('vars', project_name + '_UNAME' }}" 
   temp_pword: "{{ lookup('vars', project_name + '_PWORD' }}"


Error reads: template error while templating string: unexpected '}', expected ')'. String: {{ lookup('vars',  project_name + '_UNAME' }}"

Any help is appreciated!

Richard Megginson

unread,
Aug 17, 2022, 1:22:41 PM8/17/22
to ansible...@googlegroups.com
On Wed, Aug 17, 2022 at 11:19 AM Michael Burch <mjbu...@gmail.com> wrote:
Good afternoon Group.  Any help is appreciated.

I have a survey that collects the name of a project (project_name).  Lets call it SKILL

I have variables set in the playbook for all the projects to save their USER and Password Info.
- SKILL_UNAME
- SKILL_PWORD

I have a task that has to account for the project name and pull the values from those variables to set a temp variable in the task. Unfortunately, I keep getting an error when attempting to do a lookup and get the value of the variable:
set_fact:
   temp_uname: "{{ lookup('vars', project_name + '_UNAME' }}" 
   temp_pword: "{{ lookup('vars', project_name + '_PWORD' }}"

Missing closing parentheses
 
   temp_uname: "{{ lookup('vars', project_name + '_UNAME') }}" 
   temp_pword: "{{ lookup('vars', project_name + '_PWORD') }}"



Error reads: template error while templating string: unexpected '}', expected ')'. String: {{ lookup('vars',  project_name + '_UNAME' }}"

Any help is appreciated!

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1a99e752-6d8b-4c9e-855b-e55a28bc499dn%40googlegroups.com.

Michael Burch

unread,
Aug 17, 2022, 2:54:15 PM8/17/22
to Ansible Project
Yes.... Resolved....

Thanks,

Reply all
Reply to author
Forward
0 new messages