2023-11-21 12:45:38
728x90
728x90

Rocky Linux9을 vCenter가 존재하는 host에 설치후 진행

시작 전 vCenter에 접속 후 DataCenter에 템플릿 폴더 생성

 

1. 패키지 설치

# dnf install -y tar wget epel-release python-pip

2. pyvmomi 패키지 다운로드 및 Archive 해제

# wget https://files.pythonhosted.org/packages/ae/a4/70716f2fb132b105bc6cb4d4399491364582ab5690c87f19d6a9e4096037/pyvmomi-8.0.2.0.1.tar.gz

# tar xvfz pyvmomi-8.0.2.0.1.tar.gz

3. pyvmomi 설치

# cd pyvmomi-8.0.2.0.1
# python setup.py install

4. Ansible 설치

# dnf install -y ansible-core

5. community.vmware Collection 설치

 

# ansible-galaxy collection install community.vmware

6.주어진 vSphere 환경에서 실습을 위한 VM Folder 생성하기

# vi folder.yml

---
- hosts: localhost
  vars:
    ansible_python_interpreter: /bin/python3
    gather_facts: no
    vcenter_hostname: "172.16.10.104"
    vcenter_username: "administrator@team4.local"
    vcenter_password: "VMware1!"
    datacenter_name: "Datacenter"
    project_id: "khb-00"
    parent_folder: "1.Projects"

  tasks: 
    - name: 01. Create a Project folder
      community.vmware.vcenter_folder:
        hostname: '{{ vcenter_hostname }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        validate_certs: false
        datacenter_name: '{{ datacenter_name }}'
        folder_name: '{{ project_id }}'
#        parent_folder: "4.Projects"
        parent_folder: '{{ parent_folder }}'
        state: present
      register: sub_folder_creation_result
      delegate_to: localhost

7. playbook 실행 후 오류 확인

# ansible-playbook folder.yml -vvv

8. pip을 이용하여 requests 모듈 설치

# pip install requests

9. playbook 재실행

# ansible-playbook folder.yml -vvv

10. 폴더 생성 확인

728x90