正确的路径是ansible控制器中的vars_files是什么?

huangapple go评论80阅读模式
英文:

What is the correct path for vars_files in ansible controller?

问题

在命令行运行我的Playbook时,没有任何问题。但在Ansible控制器中,我遇到了以下错误:

[WARNING]: Found variable using reserved name: vars_files

ERROR! vars file /var/lib/awx/projects/Windows/roles/create/vars/appendvars.yml was not found
Could not find file on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option

这是我的Playbook路径:

/var/lib/awx/projects/Windows/playbook.yml

我的Playbook如下:

- name: Create from data
  hosts: localhost
  roles:
    - role: Create
  vars_files:
    - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml

- name: Delete from data
  hosts: localhost
  roles:
    - role: Delete
  vars_files:
    - /var/lib/awx/projects/Windows/roles/Delete/vars/appendvars.yml

这些vars_files包含变量及其相应的值,供我在Playbook任务中引用变量名称。

我已经看过这个问题:https://stackoverflow.com/questions/56571594/error-vars-file-vars-not-found-on-the-ansible-controller ,但我仍然无法解决我的问题。

在Ansible控制器的“variables”部分,我已经尝试了以下内容:

vars_files:
  - /roles/Create/vars/appendvars.yml
  - /roles/Delete/vars/appendvars.yml
vars_files:
  - appendvars.yml
  - appendvars.yml
vars_files:
  - /roles/Create/vars/appendvars.yml
  - /roles/Delete/vars/appendvars.yml
vars_files:
  - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml
  - /var/lib/awx/projects/Windows/roles/Delete/vars/appendvars.yml

但我仍然收到完全相同的错误消息。我需要在哪里进行更改以解决此错误?

英文:

My playbook has no issues when running it on the command line. But in ansible controller, I am encountering this error:

[WARNING]: Found variable using reserved name: vars_files

ERROR! vars file /var/lib/awx/projects/Windows/roles/create/vars/appendvars.yml was not found
Could not find file on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option

This is my playbook path:

/var/lib/awx/projects/Windows/playbook.yml

My playbook:

- name: Create from data
  hosts: localhost
  roles:
    - role: Create
  vars_files:
    - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml

- name: Delete from data
  hosts: localhost
  roles:
    - role: Delete
  vars_files:
    - /var/lib/awx/projects/Windows/roles/Delete/vars/appendvars.yml

Each of these vars_files contain the variables and their corresponding values, for me to reference the variable name in my playbook tasks.

I have already seen this question, https://stackoverflow.com/questions/56571594/error-vars-file-vars-not-found-on-the-ansible-controller , but I am still unable to resolve my issue.

In the 'variables' section of Ansible Controller, I have already tried these:

vars_files:
  - /roles/Create/vars/appendvars.yml
  - /roles/Delete/vars/appendvars.yml
vars_files:
  - appendvars.yml
  - appendvars.yml
vars_files:
  - /roles/Create/vars/appendvars.yml
  - /roles/Delete/vars/appendvars.yml
vars_files:
  - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml
  - /var/lib/awx/projects/Windows/roles/Delete/vars/appendvars.yml

But I still get the exact same error message. What and where do I need to change to fix this error?

答案1

得分: 0

根据 @β.εηοιτ.βε 的建议,

在 /roles/Create/vars/main.yml 中,我移除了:

vars_files:
  - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml

这导致了警告:"[WARNING]: Found variable using reserved name: vars_files",并用来自 /roles/Create/vars/appendvars.yml 的所有变量替代了它。

对于 'Delete' 角色也采取了同样的措施。

正确的剧本:

- name: Create from data
  hosts: localhost
  roles:
    - role: Create

- name: Delete from data
  hosts: localhost
  roles:
    - role: Delete
英文:

Based on @β.εηοιτ.βε 's suggestions,

In /roles/Create/vars/main.yml, I removed:

vars_files:
  - /var/lib/awx/projects/Windows/roles/Create/vars/appendvars.yml

which was causing the warning: "[WARNING]: Found variable using reserved name: vars_files", and replaced it with all the variables from /roles/Create/vars/appendvars.yml

Did the same for the 'Delete' role too.

Correct playbook:

- name: Create from data
  hosts: localhost
  roles:
    - role: Create

- name: Delete from data
  hosts: localhost
  roles:
    - role: Delete

huangapple
  • 本文由 发表于 2023年6月26日 21:46:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76557287.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定