【问题标题】:how can use vim-cmd command in esxi with ansible如何在 esxi 中使用 vim-cmd 命令和 ansible
【发布时间】:2021-04-20 05:26:13
【问题描述】:

我没有 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

【问题讨论】:

    标签: python ansible esx


    【解决方案1】:

    我犯了一个基本错误

      - block:
        - name: Get Target VMid
          command: /bin/vim-cmd vmsvc/getallvms
          #delegate_to: localhost <- delete this line
    

    现在可以工作了

    谢谢大家

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-01
      • 2022-06-15
      • 2020-09-18
      • 2011-05-14
      相关资源
      最近更新 更多