Puppet environment: Parameter source failed on File - puppet

I have an issue with retrieving file from puppet agent. I'm running puppet master 3.7 version. Here is my structure:
.
|-- auth.conf
|-- environments
| |-- dev
| | |-- environment.conf
| | |-- manifests
| | | `-- site.pp
| | `-- modules
| | `-- common
| | |-- files
| | | `-- profile
| | |-- manifests
| | | `-- init.pp
| | `-- staticFiles
| | `-- profile
| |-- prod
| | |-- environment.conf
| | |-- manifests
| | | `-- site.pp
| | `-- modules
| | `-- common
| | `-- manifests
| | `-- init.pp
| `-- uat
| |-- environment.conf
| |-- manifests
| | `-- site.pp
| `-- modules
| `-- common
| `-- manifests
| `-- init.pp
|-- etckeeper-commit-post
|-- etckeeper-commit-pre
|-- fileserver.conf
|-- hieradata
|-- hiera.yaml
|-- manifests
|-- modules
|-- nodes
`-- puppet.conf
My config is with puppet environment prod,uat and dev.
In dev environment I have:
manifest = /etc/puppet/environments/dev/manifests/site.pp
#modulepath = /etc/puppet/environments/dev/modules
modulepath = site:dist:modules:$basemodulepath
In a puppet client conf, I have:
environment = dev
basemodulepath=/etc/puppet/environments/$environment/modules
Here is my init common puppet module:
file { "/etc/profile":
ensure => "file",
mode => 644,
owner => "root",
group => "root",
require => Package["tree"],
source => "puppet::///common/profile"
}
On the node I got this error:
Error: Failed to apply catalog: Parameter source failed on File[/etc/profile]: Cannot use opaque URLs 'puppet::///common/profile' at /etc/puppet/environments/dev/modules/common/manifests/init.pp:13
Wrapped exception:
Cannot use opaque URLs 'puppet::///common/profile'
Even if I put source file like:
"puppet::///common/staticFiles/profile"
"puppet::///common/files/profile"
"puppet::///modules/common/profile"
"puppet::///modules/common/files/profile"
"puppet::///modules/common/staticFiles/profile"
I still got the same issue !
Do anyone know are to solve this issue?
I really want to retrieve "profile" file in /etc/puppet/environments/dev/modules/common/files/ directory.
Here is also my puppet master conf content:
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
server = puppetmaster01
certname = puppetmaster01
environment = prod
condir = /etc/puppet
report = true
show_diff = true
trace = true
runinterval=60
environmentpath=$confdir/environments
#basemodulepath = $environmentpath/$environment/modules:/etc/puppet/modules:/usr/share/puppet/modules
[master]
# These are needed when the puppetmaster is run by passenger
# and can safely be removed if webrick is used.
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY
certname = puppetmaster01
#modulepath=$confdir/environments/$environment/modules:$confdir/modules
[agent]
report = true
show_diff = true

The URL
puppet:///modules/common/profile
should work. Please make sure that directory environments are in fact enabled on the master.
If this keeps failing consistently, please run
puppet agent --test --trace --verbose --debug
and paste the output on an appropriate service for review.

Related

AntBuilder : Warning: Could not find file to copy

In this Jenkinsfile, I want to copy the list of changed files in GitHub to a new directory /toucd, and then upload them to UCD.
I don't know why the AntBuilder is giving me the above error" Could not find file to copy". Please help.
stage("list-workspace") {
steps {
sh """
tree ${env.WORKSPACE}
"""
}
}
stage("search-changes") {
steps {
script {
def allChangeFiles = getAllChangeFiles()
if (allChangeFiles.isEmpty()) {
echo "No changed file"
exit 1
}
echo "Consolidated all changed files:"
allChangeFiles.each {
println "# ${it}"
}
String sourceDir = "${env.WORKSPACE}//"
String targetDir = "${env.WORKSPACE}//toucd//"
def ant = new AntBuilder()
allChangeFiles.each {
if (it.endsWith(".xml") || it.endsWith(".bprelease")) {
ant.copy( file:"${sourceDir}${it}", tofile:"${targetDir}${it}")
println "${it} copied"
}
}
} // script
} // steps
} //stage("search-changes")
Output:
> git rev-list --no-walk a836e45cff6d96d294c89e05d5d3aa6719227b70 # timeout=10
14:17:25 + tree /home/jenkins/workspace/BluePrism/Get-Change-List
14:17:25 /home/jenkins/workspace/BluePrism/Get-Change-List
14:17:25 |-- EventAuditPush.sh
14:17:25 |-- GetChangeList_Jenkinsfile
14:17:25 |-- Object
14:17:25 | `-- BPA\ Object\ -\ DevOpsSampleObject1.xml
14:17:25 |-- Process
14:17:25 | `-- BPA\ Process\ -\ DevOpsSampleProcess1.xml
14:17:25 |-- README.md
14:17:25 `-- Release
14:17:25 |-- Release1.1.bprelease
14:17:25 `-- Release1.2.bprelease
14:17:25
14:17:25 3 directories, 7 files
14:17:26 [Pipeline] }
14:17:26 [Pipeline] // stage
14:17:28 : Warning: Could not find file /home/jenkins/workspace/BluePrism/Get-Change-List/Release/Release1.2.bprelease to copy.
14:17:28 at org.apache.tools.ant.taskdefs.Copy.copySingleFile(Copy.java:639)
I faced the same kind of issue but resolved it with using shell command instead of groovy. I tried many ways to copy file using groovy but none of them worked.
sh """
cp ${sourceDir}${it} ${targetDir}${it}
"""

Puppet class missing even when file exists

The directory structure of the puppet repo is as:
.
|-- data
| |-- common.yaml
|-- environment
| |-- environment.conf
| `-- hiera.yaml
|-- files
| `-- cdn
|-- hiera
| `-- hiera.yaml
|-- hiera.global.yaml
|-- manifests
| `-- site.pp
|-- modules
|
`-- site
|-- profile
| |-- files
| `-- manifests
| |-- appliance
| | |-- base.pp
`-- role
`-- manifests
|-- README.md
`-- role1
`-- appliance.pp
The site.pp file is as :
File { backup => false }
if $::custom_facts['appliance_type'] == 'Delivery' {
include role::role0::app
}
if $::custom_facts['appliance_type'] == 'Appliance' {
include role::role1::appliance **// line where error is occuring**
}
node default {
}
When I run the puppet apply command it fails with this error:
Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::role::role1::appliance for default-puppetmaster-centos-7.vagrantup.com (file: /tmp/kitchen/manifests/site.pp, line: 9, column: 3) on node default-puppetmaster-centos-7.vagrantup.com
The puppet command that is applied:
sudo -E /opt/puppetlabs/bin/puppet apply /tmp/kitchen/manifests/site.pp --modulepath=/tmp/kitchen/modules --fileserverconfig=/tmp/kitchen/fileserver.conf --environment=kitchen_vagrant_puppet --environmentpath=/etc/puppetlabs/code/environments --hiera_config=/tmp/kitchen/hiera.global.yaml
I cant figure out why puppet cannot find the class. The class is in the role folder. Is the directory structure wrong?
Edit:
Adding contents of envirnment.conf file:
modulepath = site:modules:$basemodulepath
Is this just because the modulepath needs to include site? Your manifests are in site rather than modules.
sudo -E /opt/puppetlabs/bin/puppet apply /tmp/kitchen/manifests/site.pp \
--modulepath=/tmp/kitchen/modules:/tmp/kitchen/site \
--fileserverconfig=/tmp/kitchen/fileserver.conf \
--environment=kitchen_vagrant_puppet \
--environmentpath=/etc/puppetlabs/code/environments \
--hiera_config=/tmp/kitchen/hiera.global.yaml
I'd check the modulepath in environment.conf, too, just in case.

tsc is trying to resolve relative path modules in the wrong folder

I'm using npm link to reference a typescript library I'm developing in my test project
Which means that my node_modules looks like this :
node_modules/
| myLib/
| | dist/
| | | subModule/
| | | | index.js
| | | | index.d.ts
| | | index.js
| | | index.d.ts
| | node_modules/
| | src/
| | tsconfig.json
| | package.json
Which implies that when I'm trying to reference my library using import X from "myLib" I have to tell the compiler that the sources are in the /dist forlder, not that the root of myLib.
I solved this by adding a "main": "./dist/index.js" in the package.json of myLib
The problem is when I try to import a path relative to myLib
Like import Y from "myLib/subModule"
This time it doesn't work.
Because instead of looking at node_modules/myLib/dist/subModule tsc is looking at node_modules/myLib/subModules/dist/ which doesn't exist.
How can I make the compiler to look at the right path for subModules ?
You can resolve this by using the "paths" key in the "compilerOptions" in your tsconfig.json. Something like this:
{
"compilerOptions": {
"paths": {
"myLib/*": "node_modules/myLib/dist/*"
}
}
}
Sadly, this is something of a standing issue with how the TypeScript compiler resolves definition files when you have a "types" key in your package.json.

Trying to run puppet yield "Error: Could not find class"

Firstly, to be honest I'm pretty new to Puppet world. I'm trying to build a puppet script for my server.
Here's how my puppet structures looks like -
.
|-- environments
| `-- example_env
| |-- manifests
| |-- modules
| `-- README.environment
|-- manifests
| |-- node.pp
| `-- site.pp
|-- modules
| |-- nginx
| | `-- manifests
| | `-- nginx.pp
| |-- sudoers
| | |-- files
| | | `-- sudoers
| | `-- manifests
| | `-- sudoers.pp
| `-- users
| `-- manifests
| `-- users.pp
|-- puppet.conf
`-- templates
here how my node.pp and site.pp look like this.
# /etc/puppet/manifests/node.pp
node werain {
include sudoers
}
and
# etc/puppet/manifests/site.pp
import 'node.pp'
and finally my sudoers.pp file look like this.
# /etc/puppet/modules/sudoers/manifests/sudoers.pp
class sudoers {
file { '/etc/sudoers':
mode: '0400',
source: 'puppet:///modules/sudoers/sudoers',
owner: 'root',
group: 'root'
}
}
Any clue what I'm doing wrong.
I'm running the puppet command like this.
puppet apply /etc/puppet/manifests/site.pp --modulepath=/etc/puppet/modules/
my puppet version is 3.8.4
You have a module named sudoers, and in it a class with the same name. Puppet will look for the definition of that class in modules/sudoers/manifests/init.pp, but you have put it in modules/sudoers/manifests/sudoers.pp instead. That latter is where Puppet would look for a class named sudoers::sudoers.

Class not taken into account in Puppet run

I am creating a "site module" to manage multiple VM.
I used this project as a template : https://github.com/nvalentine-puppetlabs/puppet-site which is based on a convention described by Craig Dunn at: http://www.craigdunn.org/2012/05/239/
I am using Puppet 3.4.3 (Puppet Enterprise 3.2.1).
I modified the role class to include the base profile.
class site::role inherits site::role::params {
require site
notify { "site::role": }
include site::profile::base
}
class site::profile::base inherits site::profile::base::params {
require site::profile
notify { "site::profile::base": }
include site::users
package { [
'htop',
'rsync',
'openssl',
'man',
'wget',
'nano',
'lsb-release',
'tree' ]:
ensure => present,
}
}
I have added the class site::role::www to my nodes.
Everything so far worked fine. All the packages were installed.
I then tried to create a www role and a webserver profile.
class site::role::www inherits site::role::www::params {
require site::role
notify { "site::role::www": }
# perhaps all nodes at your site use this as a base?
include site::profile::webserver
}
class site::profile::webserver inherits site::profile::webserver::params {
require site::profile
notify { "site::profile::webserver": }
file { "/home/httpd/":
ensure => "directory",
}
->
class { 'apache':
serveradmin => 'dev#domain.com',
server_tokens => 'Prod'
}
->
apache::vhost { "$ipaddress":
port => '80',
docroot => '/home/httpd/exploit',
}
include apache::mod::php
}
But none of the modifications declared in the webserver profile are taken into account...
Structure of the module:
site/
|-- LICENSE
|-- Modulefile
|-- README.md
|-- manifests
| |-- init.pp
| |-- params.pp
| |-- profile
| | |-- base
| | | `-- params.pp
| | |-- base.pp
| | |-- params.pp
| | |-- webserver
| | | `-- params.pp
| | `-- webserver.pp
| |-- profile.pp
| |-- role
| | |-- params.pp
| | |-- www
| | | `-- params.pp
| | `-- www.pp
| |-- role.pp
| `-- users.pp
|-- metadata.json
`-- tests
|-- init.pp
|-- site_profile.pp
|-- site_profile_base.pp
`-- site_role.pp
Content of classes.txt on agent nodes:
root#****:/var/opt/lib/pe-puppet# cat classes.txt
pe_mcollective
site::role::www
settings
default
pe_mcollective
pe_mcollective::params
pe_mcollective::role::agent
pe_mcollective::server
pe_mcollective::server::plugins
pe_mcollective::shared_key_files
site::role::www::params
site::params
site::role::params
site::role::www
site::role
site
site::profile::base::params
site::profile::params
site::profile::base
site::profile
site::users

Resources