【发布时间】:2019-03-29 00:09:56
【问题描述】:
我部署了一些低支持的操作系统,例如 Debian 9、Debian 8、Rehhat 6,7、Centos 7。
启动时不支持IP配置,所以我只添加了VLAN/虚拟网络接口,然后我使用vmware_vm_shell逐步配置操作系统。
我正在寻找的是等待远程 VM 上存在像 /proc/net/dev 这样的事件以继续其他步骤的技巧
到目前为止我尝试了什么:
- hosts: localhost
tasks:
- name: Create a virtual machine "{{ vm_name }}"
vmware_guest:
datacenter: '{{ datacenter }}'
hostname: '{{ vcenter }}'
username: "{{ login }}"
password: "{{ passwd }}"
folder: "{{ folder }}"
name: "{{ vm_name }}"
template: '{{ template }}'
cluster: "{{ cluster }}"
state: poweredon
disk:
- size_gb: "{{ disksizeGB }}"
datastore: '{{ datastore }}'
hardware:
memory_mb: '{{ ramsizeMB }}'
num_cpus: '{{ vcpu_num }}'
hotadd_cpu: True
hotremove_cpu: True
hotadd_memory: True
networks: '{{ vlans }}'
#wait_for_ip_address: yes # ERR there's ifaces, but not ip at this time
register: deploy
- name: Wait for server to start
local_action:
module: wait_for
timeout=15
when: deploy.changed
最后一个等待代码块很糟糕(等待 N 秒),我想要更聪明的东西。
有什么想法吗?
如果我不等待,我有时会收到错误:fatal: [localhost]: FAILED! => {"changed": false, "msg": "VMWareTools is not installed or is not running in the guest. VMware Tools are necessary to run this module."}
,因为 VM 未启动。模板有 vmware-tools。
https://docs.ansible.com/ansible/2.6/modules/vmware_guest_module.html#vmware-guest-module https://docs.ansible.com/ansible/latest/modules/vmware_vm_shell_module.html
【问题讨论】:
标签: ansible vmware vsphere pyvmomi