简体   繁体   English

ansible include_vars 使用循环时未定义问题

[英]ansible include_vars undefind issue while using loop

I have playbook, where i'm trying to loop through the include_vars but somehow loop is not working我有剧本,我试图循环通过include_vars但不知何故loop不起作用

Below is my playbook and Error.以下是我的剧本和错误。

Any hint or help with be much appreciated.非常感谢任何提示或帮助。

Playbook:剧本:

---
- name: Running AWS EC2 Play ...
  hosts: localhost
  connection: local
  gather_facts: yes

  tasks:
    - include_vars: "{{ item }}"
      loop:
        - "{{ secret_aws.yml }}"
        - "{{ aws_vars.yml }}"
      no_log: true

Error错误

TASK [include_vars] ********************************************************************************************************************************************************************
task path: /home/aws/aws_work/new_create_awsVM.yml:8
fatal: [localhost]: FAILED! => {
    "msg": "'secret_aws' is undefined"
}

Note笔记

It works while assigning include_vars separately.它在单独分配include_vars时起作用。

- include_vars: aws_vars.yml
- include_vars: aws_secerets.yml

you use interpollation like varts but your file names are not a vars.您使用 varts 之类的 interpollation,但您的文件名不是 vars。 juste remove interpolation: juste 删除插值:

---
- name: Running AWS EC2 Play ...
  hosts: localhost
  connection: local
  gather_facts: yes

  tasks:
    - include_vars: "{{ item }}"
      loop:
        - secret_aws.yml
        - aws_vars.yml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM