VMware PowerCLI and Chef


#1

Hello folks,

I am implementing vCloud director using PowerCLI commands. Now I wish to
execute those PowerCLI commands using Chef, it seems that the resources are
executed properly but the commands on vCloud end are not running successfully.
The PoweCLI scripts are running successfully when I execute them from
PowerShell promt. I have used “powershell” and “execute” resources, they also
run successfully, but there is no effect in the vCloud environment.
Has anyone in the list has tried so ? Any help is appreciated.

Thank you,
Ashutosh Narayan


#2

If you run those commands within a recipe, use "chef-client -l debug"
and you should see the full output of the commands as they’re run. My
hunch with shell commands is it’s usually related to the environment
the commands are running in and the commands are returning a bogus
error code, so checking them as they run should provide a little more
clarity.

Thanks,
Matt Ray
Director of Partner Integration :: Chef
512.731.2218 :: matt@getchef.com
mattray :: GitHub :: IRC :: Twitter

On Mon, Sep 15, 2014 at 11:03 PM, Ashutosh Narayan
aashutoshnarayan@gmail.com wrote:

Hello folks,

I am implementing vCloud director using PowerCLI commands. Now I wish to
execute those PowerCLI commands using Chef, it seems that the resources are
executed properly but the commands on vCloud end are not running successfully.
The PoweCLI scripts are running successfully when I execute them from
PowerShell promt. I have used “powershell” and “execute” resources, they also
run successfully, but there is no effect in the vCloud environment.
Has anyone in the list has tried so ? Any help is appreciated.

Thank you,
Ashutosh Narayan


#3

PowerCLI usually requires a special PowerCLI-enabled session. For instance,
when I run powershell, i can’t access powercli cmdlets, but must instead
startup using the powercli icon (You can examine the shortcut to see whats
being done in the background to load the powercli into the powershell
console to get the new, special console.)

Could it be that powercli cmdlets are not accessible in the “powershell
only” console that beings executed in your resource call?

On Tue, Sep 16, 2014 at 6:45 AM, Matt Ray matt@getchef.com wrote:

If you run those commands within a recipe, use "chef-client -l debug"
and you should see the full output of the commands as they’re run. My
hunch with shell commands is it’s usually related to the environment
the commands are running in and the commands are returning a bogus
error code, so checking them as they run should provide a little more
clarity.

Thanks,
Matt Ray
Director of Partner Integration :: Chef
512.731.2218 :: matt@getchef.com
mattray :: GitHub :: IRC :: Twitter

On Mon, Sep 15, 2014 at 11:03 PM, Ashutosh Narayan
aashutoshnarayan@gmail.com wrote:

Hello folks,

I am implementing vCloud director using PowerCLI commands. Now I wish to
execute those PowerCLI commands using Chef, it seems that the resources
are
executed properly but the commands on vCloud end are not running
successfully.
The PoweCLI scripts are running successfully when I execute them from
PowerShell promt. I have used “powershell” and “execute” resources, they
also
run successfully, but there is no effect in the vCloud environment.
Has anyone in the list has tried so ? Any help is appreciated.

Thank you,
Ashutosh Narayan

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com


#4

Try adding the following line to the beginning of your powershell script block:

Get-PSSnapin -Registered Vmware.* | Add-PSSnapin

It should grab all of the available VMware snap-ins at that the PowerCLI shell loads and load them in the current context of the powershell.exe that the Chef client runs.

Aaron Lindstrom
Software Build Engineer
P 312.506.1917 | M 847.274.2257
E aaron.lindstrom@savogroup.commailto:your.email@savogroup.com

From: Kenneth Barry [mailto:kbarry@tunein.com]
Sent: Tuesday, September 16, 2014 12:24 PM
To: chef@lists.opscode.com
Subject: [chef] Re: Re: VMware PowerCLI and Chef

PowerCLI usually requires a special PowerCLI-enabled session. For instance, when I run powershell, i can’t access powercli cmdlets, but must instead startup using the powercli icon (You can examine the shortcut to see whats being done in the background to load the powercli into the powershell console to get the new, special console.)

Could it be that powercli cmdlets are not accessible in the “powershell only” console that beings executed in your resource call?

On Tue, Sep 16, 2014 at 6:45 AM, Matt Ray <matt@getchef.commailto:matt@getchef.com> wrote:
If you run those commands within a recipe, use "chef-client -l debug"
and you should see the full output of the commands as they’re run. My
hunch with shell commands is it’s usually related to the environment
the commands are running in and the commands are returning a bogus
error code, so checking them as they run should provide a little more
clarity.

Thanks,
Matt Ray
Director of Partner Integration :: Chef
512.731.2218 :: matt@getchef.commailto:matt@getchef.com
mattray :: GitHub :: IRC :: Twitter

On Mon, Sep 15, 2014 at 11:03 PM, Ashutosh Narayan
<aashutoshnarayan@gmail.commailto:aashutoshnarayan@gmail.com> wrote:

Hello folks,

I am implementing vCloud director using PowerCLI commands. Now I wish to
execute those PowerCLI commands using Chef, it seems that the resources are
executed properly but the commands on vCloud end are not running successfully.
The PoweCLI scripts are running successfully when I execute them from
PowerShell promt. I have used “powershell” and “execute” resources, they also
run successfully, but there is no effect in the vCloud environment.
Has anyone in the list has tried so ? Any help is appreciated.

Thank you,
Ashutosh Narayan

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.comhttp://www.tunein.com/
[http://d11im0xz45jykv.cloudfront.net/email/logo_signature.png]


CONFIDENTIALITY NOTICE: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the named addressee, you may not disseminate, distribute , copy or otherwise use this e-mail or its contents. Please notify the sender immediately by e-mail if you have received this email by mistake and delete it from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited


#5

You’ll need to make sure yoh use add-pssnapin to load the vmware commands
into the powershell session.

Steve
On Sep 16, 2014 1:24 PM, “Kenneth Barry” kbarry@tunein.com wrote:

PowerCLI usually requires a special PowerCLI-enabled session. For
instance, when I run powershell, i can’t access powercli cmdlets, but must
instead startup using the powercli icon (You can examine the shortcut to
see whats being done in the background to load the powercli into the
powershell console to get the new, special console.)

Could it be that powercli cmdlets are not accessible in the “powershell
only” console that beings executed in your resource call?

On Tue, Sep 16, 2014 at 6:45 AM, Matt Ray matt@getchef.com wrote:

If you run those commands within a recipe, use "chef-client -l debug"
and you should see the full output of the commands as they’re run. My
hunch with shell commands is it’s usually related to the environment
the commands are running in and the commands are returning a bogus
error code, so checking them as they run should provide a little more
clarity.

Thanks,
Matt Ray
Director of Partner Integration :: Chef
512.731.2218 :: matt@getchef.com
mattray :: GitHub :: IRC :: Twitter

On Mon, Sep 15, 2014 at 11:03 PM, Ashutosh Narayan
aashutoshnarayan@gmail.com wrote:

Hello folks,

I am implementing vCloud director using PowerCLI commands. Now I wish to
execute those PowerCLI commands using Chef, it seems that the resources
are
executed properly but the commands on vCloud end are not running
successfully.
The PoweCLI scripts are running successfully when I execute them from
PowerShell promt. I have used “powershell” and “execute” resources,
they also
run successfully, but there is no effect in the vCloud environment.
Has anyone in the list has tried so ? Any help is appreciated.

Thank you,
Ashutosh Narayan

Kenneth Barry
TuneIn | Build and Release Engineer
M: 409-673-0544
www.tunein.com