gassanpavel

ADD VM

Oct 29th, 2020
590
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---
  2. - name: Prepare | Ensure deb packages are installed
  3.   apt:
  4.     name:
  5.      - python3-apt
  6.       - python3-setuptools
  7.       - python3-pip
  8.       - python3-dbus
  9.       - python3-pyvmomi
  10.       - python3-jmespath
  11.       - python3-requests
  12.     state: present
  13.     update_cache: yes
  14.  
  15. - name: Ensure that {{ vmware_guest_vm_count }} virtual machine(s) present on "{{ vmware_guest_cluster }}"
  16.   vmware_guest:
  17.     hostname: "{{ vmware_guest_hostname }}"
  18.     username: "{{ vmware_guest_username }}"
  19.     password: "{{ vmware_guest_password }}"
  20.     validate_certs: no
  21.     datacenter: "{{ vmware_guest_datacenter }}"
  22.     cluster: "{{ vmware_guest_cluster }}"
  23.     resource_pool: "{{ vmware_guest_resource_pool }}"
  24.     folder: "{{ vmware_guest_folder }}"
  25.     name: "{{ vmware_guest_vm_name }}"
  26.     template: "{{ vmware_guest_template }}"
  27.     state: poweredon
  28.     disk:
  29.     - size_gb: 10
  30.       type: thin
  31.       datastore: "{{ vmware_guest_datastore }}"
  32.     hardware:
  33.       memory_mb: 8192
  34.       num_cpus: 4
  35.       scsi: paravirtual
  36.     wait_for_ip_address: yes
  37.   with_sequence: count={{ vmware_guest_vm_count }}
  38.   register: deploy
  39.  
  40. - name: Add a host
  41.   add_host:
  42.     name: "{{ vmware_guest_vm_name }}"
  43.     groups: some_group
  44.     ansible_ssh_host: '{{ item.instance.ipv4 }}'
  45.     host_number: "{{ item.item }}"
  46.   loop: "{{ deploy | json_query('results[*]') }}"
  47.   loop_control:
  48.     label: "{{ item.instance.ipv4 }}"
RAW Paste Data