Estou tentando escrever um Vagrantfile para instalar o nginx nas imagens do CentOS 6.4.
No meu Vagrantfile eu tenho (ip's redigidos):
config.vm.provision :shell,
:inline => "echo \"export http_proxy=http://10.0.0.1:3128\; export https_proxy=https://10.0.0.1:3128\" >> /etc/profile"
config.vm.provision :shell,
:inline => "echo \"export HTTP_PROXY=http://10.0.0.1:3128\; export HTTPS_PROXY=https://10.0.0.1:3128\" >> /etc/profile"
config.vm.provision :shell,
:inline => "echo \"proxy=http://10.0.0.1:3128\" >> /etc/yum.conf"
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "nginx"
chef.json = {
"http_proxy" => "http://10.0.0.1:3128",
"https_proxy" => "https://10.0.0.1:3128",
"nginx" => {
"install_method" => "package"
}
}
end
Quando eu executo, tudo fica feliz até que ele tenta rodar o yum e tenta instalar o arquivo GPG, quando eu recebo o erro:
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'Base-CentOS-6.4'...
Progress: 10%
Progress: 20%
Progress: 40%
Progress: 60%
Progress: 80%
Progress: 90%
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] Running provisioner: shell...
[default] Running: inline script
[default] Running provisioner: shell...
[default] Running: inline script
[default] Running provisioner: shell...
[default] Running: inline script
[default] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
[2013-08-22T01:24:00+00:00] INFO: Forking chef instance to converge...
[2013-08-22T01:24:00+00:00] INFO: *** Chef 11.6.0 ***
[2013-08-22T01:24:00+00:00] INFO: Setting the run_list to ["recipe[nginx]"] from JSON
[2013-08-22T01:24:00+00:00] INFO: Run List is [recipe[nginx]]
[2013-08-22T01:24:00+00:00] INFO: Run List expands to [nginx]
[2013-08-22T01:24:00+00:00] INFO: Starting Chef Run for localhost
[2013-08-22T01:24:00+00:00] INFO: Running start handlers
[2013-08-22T01:24:00+00:00] INFO: Start handlers complete.
[2013-08-22T01:24:01+00:00] INFO: ohai plugins will be at: /etc/chef/ohai_plugins
[2013-08-22T01:24:01+00:00] INFO: remote_directory[/etc/chef/ohai_plugins] created directory /etc/chef/ohai_plugins
[2013-08-22T01:24:01+00:00] INFO: remote_directory[/etc/chef/ohai_plugins] mode changed to 755
[2013-08-22T01:24:01+00:00] INFO: cookbook_file[/etc/chef/ohai_plugins/README] created file /etc/chef/ohai_plugins/README
[2013-08-22T01:24:01+00:00] INFO: cookbook_file[/etc/chef/ohai_plugins/README] updated file contents /etc/chef/ohai_plugins/README
[2013-08-22T01:24:01+00:00] INFO: cookbook_file[/etc/chef/ohai_plugins/README] mode changed to 644
[2013-08-22T01:24:01+00:00] INFO: ohai[custom_plugins] reloaded
[2013-08-22T01:24:01+00:00] WARN: Cloning resource attributes for service[nginx] from prior resource (CHEF-3694)
[2013-08-22T01:24:01+00:00] WARN: Previous service[nginx]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/default.rb:44:in 'from_file'
[2013-08-22T01:24:01+00:00] WARN: Current service[nginx]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/default.rb:51:in 'from_file'
[2013-08-22T01:24:01+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] created file /etc/chef/ohai_plugins/nginx.rb
[2013-08-22T01:24:01+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] updated file contents /etc/chef/ohai_plugins/nginx.rb
[2013-08-22T01:24:01+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] owner changed to 0
[2013-08-22T01:24:01+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] group changed to 0
[2013-08-22T01:24:01+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] mode changed to 755
[2013-08-22T01:24:01+00:00] INFO: template[/etc/chef/ohai_plugins/nginx.rb] sending reload action to ohai[reload_nginx] (immediate)
[2013-08-22T01:24:01+00:00] INFO: ohai[reload_nginx] reloaded
[2013-08-22T01:24:01+00:00] INFO: Adding RPM-GPG-KEY-EPEL-6 GPG key to /etc/pki/rpm-gpg/
[2013-08-22T01:24:12+00:00] INFO: remote_file[/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6] created file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
================================================================================
Error executing action 'create' on resource 'remote_file[/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6]'
================================================================================
Errno::ENETUNREACH
------------------
Network is unreachable - connect(2)
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/yum/providers/key.rb
61: remote_file "/etc/pki/rpm-gpg/#{new_resource.key}" do
62: source new_resource.url
63: mode "0644"
64: notifies :run, "execute[import-rpm-gpg-key-#{new_resource.key}]", :immediately
65: end
66: end
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/yum/providers/key.rb:61:in 'block in class_from_file'
remote_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6") do
provider Chef::Provider::RemoteFile
action "create"
retries 0
retry_delay 2
path "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6"
backup 5
atomic_update true
source ["http://mirror.aarnet.edu.au/pub/epel/RPM-GPG-KEY-EPEL-6"]
use_etag true
use_last_modified true
cookbook_name :yum
mode "0644"
end
[2013-08-22T01:25:20+00:00] INFO: Running queued delayed notifications before re-raising exception
[2013-08-22T01:25:20+00:00] ERROR: Running exception handlers
[2013-08-22T01:25:20+00:00] ERROR: Exception handlers complete
[2013-08-22T01:25:20+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-08-22T01:25:20+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
[Finished in 126.4s with exit code 127]
e o stacktrace tem (mais o rastreamento de pilha):
[root@localhost ~]# cat /var/chef/cache/chef-stacktrace.out
Generated at 2013-08-22 01:25:20 +0000
Errno::ENETUNREACH: remote_file[/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6] (/tmp/vagrant-chef-1/chef-solo-1/cookbooks/yum/providers/key.rb line 61) had an error: Errno::ENETUNREACH: Network is unreachable - connect(2)
Quando eu ssh na caixa, verifique os proxies e tente enrolar a chave, não tenho problemas.
[drew@mymachine dev-environment]$ vagrant ssh
Last login: Thu Aug 22 01:25:36 2013 from 10.0.0.2
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$ echo -e "$http_proxy"" - ""$https_proxy""\n""$HTTP_PROXY"" - ""$HTTPS_PROXY"
http://10.0.0.1:3128 - https://10.0.0.1:3128
http://10.0.0.1:3128 - https://10.0.0.1:3128
[vagrant@localhost ~]$ curl "http://mirror.aarnet.edu.au/pub/epel/RPM-GPG-KEY-EPEL-6"
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.5 (GNU/Linux)
mQINBEvSKUIBEADLGnUj24ZVKW7liFN/JA5CgtzlNnKs7sBg7fVbNWryiE3URbn1
JXvrdwHtkKyY96/ifZ1Ld3lE2gOF61bGZ2CWwJNee76Sp9Z+isP8RQXbG5jwj/4B
...
XtfLk0W5Ab9pd7tKDR6QHI7rgHXfCopRnZ2VVQ==
=V/6I
-----END PGP PUBLIC KEY BLOCK-----
[vagrant@localhost ~]$
Eu também posso usar o yum dentro da caixa sem problemas.
Estou atrás de um servidor proxy em uma rede corporativa, então estou pensando que talvez o chef não esteja prestando atenção nas configurações de proxy. A minha pergunta é se alguém já experimentou isso antes, ou tem alguma ideia sobre como executar o chef por trás de um proxy onde eles estão recebendo redes inacessíveis?
Estou pensando se não posso corrigi-lo, basta baixar e instalar a chave antes de o chef funcionar, mas gostaria de saber se há algo mais acontecendo aqui.