Tuesday 26 April 2016

After deploying midtier environment on windows attempt to apply customizations failing with the error:The term 'puppet' is not recognized as the name of a cmdlet, function

After creating the psft_customizations.yaml file, when I tried to run the puppet apply site.pp --debug --trace command on windows power shell. I received a message saying that the term "puppet" is not recognized when running this command.

PS C:\DPK_INSTALL\setup> cd ../..
PS C:\> cd C:\ProgramData\PuppetLabs\puppet\etc\manifests
PS C:\ProgramData\PuppetLabs\puppet\etc\manifests> puppet apply site.pp --debug --trace
puppet : The term 'puppet' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ puppet apply site.pp --debug --trace
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (puppet:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


It is due to the fact that the Puppet software is not included in the system's path. To set the Puppet environment, we need to run the command puppet_shell.bat:

PS C:\> cd '.\Program Files'
PS C:\Program Files> cd '.\Puppet Labs'
PS C:\Program Files\Puppet Labs> cd .\Puppet
PS C:\Program Files\Puppet Labs\Puppet> cd bin
PS C:\Program Files\Puppet Labs\Puppet\bin> ls

    Directory: C:\Program Files\Puppet Labs\Puppet\bin

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        27/01/2015  11:49 AM       1243 environment.bat
-a---        27/01/2015  11:47 AM         91 facter.bat
-a---        27/01/2015  11:47 AM         94 facter_interactive.bat
-a---        27/01/2015  11:47 AM         91 hiera.bat
-a---        27/01/2015  11:47 AM         91 puppet.bat
-a---        27/01/2015  11:47 AM        104 puppet_interactive.bat
-a---        27/01/2015  11:47 AM         89 puppet_shell.bat
-a---        27/01/2015  11:47 AM        104 run_facter_interactive.bat
-a---        27/01/2015  11:47 AM        104 run_puppet_interactive.bat


Execute the command puppet_shell.bat on windows power shell.

This will set the Puppet software in system's path.

After executing the above command you need to restart the windows power shell with Administrator Option.
Open a Windows PowerShell window(with Administrater Option)
a. Select Start, and navigate to Windows PowerShell.
b. Right-click and select Run as Administrator.

And then re-execute the command puppet apply site.pp --debug --trace.

3 comments:

  1. This solution came in handy today. Thanks for taking out time to publish this!

    ReplyDelete
    Replies
    1. Hi Anmol,

      Good to hear that it worked for you.

      Thanks
      Rimpal

      Delete
  2. Many thanks Rimphal for sharing this blog with us, your solution worked. Much appreciate!

    ReplyDelete