VMware vSphere

vSphere : IaC์—์„œ ์Šค์œ„์น˜ ๋ฐ ๋ผ์šฐํ„ฐ ์„ค์น˜

NENGIN 2024. 5. 31. 15:48

yaml ํŒŒ์ผ ํด๋” ๊ฒฝ๋กœ

 

yaml ํŒŒ์ผ ์‹คํ–‰ ํ”„๋กœ๊ทธ๋žจ

 

 

 

1. ์Šค์œ„์น˜ ์ƒ์„ฑ : 01.Create_Lab_Swtich.yaml

 

## https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_vswitch_module.html#ansible-collections-community-vmware-vmware-vswitch-module 
## https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_portgroup_module.html 

---
- hosts: localhost
  vars_files: ./vars.yaml

  tasks: 
    - name: Create Lab Standard Switch
      community.vmware.vmware_vswitch:
        hostname: '{{ esxi_hostname }}'
        username: '{{ esxi_username }}'
        password: '{{ esxi_password }}'
        validate_certs: no
        switch: '{{ student_ID }}'
        security:
          promiscuous_mode: true
          mac_changes: True
          forged_transmits: True          
      delegate_to: localhost

    - name: Waiting 10 seconds for completing switch
      wait_for:
        timeout: 10
      delegate_to: localhost

    - name: Adding Trunk Portgroup
      community.vmware.vmware_portgroup:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        esxi_hostname: "{{ esxi_hostname }}"
        validate_certs: no
        switch: "{{ student_ID }}"
        portgroup: "{{ student_ID + '-Trunk' }}"
        vlan_id: 4095
      delegate_to: localhost

    - name: Adding Site A Management Portgroup
      community.vmware.vmware_portgroup:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        esxi_hostname: "{{ esxi_hostname }}"
        validate_certs: no
        switch: "{{ student_ID }}"
        portgroup: "{{ student_ID + '-SA-Mgmt' }}"
        vlan_id: 10
      delegate_to: localhost

    - name: Adding Site A Storage Portgroup
      community.vmware.vmware_portgroup:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        esxi_hostname: "{{ esxi_hostname }}"
        validate_certs: no
        switch: "{{ student_ID }}"
        portgroup: "{{ student_ID + '-SA-Storage' }}"
        vlan_id: 11
      delegate_to: localhost

    - name: Adding Site A vMotion Portgroup
      community.vmware.vmware_portgroup:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        esxi_hostname: "{{ esxi_hostname }}"
        validate_certs: no
        switch: "{{ student_ID }}"
        portgroup: "{{ student_ID + '-SA-vMotion' }}"
        vlan_id: 12
      delegate_to: localhost

    - name: Adding Site A Production Portgroup
      community.vmware.vmware_portgroup:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        esxi_hostname: "{{ esxi_hostname }}"
        validate_certs: no
        switch: "{{ student_ID }}"
        portgroup: "{{ student_ID + '-SA-Prod' }}"
        vlan_id: 13
      delegate_to: localhost

 

vars.yaml

ansible_python_interpreter: /bin/python3

student_ID: "KMJ"

vcenter_hostname: "200.200.200.130"   // AD ip add
vcenter_username: "KMJ@jc.lover"      // ๋กœ๊ทธ์ธ id
vcenter_password: "VMware1!"	      // pw

datacenter_name: "JC"

folder_prefix: "JC/vm/3. Teammates/"

# S01, S06, S11, S16, S21 --> esxi_host : 200.200.200.246, kh-esxi-01
# S02, S07, S12, S17, S22 --> esxi_host : 200.200.200.247, kh-esxi-02
# S03, S08, S13, S18, S23 --> esxi_host : 200.200.200.248, kh-esxi-03
# S04, S09, S14, S19, S24 --> esxi_host : 200.200.200.249, kh-esxi-04
# S05, S10, S15, S20, S25 --> esxi_host : 200.200.200.250, kh-esxi-05

esxi_hostname: "200.200.200.248"  // Host name
esxi_password: "VMware1!"		  
esxi_username: "root"

public_net: "VM-200.200.200.x"
private_net: "{{ student_ID + '-Trunk' }}"

datastore_name: "Local-khesxi03"

 

์‹คํ–‰

ansible@IaC:~$ ansible-playbook 01.create.lab.switch -vvv

 

์ƒ์„ฑ๋œ ์Šค์œ„์น˜ ํ™•์ธ

 

2. ๋ผ์šฐํ„ฐ ์ƒ์„ฑ :02.Create_Router_VM.yaml

 

์‹คํ–‰

ansible@IaC:~$ ansible-playbook 02.install.Router.yaml -vvv

 

 

์ƒ์„ฑ๋œ ๋ผ์šฐํ„ฐ ํ™•์ธ

 

'VMware vSphere' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

vSphere : ๋ผ์šฐํ„ฐ ์„ค์ •  (0) 2024.05.31