vmware-archive / vmware-vcenter

VMware vCenter Module
Other
87 stars 101 forks source link

esx_service fails with "Could not evaluate: host option required" #83

Closed athak closed 9 years ago

athak commented 11 years ago

Hi, I'm using the vcenter::host provided class. Manifest is almost identical to the host.pp test.

The agent errors 4 times, one per each service: ntpd, DCUI, TSM, TSM-SSH:

Esx_service[esx-01.athak.local:TSM-SSH]: Could not evaluate: host option required

Puppet master and agent are 3.1.0, Ubuntu 12.04.2.

Best, Atha

rbbrown commented 11 years ago

Atha: These modules are meant to run on the master using 'puppet apply.' No agent is used. If that doesn't clear it up, please show your manifest (equivalent of host.pp) and your data.pp if you used one. ... rb

athak commented 11 years ago

Hi Randy, I don't understand why it would make a difference if run through puppet apply on the master or puppet agent. I want to use puppet agent so I can use a series of proxies in each Datacenter.

In any case, running through puppet apply gives the same error. I was bringing data through hiera in the original manifest so I tried hardcoding it and now it fails earlier (both agent and apply):

Debug: PuppetX::Puppetlabs::Transport::Vsphere initializing connection to: vcenter.athak.local Error: /Stage[main]/Vurbia::Infrastructure::Compute::Vcenter/Vurbia::Infrastructure::Base::Vmware::Vcenter[athak]/Vcenter::Host[esx-01.athak.local]/Vc_host[esx-01.athak.local]: Could not evaluate: undefined method to_hash' for nil:NilClass /var/lib/puppet/lib/puppet_x/puppetlabs/transport.rb:26:inretrieve' /var/lib/puppet/lib/puppet/provider/vcenter.rb:33:in vim' /var/lib/puppet/lib/puppet/provider/vc_host/default.rb:67:infind_host' /var/lib/puppet/lib/puppet/provider/vc_host/default.rb:55:in exists?' /usr/lib/ruby/vendor_ruby/puppet/property/ensure.rb:81:inretrieve' /usr/lib/ruby/vendor_ruby/puppet/type.rb:1017:in retrieve' /usr/lib/ruby/vendor_ruby/puppet/type.rb:1041:inretrieve_resource' /usr/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:32:in perform_changes' /usr/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:133:inevaluate' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:48:in apply' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:83:ineval_resource' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:103:in evaluate_original' /usr/lib/ruby/vendor_ruby/puppet/util.rb:351:inthinmark' /usr/lib/ruby/1.8/benchmark.rb:308:in realtime' /usr/lib/ruby/vendor_ruby/puppet/util.rb:350:inthinmark' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:103:in evaluate_original' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:382:intraverse' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:98:in evaluate_original' /var/lib/puppet/lib/puppet_x/puppetlabs/transport.rb:9:inevaluate' /usr/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:144:in apply' /usr/lib/ruby/vendor_ruby/puppet/configurer.rb:122:inapply_catalog' /usr/lib/ruby/vendor_ruby/puppet/util.rb:179:in benchmark' /usr/lib/ruby/1.8/benchmark.rb:308:inrealtime' /usr/lib/ruby/vendor_ruby/puppet/util.rb:178:in benchmark' /usr/lib/ruby/vendor_ruby/puppet/configurer.rb:121:inapply_catalog' /usr/lib/ruby/vendor_ruby/puppet/configurer.rb:179:in run' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:45:inrun' /usr/lib/ruby/vendor_ruby/puppet/agent/locker.rb:20:in lock' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:45:inrun' /usr/lib/ruby/1.8/sync.rb:230:in synchronize' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:45:inrun' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:119:in with_client' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:42:inrun' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:84:in run_in_fork' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:41:inrun' /usr/lib/ruby/vendor_ruby/puppet/application.rb:179:in call' /usr/lib/ruby/vendor_ruby/puppet/application.rb:179:incontrolled_run' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:39:in run' /usr/lib/ruby/vendor_ruby/puppet/application/agent.rb:338:inonetime' /usr/lib/ruby/vendor_ruby/puppet/application/agent.rb:312:in run_command' /usr/lib/ruby/vendor_ruby/puppet/application.rb:364:inrun' /usr/lib/ruby/vendor_ruby/puppet/application.rb:456:in plugin_hook' /usr/lib/ruby/vendor_ruby/puppet/application.rb:364:inrun' /usr/lib/ruby/vendor_ruby/puppet/util.rb:504:in exit_on_fail' /usr/lib/ruby/vendor_ruby/puppet/application.rb:364:inrun' /usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:132:in run' /usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:86:inexecute' /usr/bin/puppet:4

