ansible - Ansible 看不到主机列表或角色
问题描述
当我运行 ansible-playbook -k configure-clish.yml 时,出现以下错误:
我认为这不是语法问题,因为 Visual Studio Code 中没有显示语法问题。
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
ERROR! the role 'ashwin_sid.gaia_fw1' was not found in /app/sandbox/playbooks/roles:/home/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/app/sandbox/playbooks
The error appears to be in '/app/sandbox/playbooks/configure-clish.yml': line 25, column 16, but may
be elsewhere in the file depending on the exact syntax problem.
违规行似乎是:
'import_role:
name: ashwin_sid.gaia_fw1
^ here'
这是剧本:
- hosts: localhost
tasks:
- command: /bin/echo "{{ lookup('pipe','date +%Y-%m-%d_%H-%M') }}"
register: foo
- file:
path: ../SHOW
state: directory
- hosts: ckp
serial: 1
gather_facts: no
tasks:
- name: SHOW COMMAND
import_role:
name: ashwin_sid.gaia_fw1
tasks_from: setclish
vars:
cmdfile: configure-clish.cmd
logdir: ../SHOW
这是主机文件:
[ckp]
lab ansible_host=192.168.2.1
这是 ansible.cfg 文件:
[defaults]
roles_path = /app/sandbox/roles/ashwin_sid.gaia_fw1
inventory = /app/sandbox/hosts
host_key_checking = False
retry_files_enabled = False
解决方案
正如错误所说,您没有名为ashwin_sid.gaia_fw1
. 确保该角色位于 /app/sandbox/playbooks/roles、/home/.ansible/roles、/usr/share/ansible/roles、/etc/ansible/roles 或 /app/sandbox/playbooks 中的某个位置以及您的问题应该修复。
推荐阅读
- javascript - 点击未定义(页面加载时取消静音流)
- firebase - Flutter - 无法在初始化程序中访问实例成员“remoteConfig”
- sql-server - 根据输入对象列表过滤 DACPAC 文件
- bash - 使用生成的字符串作为命令的 sed
- javascript - 电子远程(关闭、最小化等)不起作用(无法读取未定义的属性“getCurrentWindow”)
- python - 使用 python 从 google play store 评论中获取信息
- python - 重复列表的第一个和最后一个元素的pythonic方法是什么?
- c++ - 为什么我在使用重载赋值运算符时会出错,但我没有使用编译器提供的运算符?
- react-native - 在 react-navigation 5.x 选项卡中预加载嵌套堆栈
- laravel - 错误:找不到类“App\Providers\View”