zoukankan      html  css  js  c++  java
  • Ansible VMware模块使用示例

    vmware_vm_facts模块使用示例

    执行条件:

      安装Pyvmimo:  pip install pyvmomi

    方法一,直接编写单个yaml文件:

    - hosts: localhost   # 注意这里使用的是 localhost
      gather_facts: True  # 是否开启或关闭收集远程主机信息
      connection: local  
    
      tasks:
      - name: Gather Facts of all vms in vCenter Server
        local_action:
          module: vmware_vm_facts
          hostname: '10.110.164.133'
          username: 'administrator@vsphere.local'
          password: 'VMware1!'
          validate_certs: no
        register: vmfacts
    
      - name: Verbose virtual machine
        debug:
          msg: "{{ vmfacts.virtual_machines }}"

    方法二,编写playbook

    1.目录结构

    ├── get_vms.yaml

    └── roles

        └── vc01

            └── tasks

                └── main.yaml

     

    2. main.yaml内容

    - name: vm
      vmware_vm_facts:
        hostname: '10.110.164.133'
        username: 'administrator@vsphere.local'
        password: 'VMware1!'
        validate_certs: no
      delegate_to: localhost  
      register: instance_vm_facts
    
    - debug:
        var: instance_vm_facts.virtual_machines

    3. get_vms.yaml

    - hosts: localhost # 注意这里使用的是localhost 
      gather_facts: True
      roles:
      - vc01
  • 相关阅读:
    POJ 3292 Semi-prime H-numbers (素数筛法变形)
    POJ 1845 Sumdiv (整数拆分+等比快速求和)
    POJ 2635 The Embarrassed Cryptographer(大数求余)
    POJ 2115 C Looooops (扩展欧几里德 + 线性同余方程)
    poj3071
    poj2486
    poj1947
    POJ 1159
    POJ 1845
    poj3282
  • 原文地址:https://www.cnblogs.com/vincenshen/p/10592509.html
Copyright © 2011-2022 走看看