The relevant section of the manifest is:

vcenter::host { 'esx-01.athak.local': path => '/DEV/MGMT', username => 'root', password => 'vmware1234', dateTimeConfig => { 'ntpConfig' => { 'server' => 'pool.ntp.org', }, 'timeZone' => { 'key' => 'US/Eastern', }, }, transport => Transport['vcenter.athak.local-vsphere'], }

The transport is used successfully for defining the DC and cluster.

The original manifest (which brings data from hiera) only fails with esx_service:

.... $esxi_host_defaults = { 'path' => "/${vc_datacenter}/${vc_cluster}", 'dateTimeConfig' => { 'timeZone' => { 'key' => 'US/Eastern', }, }, 'transport' => Transport["${name}-vsphere"], }

create_resources('vcenter::host', $esxi_hosts, $esxi_host_defaults)

In hiera: esxi_hosts: esx-01.athak.local: username: root password: vmware1234

Full stack trace: Debug: PuppetX::Puppetlabs::Transport::Vsphere initializing connection to: vcenter.athak.local Debug: PuppetX::Puppetlabs::Transport::Vsphere initializing connection to: Error: /Stage[main]/Vurbia::Infrastructure::Compute::Vcenter/Vurbia::Infrastructure::Base::Vmware::Vcenter[athak]/Vurbia::Infrastructure::Base::Vmware::Host[esx-01.athak.local]/Esx_service[esx-01.athak.local:TSM-SSH]: Could not evaluate: host option required /var/lib/gems/1.8/gems/rbvmomi-1.6.0.z1/lib/rbvmomi/vim.rb:22:in connect' /var/lib/puppet/lib/puppet_x/puppetlabs/transport/vsphere.rb:20:inconnect' /var/lib/puppet/lib/puppet_x/puppetlabs/transport.rb:33:in retrieve' /var/lib/puppet/lib/puppet/provider/vcenter.rb:33:invim' /var/lib/puppet/lib/puppet/provider/esx_service/default.rb:54:in host' /var/lib/puppet/lib/puppet/provider/esx_service/default.rb:49:insvc' /var/lib/puppet/lib/puppet/provider/esx_service/default.rb:17:in running' /usr/lib/ruby/vendor_ruby/puppet/property.rb:462:insend' /usr/lib/ruby/vendor_ruby/puppet/property.rb:462:in retrieve' /usr/lib/ruby/vendor_ruby/puppet/type.rb:1027:inretrieve' /usr/lib/ruby/vendor_ruby/puppet/type.rb:1022:in each' /usr/lib/ruby/vendor_ruby/puppet/type.rb:1022:inretrieve' /usr/lib/ruby/vendor_ruby/puppet/type.rb:1041:in retrieve_resource' /usr/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:32:inperform_changes' /usr/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:133:in evaluate' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:48:inapply' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:83:in eval_resource' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:103:inevaluate_original' /usr/lib/ruby/vendor_ruby/puppet/util.rb:351:in thinmark' /usr/lib/ruby/1.8/benchmark.rb:308:inrealtime' /usr/lib/ruby/vendor_ruby/puppet/util.rb:350:in thinmark' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:103:inevaluate_original' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:382:in traverse' /usr/lib/ruby/vendor_ruby/puppet/transaction.rb:98:inevaluate_original' /var/lib/puppet/lib/puppet_x/puppetlabs/transport.rb:9:in evaluate' /usr/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:144:inapply' /usr/lib/ruby/vendor_ruby/puppet/configurer.rb:122:in apply_catalog' /usr/lib/ruby/vendor_ruby/puppet/util.rb:179:inbenchmark' /usr/lib/ruby/1.8/benchmark.rb:308:in realtime' /usr/lib/ruby/vendor_ruby/puppet/util.rb:178:inbenchmark' /usr/lib/ruby/vendor_ruby/puppet/configurer.rb:121:in apply_catalog' /usr/lib/ruby/vendor_ruby/puppet/configurer.rb:179:inrun' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:45:in run' /usr/lib/ruby/vendor_ruby/puppet/agent/locker.rb:20:inlock' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:45:in run' /usr/lib/ruby/1.8/sync.rb:230:insynchronize' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:45:in run' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:119:inwith_client' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:42:in run' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:84:inrun_in_fork' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:41:in run' /usr/lib/ruby/vendor_ruby/puppet/application.rb:179:incall' /usr/lib/ruby/vendor_ruby/puppet/application.rb:179:in controlled_run' /usr/lib/ruby/vendor_ruby/puppet/agent.rb:39:inrun' /usr/lib/ruby/vendor_ruby/puppet/application/agent.rb:338:in onetime' /usr/lib/ruby/vendor_ruby/puppet/application/agent.rb:312:inrun_command' /usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in run' /usr/lib/ruby/vendor_ruby/puppet/application.rb:456:inplugin_hook' /usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in run' /usr/lib/ruby/vendor_ruby/puppet/util.rb:504:inexit_on_fail' /usr/lib/ruby/vendor_ruby/puppet/application.rb:364:in run' /usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:132:inrun' /usr/lib/ruby/vendor_ruby/puppet/util/command_line.rb:86:in `execute' /usr/bin/puppet:4

Otherwise, if I comment out the esx_service call in vcenter::host, everything works fine.

Best, Atha

nanliu commented 11 years ago

I think this might be an issue related to Puppet 3.1 scoping. Transport is a metaparameter so it should get passed to the vc_* resources in vcenter::host. However scoping changes in Puppet 3.1 may result in $transport = nil, and the error you see. I'm wondering if transport should not be set for the resources in the define type.

athak commented 11 years ago

Hi Nan, I got the same results testing with 2.7.21 and 3.0.2. Is there something I could be doing wrong?

Best, Atha

gungazoo commented 11 years ago

I'm having the same issue. I can create a datacenter and add a host but NTP is giving an error as is DCUI saying "host option required." I can see that the host name has been passed to the command (pasted below). It is also giving an error about esxi_shell_insteracitve_time_out but that is a different error I haven't looked into yet.

err: /Stage[main]/Internal/Vcenter::Host[mymachine.mydomain]/Esx_service[mymachine.mydomain:ntpd]: Could not evaluate: host option required

Oh -- running puppetd version 2.7.21 and have run against ESXi 5.0 and 5.1.

nanliu commented 11 years ago

Not reproducing this issue in the lab. Would it be possible to get the smallest manifests with vcenter::host and transport resource (minus username/password) to reproduce this problem? Also besides Puppet version, Ruby version and OS version?

gungazoo commented 11 years ago

This is running RHEL 6.3 64-bit with Ruby version 1.8.7. Here is the config:

class internal {
    # VMware module tests
    include vcenter::package
    transport { 'devvcenter':
        username => 'myvcuser',
        password => 'mypassword',
        server   => 'devvcenter.usg.edu',
        options  => { 'insecure' => true },
    }
    vcenter::host { 'esx.usg.edu':
        path      => '/jojo',
        username  => 'myesxuser',
        password  => 'mypassword',
        dateTimeConfig => {
            'ntpConfig' => {
                'server' => 'ntp.usg.edu',
                'running' => true,
                'policy' => 'automatic',
            },
            'timeZone' => {
                'key' => 'UTC',
            },
        },
        transport => Transport['devvcenter'],
    }
}

This will attach the host to vCenter in the correct path. It will also set the time server to be ntp.usg.edu. But, when the esx_service runs is when it fails. We've also tried putting the host in maintenance mode and that works fine. By default I think there are 4 esx_service stanzas in hosts.pp. All 4 fail with "host option required" message.

We have a stanza that creates a datacenter which works fine also.

Thanks so much for looking.

gungazoo commented 11 years ago

More information...

If we change the esx_service stanze in host.pp to be this:

  esx_service { "${name}:ntpd":
    policy    => $config_dt['ntpConfig']['policy'],
    running   => $config_dt['ntpConfig']['running'],
    subscribe => Esx_ntpconfig[$name],
    transport => Transport['mytransport'],
  }

which adds the transport line everything works. The transport line has to be added to each esx_service stanza.

nanliu commented 11 years ago

A bit odd this wasn't cropping up in the lab, anyhow we can simplify the define resource with:

Esx_server { transport => $transport }