我没有 vCenter,只有 esxi 主机
而且我不使用任何 ansible 库存,我更喜欢 add_host 样式,如下所示
- name: Set inventory from parameter
gather_facts: no
hosts: localhost
tasks:
- name: Set with add_host
add_host:
hostname: "{{ item.dest_name }}"
ansible_host: "{{ item.dest_addr }}"
ansible_user: "{{ item.dest_conn_user }}"
ansible_password: "{{ item.dest_conn_pwd }}"
ansible_dest_protocol: "{{ item.dest_protocol| default('') }}"
ansible_port: "{{ item.dest_port | default('22') }}"
ansible_host_key_checking: no
custom_dest_name: "{{ item.dest_name }}"
group: remote_org
with_items: "{{ dests }}"
- name: Module test with set parameter
gather_facts: no
hosts: remote_org
become: yes
remote_user: root
roles:
- ../roles/4.get_vm_mac
下面是我的任务/主文件
---
- block:
- name: Get Target VMid
command: /bin/vim-cmd vmsvc/getallvms
delegate_to: localhost
rescue:
- name: 'When failure'
debug:
msg: "Try again"
和结果
[Errno 2] No such file or directory
你能帮助我吗 ??:d