Vagrantfile에서 Expect 스크립트를 사용하여 구성할 수 있나요?
installOracle.exp 스크립트의 파일이 적절한 시간에 존재하지 않는 것 같습니다(오류 로그 참조).
spawn "/var/wminst/vm_provision/oracle_installer/installOracleDatabase.sh"
파일이 있어요! :)
[vagrant@wemdbc01 ~]$ ls -la /var/wminst/vm_provision/oracle_installer/installOracleDatabase.sh
-rwxrwxrwx. 1 vagrant vagrant 541 May 25 08:43 /var/wminst/vm_provision/oracle_installer/installOracleDatabase.sh
내 Vagrantfile의 관련 부분:
[...]
db.vm.synced_folder ".", "/vagrant", disabled: true
db.vm.synced_folder "C:/Installers", "/var/wminst"
db.vm.provision :shell, :inline => "yum -y install expect"
db.vm.provision :shell, :inline => "expect /var/wminst/vm_provision/oracle_installer/installOracle.exp"
end
Oracle.exp를 설치합니다.
#!/usr/bin/env expect
set timeout 20
spawn "/var/wminst/vm_provision/oracle_installer/installOracleDatabase.sh"
expect "replace Disk1/upgrade/gen_inst.sql?" { send "N\r" }
expect "Specify the HTTP port that will be used for Oracle Application Express" { send "\r" }
expect "Specify a port that will be used for the database listener" { send "\r" }
expect "initial configuration:" { send "root\r" }
expect "Confirm the password:" { send "root\r" }
expect "Do you want Oracle Database 11g Express Edition to be started on boot" { send "y\r" }
expect eof
expect eof
expect "Installation completed successfully." { send "\r" }
expect eof
실수:
==> wemdbc01: Running provisioner: shell...
wemdbc01: Running: inline script
==> wemdbc01: spawn /var/wminst/vm_provision/oracle_installer/installOracleDatabase.sh
==> wemdbc01: couldn't execute "/var/wminst/vm_provision/oracle_installer/installOracleDatabase.sh": no such file or directory
==> wemdbc01: while executing
==> wemdbc01: "spawn "/var/wminst/vm_provision/oracle_installer/installOracleDatabase.sh""
==> wemdbc01: (file "/var/wminst/vm_provision/oracle_installer/installOracle.exp" line 5)
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
편집 1: 변경 사항:
#!/bin/bash
도착하다
#!/usr/bin/env bash
이제 오류 로그는 다음과 같습니다.
==> wemdbc01: Running provisioner: shell...
wemdbc01: Running: inline script
==> wemdbc01: spawn /var/wminst/vm_provision/oracle_installer/installOracleDatabase.sh
: No such file or directory bash
==> wemdbc01: expect: spawn id exp5 not open
==> wemdbc01: while executing
==> wemdbc01: "expect "Specify the HTTP port that will be used for Oracle Application Express" { send "\r" }"
==> wemdbc01: (file "/var/wminst/vm_provision/oracle_installer/installOracle.exp" line 8)
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
답변1
문제의 스크립트는 Windows에서 생성되었습니다. 이는 DOS 개행 문자가 있음을 의미합니다. 이로 인해 Unix VM에서 스크립트가 실행되지 않습니다.
그러나 가상 머신이 Windows에서 실행되고 있다는 사실은 문제가 되지 않습니다.