IaC/Vagrant
[Vagrant] Provisioning
신샤인
2022. 1. 16. 08:36
반응형
Provisioning
VagrantFile
해당 VM에서 실행하는 명령어를 VagrantFile에 정의할 수 있다.
#Vagrantfile 내 provisioning 설정
Vagrant.configure("2") do |config|
...
#프로비저닝 설정 부분 해당 명령어를 순차적으로 실행함
config.vm.provision "shell", inline: <<-SHELL
yum -y update
yum -y install httpd
mkdir /opt/devopsdir
free -m
uptime
SHELL
...
end
VagrantFile 정의하고 VM 시작
#vagrant up
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'geerlingguy/centos7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'geerlingguy/centos7' version '1.2.25' is up to date...
==> default: Setting the name of the VM: centos7_default_1642236765478_89033
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
default: Adapter 3: bridged
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection aborted. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => D:/vagrant/centos7
default: /opt/scripts => D:/mydata
==> default: Running provisioner: shell...
...
반응형