CentOS

OpenStack, OCI, AWS 에서 VM Instance를 위한 UserData 설정 (init-cloud 스크립트)

AndrewJ 2022. 6. 21. 19:08
반응형

 

작성일: 2024년 2월 16일

 

 

Openstack에서 VM Instance를 새로 생성할 때, OS에 설정할 내용이 있다면 User Data를 입력하면 편하다.

(VM instance의 user datainit-cloud, cloud-init 스크립트라는 용어로 불리는 경우도 있다)

아래와 같이 예제를 보고, 필요한 부문만 조금씩 바꾸어 사용하는 것을 추천~

 

#cloud-config

ssh_pwauth: True

ssh_authorized_keys:
  - ssh-rsa AAA...SDvz sejong@xx.yy.com
  - ssh-rsa AAB...QTuo alphaa@aa.bb.com

chpasswd:
  list: |
     root:myxxyyzzroot
     ubuntu:myubuntuxxyyzz
     cloud-user:myxxyyzz
  expire: False
    
locale: en_US.UTF-8

# timezone: America/New_York
timezone: Asia/Seoul

bootcmd:
 - echo "My command at system booting" >> /var/my-cmd.txt

runcmd:
 - echo "My command example" >> /var/my-cmd.txt
 - apt install locales
 - locale-gen en_US.UTF-8
 - locale-gen ko_KR.UTF-8

 

위 예제는 root, ubuntu, cloud-user 등 3개 계정의 Password를 변경하고, timezone을 서울로 설정하고, Locale(언어)를 English로 설정하는 예제이다.

 

 


 

 

더 자세한 내용은 아래 Web Docs를 참고하자 !!!

 

Red Hat 문서

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_cloud-init_for_rhel_8/configuring-cloud-init_cloud-content

 

다양한 cloud-init 설정 예제 문서

https://ko.linux-console.net/?p=8814