Ansible:没有传递清单,只有隐式本地主机可用
Ansible: No inventory was passed, only implicit localhost is available
我有以下 ansible 剧本:
$ cat vm_template.yml
- name: Create new LXC container in Proxmox
hosts: 'central.local'
tasks:
- name: 'Create container'
proxmox:
vmid: '810' # specifying container ID
api_user: 'root@pam' # Proxmox user
api_password: '' # password in plaintext
api_host: '' # proxmox hostname
password: 'password' # container password in plaintext
hostname: 'CT-Prometheus-ArchLinux' # container hostname
node: 'central' # proxmox hostname
cores: '1'
cpus: '2'
cpuunits: '1000'
ostemplate: 'archlinux-base_20210421-1_amd.tar.gz'
storage: 'VMs'
disk: '16'
memory: '512'
nameserver: '8.8.8.8'
netif: '{"net0":"name=eth0,ip=static,bridge=vmbr10"}'
state: 'present'
和位于“/etc/ansible/hosts.yml”的主机文件:
central.local
我得到的只是这个错误:
$ ansible all --list-hosts
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not
match 'all'
hosts (0):
运行剧本时也是如此。
ansible 清单的默认路径是 /etc/ansible/hosts
,而不是 /etc/ansible/hosts.yml
。您需要删除文件扩展名。
当 运行 ansible 时,您还可以使用 -i
标志设置清单文件的不同路径。
我有以下 ansible 剧本:
$ cat vm_template.yml
- name: Create new LXC container in Proxmox
hosts: 'central.local'
tasks:
- name: 'Create container'
proxmox:
vmid: '810' # specifying container ID
api_user: 'root@pam' # Proxmox user
api_password: '' # password in plaintext
api_host: '' # proxmox hostname
password: 'password' # container password in plaintext
hostname: 'CT-Prometheus-ArchLinux' # container hostname
node: 'central' # proxmox hostname
cores: '1'
cpus: '2'
cpuunits: '1000'
ostemplate: 'archlinux-base_20210421-1_amd.tar.gz'
storage: 'VMs'
disk: '16'
memory: '512'
nameserver: '8.8.8.8'
netif: '{"net0":"name=eth0,ip=static,bridge=vmbr10"}'
state: 'present'
和位于“/etc/ansible/hosts.yml”的主机文件:
central.local
我得到的只是这个错误:
$ ansible all --list-hosts
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not
match 'all'
hosts (0):
运行剧本时也是如此。
ansible 清单的默认路径是 /etc/ansible/hosts
,而不是 /etc/ansible/hosts.yml
。您需要删除文件扩展名。
当 运行 ansible 时,您还可以使用 -i
标志设置清单文件的不同路径。