install vm on vcenter /vsphere and convert into template livekde use the same template livekde to create vm jump

used this iso  CentOS-7-x86_64-DVD-1804 to create vm


https://docs.google.com/document/d/e/2PACX-1vRuipYIMvRT6JVRxaQwdBs_PbIbrK9zYVcTnfrQrpPPMdQrlNfdzmfysKcWrdR1oFK_q8XIkFAwem4V/pub


[root@localhost ~]# cat vmfromtemplate.yml
---
- name: Create a VM

  hosts: localhost

  connection: local

  gather_facts: no

  tasks:
  - name: Create a VM  jump from template livekde
    vmware_guest:
      hostname: 192.168.0.103
      username: root
      password: vmware
      validate_certs: no
      datacenter: dc
      folder: /dc/vm/
      name: jump
      template: livekde
      state: present
    # This is hostname of particular ESXi server on which user wants VM to be deployed
      esxi_hostname: 192.168.0.108
      disk:
       - size_gb: 10
         type: thin
         datastore: datastore1
      hardware:
       memory_mb: 1024
       num_cpus: 1
       scsi: paravirtual
      networks:
       - name: VM Network
         device_type: vmxnet3
      wait_for_ip_address: yes
    delegate_to: localhost
    register: jump

[root@localhost ~]# vi CreateVMfromTemplate.yml
[root@localhost ~]# ansible-playbook CreateVMfromTemplate.yml

PLAY [Create a VM] ********************************************************************

TASK [Create a VM  jump from template livekde] ****************************************
changed: [localhost -> localhost]

PLAY RECAP ****************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0 

[root@localhost ~]#

https://docs.google.com/document/d/e/2PACX-1vRIaVz7Wa8pudGNdb8DzesR5obpBlR-GzsOj9cSQAT0GqKS3OJqYnTkF5SAQhSUSSHRBAJ4cu_StZqA/pub

https://docs.google.com/document/d/e/2PACX-1vSbHXGWevjJZjFF4C9V8HWT5dwEu6jGmTjxhgLZnaGR5-vczxNMpILD6hylVNmBOTAGko_ZLxX4XaD6/pub

[root@localhost ~]# cat poweroffjump.yml
---
- name: Create a VM

  hosts: localhost

  connection: local

  gather_facts: no

  tasks:
  - name: poweroff  virtual machine jump
    vmware_guest:
      hostname: 192.168.0.103
      username: root
      password: vmware
      validate_certs: no
      datacenter: dc
      folder: /dc/vm/
      name: jump
      template: livekde
      state: poweredoff
    # This is hostname of particular ESXi server on which user wants VM to be deployed
      esxi_hostname: 192.168.0.108
      disk:
       - size_gb: 10
         type: thin
         datastore: datastore1
      hardware:
       memory_mb: 1024
       num_cpus: 1
       scsi: paravirtual
      networks:
       - name: VM Network
         device_type: vmxnet3
      wait_for_ip_address: yes
    delegate_to: localhost
    register: jump


[root@localhost ~]# ansible-playbook poweroffjump.yml

PLAY [Create a VM] ********************************************************************

TASK [poweroff  virtual machine jump] *************************************************
changed: [localhost -> localhost]

PLAY RECAP ****************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0 

[root@localhost ~]#

https://docs.google.com/document/d/e/2PACX-1vSNS_Wa8acCrsiPEBqc1u4LMr6HWgar6e2yOwlUWgWQc9UJsSDs09ISuTkhjs9cmW3W1ytX53_6xHM9/pub
[root@localhost ~]# cat removejump.yml
---
- name: Create a VM

  hosts: localhost

  connection: local

  gather_facts: no

  tasks:
  - name: remove  virtual machine jump
    vmware_guest:
      hostname: 192.168.0.103
      username: root
      password: vmware
      validate_certs: no
      datacenter: dc
      folder: /dc/vm/
      name: jump
      template: livekde
      state: absent
    # This is hostname of particular ESXi server on which user wants VM to be deployed
      esxi_hostname: 192.168.0.108
      disk:
       - size_gb: 10
         type: thin
         datastore: datastore1
      hardware:
       memory_mb: 1024
       num_cpus: 1
       scsi: paravirtual
      networks:
       - name: VM Network
         device_type: vmxnet3
      wait_for_ip_address: yes
    delegate_to: localhost
    register: jump

[root@localhost ~]# ansible-playbook removejump.yml

PLAY [Create a VM] ********************************************************************

TASK [remove  virtual machine jump] ***************************************************
changed: [localhost -> localhost]

PLAY RECAP ****************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0 

[root@localhost ~]#

Comments

Popular posts from this blog

ansible redhat cluster qorum qdevice

PE 3.9.0 on centos 6

gfs2 cluster