我部署了一些受支持程度较低的操作系统,例如Debian 9,Debian 8,Rehhat 6,7,Centos 7。
在启动时不支持IP配置,因此我仅添加VLAN /虚拟网络接口,然后使用var iResponse = this.Activity.responsebody;
System.IO.File.WriteLines(@"directorypath&FileName);
逐步配置操作系统。
我正在寻找一种技巧,以等待远程VM上存在vmware_vm_shell
之类的事件,以继续其他步骤
到目前为止我尝试过的事情:
/proc/net/dev
最后一个等待代码块很烂(等待N秒),我想要更智能的东西。
有什么想法吗?
如果我不等,有时会出现错误:- 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
,因为虚拟机未启动。模板具有 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
答案 0 :(得分:0)
好,发现自己:)
- name: wait for server to boot
vmware_vm_shell:
datacenter: '{{ datacenter }}'
hostname: 'vcenter{{ vcenter }}'
username: "{{ login }}"
password: "{{ passwd }}"
validate_certs: False
folder: "{{ folder }}"
vm_id: "{{ vm_name }}"
cluster: "{{ cluster }}"
vm_password: '{{ passwd }}'
vm_username: root
vm_shell: '/bin/sleep'
vm_shell_args: 0
when: deploy.changed and 'debian' in distro
register: has_reboot
until: has_reboot.failed != 'true'
delay: 2
retries: 150