【发布时间】:2020-08-27 12:03:09
【问题描述】:
库存文件 - /home/Alan/hosts
[routers]
rter1 ansible_network_os=ios ansible_connection=network_cli
rter2 ansible_network_os=ios ansible_connection=network_cli
Ansible.cfg 文件 /home/Alan/ansible.cfg
[defaults]
# Use local hosts file in folder
inventory = /home/Alan/hosts
#library = /usr/share/my_modules/
#module_utils = /usr/share/my_module_utils
host_key_checking = False
retry_files_enabled = False
gathering = explicit
#interpreter_python = /usr/bin/python3
Ansible 剧本:/home/Alan/getver1.yml
---
-
name: "show version and other user level commands"
gather_facts: false
hosts: routers
tasks:
-
ios_command:
commands:
- "show version"
- "show ip int brief"
name: "run multiple commands on remote nodes"
register: print_output
-
debug: var=print_output.stdout_lines
Ansible --version 输出:
ansible 2.9.11
config file = /home/Alan/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Sep 26 2019, 11:57:09) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
运行剧本的命令:
ansible-playbook getver1.yml -u alan -k
运行命令导致此错误..我可以做些什么来修复?
"Unable to find location of 'ansible-connection'. Please set or check the value of ANSIBLE_CONNECTION_PATH"
【问题讨论】:
-
运行 ansible-inventory -i hosts --list 时 ANSIBLE_CONNECTION 有什么价值?