Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ansible: No inventory was passed, only implicit localhost is available

I have the following ansible playbook:

$ 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'

and a hosts file at `/etc/ansible/hosts.yml’ with:

central.local

All I get is this error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

$ 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):

Same thing when running the playbook.

>Solution :

The default path to the ansible inventory is /etc/ansible/hosts, not /etc/ansible/hosts.yml. You need to remove the file extension.

You can also set a different path to the inventory file with the -i flag when running ansible.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading