【发布时间】:2020-03-23 05:37:44
【问题描述】:
我即将制作一个用于自动更新某些库的 ansible playbook
我得到的错误信息:
"msg": "任务包含一个带有未定义变量的选项。 错误是:“lib_wheel_path”未定义\n\n错误似乎是 在“/home/user/Desktop/setup/roles/lib/tasks/main.yml”中:第 4 行, 第 3 列,但可能\n位于文件中的其他位置,具体取决于确切的 语法问题。\n\n有问题的行似乎是:\n\n\n- 名称: 在此处下载 lib\n ^\n"
我的 ansible/vars 文件包含库的路径:
local_path: "~/Some_Libraries/"
lib_wheel_path: "{{ local_path }}lib/"
ansible/role/lib/vars/main.yml 文件包含:
lib_path: "{{ lib_wheel_path }}"
lib_wheels: "'{{ lib_path }}' | regex_findall('(lib\\S*\\.whl)') | sort(reverse=True) }}"
ansible/role/lib/tasks/main.yml 文件包含:
- name: Download lib
copy:
src: "{{ lib_path }}/{{ lib_wheels[0] }}"
dest: /tmp
remote_src: true
- name: Install lib
pip:
name: file:///tmp/{{ lib_wheels[0] }}
become: yes
预计它将包含 ansible/vars,其中包含 lib_wheel_path,我认为 ansible 的工作原理没有错
【问题讨论】: