尝试在Ansible中创建新VM时出错 [英] Error trying to create a new vm in ansible

查看:280
本文介绍了尝试在Ansible中创建新VM时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习Ansible.到目前为止,这一直很痛苦.我有这段代码来创建一个新的虚拟机.我遵循了教程.

I just started learning Ansible. It has been a pain so far. I have this code to create a new vm. I followed this tutorial.

 ---
- hosts: localhost
  connection: local
  tasks:
    - vsphere_guest:
            vcenter_hostname:1.1.1.12
            username: root
            password: pasword
            guest: newvm001
            state: powered_on
            validate_certs: no
            vm_extra_config:
                vcpu.hotadd: yes
                mem.hotadd:  yes
                notes: This is a test VM
                folder: MyFolder
            vm_disk:
                disk1:
                        size_gb: 10
                        type: thin
                        datastore: storage001
            vm_nic:
                nic1:
                    type: vmxnet3
                    network: VM Network
                    network_type: standard
            vm_hardware:
                memory_mb: 256
                num_cpus: 1
                osid: ubuntu64Guest
                scsi: paravirtual
            esxi:
                datacenter: 1.1.1.12
                hostname: 1.1.1.12

但是我一直收到此错误.

I however keep getting this error.

[警告]:找不到主机文件:/etc/ansible/hosts

[WARNING]: Host file not found: /etc/ansible/hosts

[警告]:提供的主机列表为空,只有本地主机可用

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

播放[localhost]

PLAY [localhost]

任务[设置] ****************************************************** *****************好的:[本地主机]

TASK [setup] ******************************************************************* ok: [localhost]

任务[vsphere_guest] ****************************************************** *********致命:[本地主机]:失败! => {已更改":false,失败":true,"msg": 无法找到名为9.1.142.86的数据中心"}

TASK [vsphere_guest] *********************************************************** fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Cannot find datacenter named: 9.1.142.86"}

没有其他的主机了 ****************************************************** *********** [警告]:无法创建重试文件"testing.retry". [Errno 2]没有这样的文件或目录:

NO MORE HOSTS LEFT ************************************************************* [WARNING]: Could not create retry file 'testing.retry'. [Errno 2] No such file or directory: ''

PLAY RECAP ****************************************************** *******************本地主机:ok = 1更改= 0 =无法访问= 0 =
失败= 1

PLAY RECAP ********************************************************************* localhost : ok=1 changed=0 unreachable=0
failed=1

为什么会这样?主机文件和清单文件有什么区别?

Why is that so? And what is the difference between a host file and an inventory file?

推荐答案

主机文件和清单文件有什么区别?

what is the difference between a host file and an inventory file?

它们是相同的.但是,由于您要在本地计算机上进行所有操作,所以只有本地主机可用就可以了.

They are the same. However, since you're doing everything on your local machine, it's fine that you only have localhost available.

这是您的错误:

任务[vsphere_guest] *********************************************** ****************致命:[本地主机]:失败! => {已更改":false,失败":true,"msg":找不到名为9.1.142.86"的数据中心

TASK [vsphere_guest] *********************************************************** fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Cannot find datacenter named: 9.1.142.86"}

我不清楚您为什么会从提供的剧本中收到此消息,因为它根本没有提到IP,而我怀疑是造成此问题的线路是

It's not clear to me why you're receiving this with the playbook you've provided, as it doesn't mention that IP at all and the line I suspect is causing the problem is

datacenter: 1.1.1.12

您确定这是您正在运行的文件,并且已保存对它所做的任何更改吗?

Are you sure this is the file you're running, and that you've saved any changes you've made to it?

这篇关于尝试在Ansible中创建新VM时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