Ansible: recursive loop found in pattern string

In the playbook, I use the role as follows:

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

And in the project role, I 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 message:

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

Does the variable name "project_name" change the only solution?

thank

+3
source share
1 answer

External variables are inherited in the role automatically, so project_name: "{{ project_name }}"it is not required. Change your role declaration to:

- project

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

+8
source

All Articles