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
## https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_guest_module.html
---
- hosts: localhost
vars_files: ./vars.yaml
tasks:
- name: Create Router VM
community.vmware.vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: 'false'
datacenter: '{{datacenter_name}}'
folder: '{{ folder_prefix + student_ID }}'
name: '{{ item.vmname }}'
state: poweredon
guest_id: '{{ item.guest_id }}'
esxi_hostname: "{{ esxi_hostname }}"
hardware:
num_cpus: '{{ item.cpus }}'
memory_mb: '{{ item.memory }}'
scsi: paravirtual
disk:
- size_gb: '{{ item.disk_gb }}'
type: thin
datastore: '{{ datastore_name }}'
networks:
- name: '{{ public_net }}'
device_type: vmxnet3
- name: '{{ private_net }}'
device_type: vmxnet3
cdrom:
- controller_number: 0
unit_number: 0
state: present
type: iso
iso_path: '{{ "[" + datastore_name + "]\ISO\vyos-1.5-rolling-202405070019-amd64.iso" }}'
loop:
- { vmname: "{{ student_ID + '-Router'}}", guest_id: debian10_64Guest, cpus: 1, memory: 1024, disk_gb: 10 }
delegate_to: localhost
register: deploy_vm
์คํ
ansible@IaC:~$ ansible-playbook 02.install.Router.yaml -vvv
์์ฑ๋ ๋ผ์ฐํฐ ํ์ธ
'VMware vSphere' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
vSphere : ๋ผ์ฐํฐ ์ค์ (0) | 2024.05.31 |
---|