Automation Assembler에서 vSphere에 배포하는 경우 정적 IP 주소를 할당할 수 있지만 cloudConfig 초기화 명령과 사용자 지정 규격 간에 충돌이 발생하지 않도록 주의해야 합니다.

샘플 설계

다음 설계는 클라우드 템플릿 초기화 명령과 사용자 지정 규격 간의 충돌 없이 정적 IP 주소를 안전하게 적용합니다. 모두 assignment: static 네트워크 설정을 포함합니다.

설계 샘플 클라우드 템플릿 코드

cloud-init 코드가 없는 Linux 시스템에 정적 IP 주소 할당

resources:
  wpnet:
    type: Cloud.Network
    properties:
      name: wpnet
      networkType: public
      constraints:
        - tag: sqa
  DBTier:
    type: Cloud.vSphere.Machine
    properties:
      flavor: small
      image: linux-template
      networks:
        - name: '${wpnet.name}'
          assignment: static
          network: '${resource.wpnet.id}'

네트워크 할당 명령이 포함되지 않은 cloud-init 코드를 사용하여 Linux 시스템에 정적 IP 주소를 할당합니다.

참고: vSphere 사용자 지정 규격은 customizeGuestOs 속성을 true로 설정하거나 customizeGuestOs 속성을 생략해도 적용됩니다.

Ubuntu 샘플

resources:
  wpnet:
    type: Cloud.Network
    properties:
      name: wpnet
      networkType: public
      constraints:
        - tag: sqa
  DBTier:
    type: Cloud.vSphere.Machine
    properties:
      flavor: small
      image: ubuntu-template
      customizeGuestOs: true
      cloudConfig: |
        #cloud-config
        ssh_pwauth: yes
        chpasswd:
          list: |
            root:Pa$$w0rd
          expire: false
        write_files:
          - path: /tmpFile.txt
            content: |
              ${resource.wpnet.dns}
        runcmd:
          - hostnamectl set-hostname --pretty ${self.resourceName}
          - touch /etc/cloud/cloud-init.disabled
      networks:
        - name: '${wpnet.name}'
          assignment: static
          network: '${resource.wpnet.id}'

CentOS 샘플

resources:
  wpnet:
    type: Cloud.Network
    properties:
      name: wpnet
      networkType: public
      constraints:
        - tag: sqa
  DBTier:
    type: Cloud.vSphere.Machine
    properties:
      flavor: small
      image: centos-template
      customizeGuestOs: true
      cloudConfig: |
        #cloud-config
        write_files:
          - path: /test.txt
            content: |
              deploying in power off.
              then rebooting.
      networks:
        - name: '${wpnet.name}'
          assignment: static
          network: '${resource.wpnet.id}'

네트워크 할당 명령이 포함된 cloud-init 코드를 사용하여 Linux 시스템에 정적 IP 주소를 할당합니다.

customizeGuestOs 속성은 false입니다.

Ubuntu 샘플

resources:
  wpnet:
    type: Cloud.Network
    properties:
      name: wpnet
      networkType: public
      constraints:
        - tag: sqa
  DBTier:
    type: Cloud.vSphere.Machine
    properties:
      flavor: small
      image: ubuntu-template
      customizeGuestOs: false
      cloudConfig: |
        #cloud-config
        write_files:
          - path: /etc/netplan/99-installer-config.yaml
            content: |
              network:
                version: 2
                renderer: networkd
                ethernets:
                  ens160:
                    addresses:
                      - ${resource.DBTier.networks[0].address}/${resource.wpnet.prefixLength}
                    gateway4: ${resource.wpnet.gateway}
                    nameservers:
                      search: ${resource.wpnet.dnsSearchDomains}
                      addresses: ${resource.wpnet.dns}
        runcmd:
          - netplan apply
          - hostnamectl set-hostname --pretty ${self.resourceName}
          - touch /etc/cloud/cloud-init.disabled
      networks:
        - name: '${wpnet.name}'
          assignment: static
          network: '${resource.wpnet.id}'

CentOS 샘플

