Hi Folks,
I am trying to run "**sudo chef-client**" command inside the windows machine without logging into it.I know for linux we ca n we knife ssh but for windows i didn't find exact command to run chef-client remotley.Any help would be appreciated.
Thanks,
Sunilkumar.
Sudo? That would mean that you’re on a linux machine. There’s no sudo command in windows.
If you want to run chef-client remotely on a windows machine, from another windows machine or from a linux machine, there are prereqs steps you need to follow.
So… to run chef-client remotely to a windows machine from a windows machine, follow the instructions from here: http://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/)
To run chef-client to a remote windows machine, from a linux machine, something like this should work:
knife winrm "platform:windows" -P PASSWORD chef-client
Gabriel
Sorry my bad…No sudo…I got a command which can do this task.
knife winrm “10.164.1.89” “chef-client -o ‘recipe[cookbook_name::default]’” -m -x username -P “password”
With the above command i can run chef-client remotely in windows machine.But i have a problem in this my client not allowing me to use username and password.So is there any way to run chef-client remotely without username and password.
The solution would be NOT to use knife winrm
, but
Invoke-Command -ComputerName TheComputerName -ScriptBlock { chef-client }
As I was saying above, you should check if the prereqs are there according to the link above.
In order for this to work, you should make sure that you store the credentials in a variable and that those credentials should belong to a user which is part of the Administrators group on the remote computer.
That if you use a windows as chefDK.
If you use a linux, then you will need another solution
Gabriel
running chef-client
via knife winrm
or Invoke-Command -ComputerName TheComputerName -ScriptBlock { chef-client }
are effectively the same but as @genache mentions, both your node and your workstation need to be propperly configured. Depending on the version of windows running on either, they may be configured already. However, if you do run into connection or authentication issues, have a look at http://www.hurryupandwait.io/blog/understanding-and-troubleshooting-winrm-connection-and-authentication-a-thrill-seekers-guide-to-adventure