0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ansibleのvmware_guestモジュール

Posted at

memo

  • hostsにIPを書いた分だけ、仮想マシンを作る
  • パラメータは全部conf.yamlに書く
  • templateの場所はある程度適当でも、都合良く解釈してくれそう

playbook

main.yaml
---
- hosts: localhost
  vars_files: 
  - conf.yaml
  sudo: yes
  tasks:
    - include: createvm.yaml
createvm.yaml
---
- name: Create VirtualMachines from template
  with_inventory_hostnames: 
    - target

  vmware_guest:
    # vCenter情報
    hostname: "{{ vcenter_ip }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"

    # データセンター情報
    datacentername: "{{ datacenter_name }}"

    # esxiホスト情報
    esxi_hostname_ip: "{{ esxi_host_ip }}"

    # 仮想マシン設定
    name: "vm-{{ item }}"
    template: "{{ mytemplate }}"
    state: poweredon
    folder: "{{ datacenter_name }}/"
    wait_for_ip_address: yes
    validate_certs: no

    # 仮想マシンのディスク設定
    disk:
    - size_gb: "{{ disk_size }}"
      datastore: "{{ datastore_name }}"

    # 仮想マシンのネットワーク設定
    networks:
    - name: "{{ nw_name }}"
      type: static
      ip: "{{ item }}"
      netmask: "{{ nw_subnet }}"
      gateway: "{{ nw_gateway }}" 
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?