resources:
  wpnet:
    type: Cloud.Network
    properties:
      name: wpnet
      networkType: public
      constraints:
        - tag: sqa
  DBTier:
    type: Cloud.vSphere.Machine
    properties:
      flavor: small
      image: centos-template
      customizeGuestOs: false
      cloudConfig: |
        #cloud-config
        ssh_pwauth: yes
        chpasswd:
          list: |
            root:VMware1!
          expire: false
        runcmd:
          - nmcli con add type ethernet con-name 'custom ens192' ifname ens192 ip4 ${self.networks[0].address}/${resource.wpnet.prefixLength} gw4 ${resource.wpnet.gateway}
          - nmcli con mod 'custom ens192' ipv4.dns "${join(resource.wpnet.dns,' ')}"
          - nmcli con mod 'custom ens192' ipv4.dns-search "${join(resource.wpnet.dnsSearchDomains,',')}"
          - nmcli con down 'System ens192' ; nmcli con up 'custom ens192'
          - nmcli con del 'System ens192'
          - hostnamectl set-hostname --static `dig -x ${self.networks[0].address} +short | cut -d "." -f 1`
          - hostnamectl set-hostname --pretty ${self.resourceName}
          - touch /etc/cloud/cloud-init.disabled
      networks:
        - name: '${wpnet.name}'
          assignment: static
          network: '${resource.wpnet.id}'

배포가 참조된 이미지에 기반하는 경우 네트워크 할당 명령이 포함된 cloud-init 코드를 사용하여 Linux 시스템에 정적 IP 주소를 할당합니다.

customizeGuestOs 속성은 false입니다.

또한 클라우드 템플릿에 사용자 지정을 차단하는 ovfProperties 속성을 포함해서는 안 됩니다.

resources:
  wpnet:
    type: Cloud.Network
    properties:
      name: wpnet
      networkType: public
      constraints:
        - tag: sqa
  DBTier:
    type: Cloud.vSphere.Machine
    properties:
      flavor: small
      imageRef: 'https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.ova'
      customizeGuestOs: false
      cloudConfig: |
        #cloud-config
        ssh_pwauth: yes
        chpasswd:
          list: |
            root:Pa$$w0rd
            ubuntu:Pa$$w0rd
          expire: false
        write_files:
          - path: /etc/netplan/99-netcfg-vrac.yaml
            content: |
              network:
                version: 2
                renderer: networkd
                ethernets:
                  ens192:
                    dhcp4: no
                    dhcp6: no
                    addresses:
                      - ${resource.DBTier.networks[0].address}/${resource.wpnet.prefixLength}
                    gateway4: ${resource.wpnet.gateway}
                    nameservers:
                      search: ${resource.wpnet.dnsSearchDomains}
                      addresses: ${resource.wpnet.dns}
        runcmd:
          - netplan apply
          - hostnamectl set-hostname --pretty ${self.resourceName}
          - touch /etc/cloud/cloud-init.disabled
      networks:
        - name: '${wpnet.name}'
          assignment: static
          network: '${resource.wpnet.id}'

2일차 사용자 지정

초기 배포와 마찬가지로 2일차 작업에도 네트워크 구성이 포함될 수 있습니다. 2일차 작업 중에 사용자 지정을 건너뛰려면 다음 속성을 추가합니다.

customizeGuestOsDay2: false

작동하지 않거나 원치 않는 결과를 생성할 수 있는 설계

  • cloud-init 코드에 네트워크 할당 명령이 포함되어 있지 않고 customizeGuestOs 속성은 false입니다.

    네트워크 설정을 구성하는 초기화 명령과 사용자 지정 규격이 둘 다 없습니다.

  • cloud-init 코드에 네트워크 할당 명령이 포함되어 있지 않고 ovfProperties 속성이 설정되어 있습니다.

    초기화 명령이 없지만 ovfProperties가 사용자 지정 규격을 차단했습니다.

  • cloud-init 코드에는 네트워크 할당 명령이 포함되어 있고 customizeGuestOs 속성이 누락되었거나 true로 설정되어 있습니다.

    사용자 지정 규격을 적용하면 초기화 명령과 충돌합니다.

cloud-init 및 사용자 지정 규격에 대한 기타 해결 방법

vSphere에 배포하는 경우 cloud-init 및 사용자 지정 규격 충돌을 해결하도록 이미지를 사용자 지정할 수도 있습니다. 자세한 내용은 다음 외부 저장소를 참조하십시오.

스페이서