0

需要帮助以查看此 include_role 有什么问题。

这项工作没有任何问题:

#US East (N. Virginia)
- hosts: localhost
  gather_facts: false
  connection: local
  vars:
    region_services:
      - "us-east-1"
  tasks:
    - name: 3 run - should loop and print dynamic var
      include_role: name=nginx
      when: aws_region_name == "us-east-1"
      with_items:
        - "{{ region_services }}"

这通过调用任何额外的角色不起作用:

#US East (N. Virginia)
- hosts: localhost
  gather_facts: false
  connection: local
  vars:
    region_services:
      - "us-east-1"
  tasks:
    - name: 3 run - should loop and print dynamic var
      include_role: name=nginx
    - name: 4 run - should loop and print dynamic var
      include_role: name=nginx
      when: aws_region_name == "us-east-1"
      with_items:
        - "{{ region_services }}"

我得到这样的错误

'item' 未定义\n\n错误似乎出现在

4

1 回答 1

0

你也可以像这样在你的剧本中包含角色。

# US East (N. Virginia)
- hosts: localhost
  gather_facts: false
  connection: local
  vars:
    region_services:
      - "us-east-1"
  roles:  
    - {role: ../roles/nginx}
    - {role: ../roles/other}
  ...
于 2017-07-13T17:08:53.710 回答