Ansible 失败的未定义变量
Ansible failed undefined variable
我尝试使用简单的 ansible 并收到以下错误消息
fatal: [localhost]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: 'entregas' is undefined\n\nThe error appears to be in
'/home/gustavo/Documents/ansible/roles/build/tasks/main.yml': line 2,
column 3, but may\nbe elsewhere in the file depending on the exact
syntax problem.\n\nThe offending line appears to be:\n\n---\n- name :
Clone and pull\n ^ here\n" }
我的目录
.
├── build.yml
├── roles
├── build
├── defaults
├── main.yml
├── tasks
├── main.yml
还有我的文件
build.yml
---
- name: Pull Git
hosts: localhost
connection: local
roles:
- build
默认 -> main.yml
---
dest_path : /tmp/ansible/test
sh_key_path : /root/.ssh/id_rsa
entregas-web : **bit bucket ssh**
任务 -> main.yml
---
- name : Clone and pull
become : true
ansible.builtin.git :
repo : "{{ entregas-web }}"
key_file : "{{ ssh_key_path }}"
dest : "{{ dest_path }}"
refspec : '+refs/pull/* :refs/heads/*'
force : yes
version : master
当我发出这个命令时会发生这种情况
ansible-playbook build.yml -u root -vvvvv
或
ansible-playbook build.yml -vvvv
变量名无效。有效的变量名称不包含 -
(破折号)。
这就是为什么您的错误消息提到缺少变量 entregas
。
请参阅 variable names 上的文档。
我尝试使用简单的 ansible 并收到以下错误消息
fatal: [localhost]: FAILED! => { "msg": "The task includes an option with an undefined variable. The error was: 'entregas' is undefined\n\nThe error appears to be in '/home/gustavo/Documents/ansible/roles/build/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name : Clone and pull\n ^ here\n" }
我的目录
.
├── build.yml
├── roles
├── build
├── defaults
├── main.yml
├── tasks
├── main.yml
还有我的文件
build.yml
---
- name: Pull Git
hosts: localhost
connection: local
roles:
- build
默认 -> main.yml
---
dest_path : /tmp/ansible/test
sh_key_path : /root/.ssh/id_rsa
entregas-web : **bit bucket ssh**
任务 -> main.yml
---
- name : Clone and pull
become : true
ansible.builtin.git :
repo : "{{ entregas-web }}"
key_file : "{{ ssh_key_path }}"
dest : "{{ dest_path }}"
refspec : '+refs/pull/* :refs/heads/*'
force : yes
version : master
当我发出这个命令时会发生这种情况
ansible-playbook build.yml -u root -vvvvv
或
ansible-playbook build.yml -vvvv
变量名无效。有效的变量名称不包含 -
(破折号)。
这就是为什么您的错误消息提到缺少变量 entregas
。
请参阅 variable names 上的文档。