Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ansible: recursive loop detected in template string

In a playbook, I am using a role this way:

- { role: project, project_name: "{{project_name}}" }

And in the "project" role, I actually have a dependency that wants to use the project_name variable of the "project" role:

---
dependencies:
  - { 
      role: users, 
      users: [
        { 
            name: "{{project_name}}", 
            home: "/home/{{project_name}}",
            shell: "/bin/bash",
            group: "{{project_name}}",
        }
     ]
   }

But I get an error:

recursive loop detected in template string: {{project_name}}

Is changing the name of the "project_name" variable the only solution?

Thanks

like image 280
Michael Avatar asked Feb 12 '14 20:02

Michael


1 Answers

External variables are inherited into roles automatically, so project_name: "{{ project_name }}" isn't necessary. Change your role declaration to:

- project

... and the {{ project_name }} variable will be available within your role as-is.

like image 122
Ash Wilson Avatar answered Nov 09 '22 01:11

Ash Wilson