6

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

4

1 回答 1

10

外部变量会自动继承到角色中,因此project_name: "{{ project_name }}"没有必要。将您的角色声明更改为:

- project

...并且该{{ project_name }}变量将按原样在您的角色中可用。

于 2014-02-12T20:20:11.567 回答