简体   繁体   中英

Ansible playbook doesn't start?

Here is my Ansible playbook to create a new vm.

---
- name: Create a VM in OA resource pool
  hosts: local
  connection: local
  gather_facts: False
  tasks:
  - name: create VM
    vsphere_guest:
        vcenter_hostname: https:\\virtualcenter
        username: '{{ user }}'
        password: '{{ password }}'
        guest: '{{ guest }}'
        state: powered_off
        vm_extra_config:
            vcpu.hotadd: yes
            mem.hotadd: yes
            notes: This is a test VM
        vm_disk:
            disk1:
                size_gb: 10
                type: thick
                datastore: storage
        vm_nic:
            type: vmxnet3
            network: network1
        vm_hardware:
            memory_mb: 1024
            num_cpus: 1
            osid: centos64Guest
            scsi: paravirtual
        resource_pool: "RP1"

Variables are passed from a command line. However, when I try to run the task I get this:

No config file found; using defaults
 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available


PLAYBOOK: createvm.yml *********************************************************
1 plays in playbooks/vmware/createvm.yml

PLAY [Create a VM in OA resource pool] *****************************************
skipping: no hosts matched

PLAY RECAP *********************************************************************

What can be reason of that? A typo? Syntax check with list tasks also doesn't show anything.

What can be reason of that?

As you did not specify an inventory file, Ansible looks for the host/group named local in the default /etc/ansible/hosts which does not exist.

As the inventory file does not exist, Ansible does not know what target to run the playbook on.

Note: local is not the same as localhost . Ansible expects local to be a regular host or group name defined in the inventory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM