Puppet: Install rpm - puppet

I am trying to install jdk rpm via Puppet. I have tried lot of manifests but none of them working.
At this moment, I have manifest like this
class java {
#file {' Java 8 rpm file':
#source => 'puppet:///modules/java/jdk-8u161-linux-x64.rpm',
#}
package { 'jdk-8u161-linux-x64.rpm':
ensure => 'present',
provider => 'rpm',
source => '/etc/puppetlabs/code/environments/production/modules/java/jdk-8u161-linux-x64.rpm',
}
}
And I am getting below error
[root#sahasraarchi ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for sahasraarchi.devmac.com
Info: Applying configuration version '1517758835'
Error: Execution of '/usr/bin/rpm -i /etc/puppetlabs/code/environments/production/modules/java/jdk-8u161-linux-x64.rpm' returned 1: error: open of /etc/puppetlabs/code/environments/production/modules/java/jdk-8u161-linux-x64.rpm failed: No such file or directory
Error: /Stage[main]/Java/Package[jdk-8u161-linux-x64.rpm]/ensure: change from absent to present failed: Execution of '/usr/bin/rpm -i /etc/puppetlabs/code/environments/production/modules/java/jdk-8u161-linux-x64.rpm' returned 1: error: open of /etc/puppetlabs/code/environments/production/modules/java/jdk-8u161-linux-x64.rpm failed: No such file or directory
Notice: Applied catalog in 2.01 seconds
[root#sahasraarchi ~]#

Seems I have missed basic point here. Source at package attribute is always referring the address on Puppet-agent. i.e to where file copying to remote machine before its getting installed.
class java {
file {' /tmp/jdk-8u161-linux-x64.rpm':
source => 'puppet:///modules/java/jdk-8u161-linux-x64.rpm',
}
package { 'jdk-8u161-linux-x64.rpm':
ensure => 'present',
provider => 'rpm',
source => '/tmp/jdk-8u161-linux-x64.rpm',
require => File["/tmp/jdk-8u161-linux-x64.rpm"],
}
}
Will install the rpm at Puppet-agent.

Related

autoload error when using puppetlabs/chocolatey module

I am not new to puppet, but I am new to using it on Windows. Trying to configure chocolatey using the puppetlabs/chocolatey module. Initial puppet run without the module worked just fine. Then I added include chocolatey to the manifest, and it downloaded and installed chocolatey. So far, so good. However, then I went to add a custom source like so:
chocolateysource { 'mysource':
ensure => present,
location => 'https://my.chocolatey.source',
priority => 10,
}
Now I get the following message when running puppet agent -t:
PS C:\Windows\system32> puppet agent -t
Error: Could not autoload puppet/provider/package/chocolatey: C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/package/chocolatey.rb:280: syntax error, unexpected '.'
pin_output&.split("\n")&.each { |pin| pin...
^
C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/package/chocolatey.rb:280: syntax error, unexpected '.'
... pin_output&.split("\n")&.each { |pin| pins << pin.spli...
... ^
Error: Facter: error while resolving custom facts in C:/ProgramData\PuppetLabs\puppet\cache\lib\facter\package_provider.rb: Could not autoload puppet/provider/package/chocolatey: C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/package/chocolatey.rb:280: syntax error, unexpected '.'
pin_output&.split("\n")&.each { |pin| pin...
^
C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/provider/package/chocolatey.rb:280: syntax error, unexpected '.'
... pin_output&.split("\n")&.each { |pin| pins << pin.spli...
... ^
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Redefining package in Puppet::Type
Error: Could not autoload puppet/type/chocolateysource: C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/type/chocolateysource.rb:221: syntax error, unexpected '.'
parameter(:password)&.sensitive = true
^
Error: Could not retrieve catalog from remote server: Could not intern from text/pson: Could not autoload puppet/type/chocolateysource: C:/ProgramData/PuppetLabs/puppet/cache/lib/puppet/type/chocolateysource.rb:221: syntax error, unexpected '.'
parameter(:password)&.sensitive = true
^
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
As a non-Windows user, I feel like I'm missing something to make this work, but I'm not sure what it is. I have verified that .Net framework is installed, but not sure what else to check here. Thanks in advance for any help.
Turns out the version was the issue. I had mistakenly installed puppet 4 agent, while the server is puppet 7.

Puppet Error : Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class

I am testing this out and getting an error on the Puppet agent node
[root#pagent1 ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::nginx for pagent1.testcentos7.com (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 3, column: 3) on node pagent1.testcentos7.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Content of these classes from the Puppet server:
[root#pmaster ~]# cat /etc/puppetlabs/code/environments/production/manifests/site.pp
node pagent1.testcentos7.com {
class { 'nginx': }
}
[root#pmaster ~]# cat /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp
class nginx {
contain nginx::install
}
[root#pmaster ~]# cat /etc/puppetlabs/code/environments/production/modules/nginx/manifests/install.pp
class nginx::install {
package { 'install_nginx':
name => 'nginx',
ensure => 'present',
}
}
Syntax check shows this error:
[root#pmaster ~]# puppet parser validate /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp
Error: Could not parse for environment production: Unacceptable location. The name 'nginx' is unacceptable in file '/etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp' (file: /etc/puppetlabs/code/environments/production/modules/nginx/manifests/manifests/init.pp, line: 7, column: 1)
NOTE: Created module 'nginx' and its classes using Puppet Development Kit(PDK).
Is that a bug or something or I made a mistake with the class name?.
Related thread I found is https://groups.google.com/forum/embed/#!topic/puppet-users/nxbwCvWrgMI but would like to have someone simplify this for me
Solved this by moving 'init.pp' to the path /etc/puppetlabs/code/environments/production/modules/nginx/manifests where install class file 'install.pp' exists.
For more clarity, I put both the files 'init.pp' and 'install.pp' in the same location directory /etc/puppetlabs/code/environments/production/modules/nginx/manifests to solve this.

Puppet Agent Could not retrieve catalog

I installed Maven module in Master machine using this command:
puppet module install maestrodev-maven --version 1.4.0
It installed it successfully in /etc/puppet/modules/
Afterwards I added following code inside the file /etc/puppet/manifests/site.pp of master machine
node 'test02.edureka.com'
{
include maven
}
Now, when I run below command on Puppet Agent machine
puppet agent -t
It gives error:
root#test02:~# puppet agent -t
Warning: Unable to fetch my node definition, but the agent run will continue:
Warning: execution expired
Info: Retrieving pluginfacts
Error: /File[/var/lib/puppet/facts.d]: Failed to generate additional resources using 'eval_generate': execution expired
Error: /File[/var/lib/puppet/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet://test01.edureka.com/pluginfacts: execution expired
Info: Retrieving plugin
Error: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate': execution expired
Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve file metadata for puppet://test01.edureka.com/plugins: execution expired
Info: Loading facts
Error: JAVA_HOME is not defined correctly.
We cannot execute
Could not retrieve fact='maven_version', resolution='': undefined method `split' for nil:NilClass
Error: Could not retrieve catalog from remote server: execution expired
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Error: Could not send report: execution expired
root#test02:~#
puppet.conf file on master:
puppet.conf file on agent:
Error screenshot:

Puppet master and client on one machine

I would like to test the puppet client on the same machine as the master resides. I followed this tutorial "http://www.elsotanillo.net/2011/08/installing-puppet-master-and-client-in-the-same-host-the-debian-way/". He was saying that generating SSL at the right moment is the trick involved in keeping master and client communicating successfully in one machine. I killed puppet master process, generated puppet.conf file as he given in that link, installed puppet client, but when I try to generate SSL using the below command. It failed. You could see the log below.
puppetd --no-daemonize --onetime --verbose --waitforcert 30
I replaced puppetd with puppet agent to make it work in latest version of puppet
Warning: Unable to fetch my node definition, but the agent run will
continue:
Warning: Connection timed out - connect(2)
Info: Retrieving pluginfacts
Error: /File[/home/lhdadmin/.puppet/var/facts.d]: Failed to generate
additional resources using 'eval_generate': Connection timed out -
connect(2)
Error: /File[/home/lhdadmin/.puppet/var/facts.d]: Could not evaluate:
Could not retrieve file metadata for puppet://puppet/pluginfacts:
Connection timed out - connect(2)
Info: Retrieving plugin
Error: /File[/home/lhdadmin/.puppet/var/lib]: Failed to generate
additional resources using 'eval_generate': Connection timed out -
connect(2)
Error: /File[/home/lhdadmin/.puppet/var/lib]: Could not evaluate:
Could not retrieve file metadata for puppet://puppet/plugins:
Connection timed out - connect(2)
I tried to install puppetdb thinking that was the missing component could be triggering the above error, but it couldn't find puppetdb module to install. see the errors below
sudo puppet resource package puppetdb ensure=latest
Error: Could not update: Execution of '/usr/bin/apt-get -q -y -o
DPkg::Options::=--force-confold install puppetdb' returned 100:
Reading package lists... Building dependency tree... Reading state
information... E: Unable to locate package puppetdb Error:
/Package[puppetdb]/ensure: change from purged to latest failed: Could
not update: Execution of '/usr/bin/apt-get -q -y -o
DPkg::Options::=--force-confold install puppetdb' returned 100:
Reading package lists... Building dependency tree... Reading state
information... E: Unable to locate package puppetdb
package { 'puppetdb': ensure => 'purged', }
Aah , I think you have not mentioned your puppet class in init.pp or have defined your node in node.pp .
If you don't want to use puppetdb then please don't include in your puppet/puppet.conf file and if you want to use it then cross check the puppetdb by login in manually by the user mentioned in puppet.conf file.
storeconfigs = true
dbname = puppet-db
dbadapter = mysql
dbuser = puppet-user
dbpassword = puppet
dbserver = localhost
Also check for the proper repo in /etc/apt/sources.list , E: Unable to locate package puppetdb this error generally occurs due to failed internet connectivity, or if it is unable to reach the server.

puppet-acl module on Windows throws transactionstore.yaml corrupt error

Trying out puppet-acl module on Windows Server 2016, Preview5. I'm getting the weirdest error on the second puppet run. If i remove the trnsactionstore.yaml file, and re-run the puppet agent, the behavior is repeatable. Im running puppet4 with latest agent version.
This is my codeblock
acl { "c:/temp":
permissions => [
{ identity => 'Administrator', rights => ['full'] },
{ identity => 'Users', rights => ['read','execute'] }
],
}
This is the output from the puppet-run.
PS C:\ProgramData\PuppetLabs\puppet\cache\state> puppet agent -t
Info: Using configured environment 'local'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for opslowebf02n02.local
Error: Transaction store file C:/ProgramData/PuppetLabs/puppet/cache/state/transactionstore.yaml is corrupt (wrong number of arguments (0 for 1..2)); replacing
Error: Transaction state file C:/ProgramData/PuppetLabs/puppet/cache/state/transactionstore.yaml is valid YAML but not returning a hash. Check the file for corruption, or remove it before continuing.
Info: Applying configuration version '1471436916'
Notice: /Stage[main]/platform_base_system::Role::Windows/Exec[check-powershell-exection-policy]/returns: executed successfully
Notice: /Stage[main]/configs_iis::Profile::Default/Exec[check-iis-global-anonymous-authentication]/returns: executed successfully
Notice: Applied catalog in 7.42 seconds
In the transactionstore.yaml file, this is the error section:
Acl[c:/temp]:
parameters:
permissions:
system_value:
- !ruby/hash:Puppet::Type::Acl::Ace {}
- !ruby/hash:Puppet::Type::Acl::Ace {}
inherit_parent_permissions:
system_value: :true
This has been resolved by dowwngrading the puppet agent to 4.5.3.
Behavior of the 4.6.0 version must have changed.
With 4.5.3 i still see the error in the logfile, but the puppetrun does not fail
I'll try to talk to the people at puppet about this.
Acl[c:/temp]:
parameters:
permissions:
system_value:
- !ruby/hash:Puppet::Type::Acl::Ace {}
- !ruby/hash:Puppet::Type::Acl::Ace {}
inherit_parent_permissions:
system_value: :true
This is being tracked as https://tickets.puppetlabs.com/browse/PUP-6629. It's almost coincidental that you created https://tickets.puppetlabs.com/browse/PUP-6630 right afterwards.

Resources