我正在使用vagrant和chef来构建VM。
主机:OSX 10.9.5
奥黛丽:Ubuntu2 JLUC$ 厨师 -V
厨师开发工具包版本:0.10.0
厨师客户端版本:12.5.1
伯克斯版本:4.0.1
厨房版本:1.4.2
奥黛丽:Ubuntu2 jluc$ 流浪汉 -v
流浪 1.8.1
奥黛丽:Ubuntu2 jluc$ 流浪插件列表
流浪汉-伯克谢尔 (4.1.0)
流浪者综合 (1.4.1)
流浪者共享(1.1.5,系统)
Virtualbox:5,但之前的4相同。
嘉宾: 乌班图 14.04
背景:我正在使用外星人来安装Oracle rpm。 但是,您不能只将客户端指向某处的 url 或包,您需要从 Oracle 下载 rpm,接受条件,然后将文件提供给客户端安装。 有 2 rpm,一个 30MB,一个 640KB。
我通过在主机上的端口 9003 上启动 http 服务器来执行此操作。
问题:
在厨师运行中,下载/remote_file时间在 5-20 分钟内不等,而我可以在 5-15 秒内从客人体内获取/卷曲它们。
详:
以下 chef 代码处理这些文件:
ip = node[:network][:default_gateway]
simplehttp_port=node[:basedjango][:port_host_fileserver]
fn_basic = "oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm"
execute 'download_basic' do
cwd "/tmp"
command "wget http://#{ip}:#{simplehttp_port}/#{fn_basic} "
not_if do ::File.exists?(fnp_basic) end
end
#I have also used this instead, just as slow...
remote_file fnp_basic do
uri = "http://#{ip}:#{simplehttp_port}/#{fn_basic}"
not_if do ::File.exists?(fnp_basic) end
mode '0755'
action :create
end
我的问题是我可以在 5 到 15 秒内将 ssh 流浪到来宾中并获取或卷曲文件。 从厨师食谱中,我每次查看 5-20 分钟(如果存在,有一个条件保护以避免下载它)。
==> default: [2016-01-18T11:13:58-08:00] INFO: file[/etc/profile.d/ORACLE_HOME.sh] mode changed to 755
==> default:
==> default: - change mode from '' to '0755'
==> default:
==> default: - change owner from '' to 'root'
==> default:
==> default: - change group from '' to 'root'
==> default:
==> default: (up to date)
==> default: Recipe: basedjango::oracle
==> default:
==> default: * execute[download_basic] action run
!! 11:13 到 11:28 => 15 分钟在这里。
==> default: [2016-01-18T11:28:04-08:00] INFO:
execute[download_basic] ran successfully
==> default:
==> default: - execute wget http://10.0.2.2:9003/oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm
==> default: * execute[install_basic] action run
这是相同的命令,通过流浪 ssh 手动执行。 在这种情况下大约 2 秒。
vagrant@vagrant:/tmp$ wget http://10.0.2.2:9003/oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm
--2016-01-18 11:50:40-- http://10.0.2.2:9003/oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm
Connecting to 10.0.2.2:9003... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30940809 (30M) [text/html]
Saving to: ‘oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm’
100%[====================================================================================================================================================================================>] 30,940,809 17.8MB/s in 1.7s
2016-01-18 11:50:41 (17.8 MB/s) - ‘oracle-instantclient12.1-basiclite-12.1.0.2.0-1.x86_64.rpm’ saved [30940809/30940809]
remote_file资源的行为方式相同,所以起初我认为它或我使用它的方式有问题。 顺便说一句,rpm 不是从 Vagrant 共享目录提供的。
有什么想法吗?
您是否还没有找到解决方案,但是当我遇到该问题(甚至从另一台服务器下载)时,我可以通过启用厨师的调试输出来"修复"它。这神奇地提高了下载速度。
简单地说
config.vm.provion :chef_solo |chef|
chef.log_level = 'debug'
[...]
end