I install open source puppet on the servers.
Puppet server have Puppet 3.3.1 and on agent puppet 2.7.25.
Until now I work with manifest file. Now I would like to create a perl/php script
that will create the YAML script and should overwrite the manifest files.
I edit the file puppet.conf and put:
mode_terminus = exec
external_nodes = /usr/bin/env PUPPET_DASHBOARD_URL=http://localhost:3000 /path/to/bin/external_node
In the file /path/to/bin/external_node I put my code for the perl script.
when I run Puppet on the agent, it's look like it still take the manifest instead of the script I put.
Also,
How can I send parameters to the script?
How to access to fact variables from the script, like $hostname etc?
After this part will work I would like to make it visual from the Dashboard too.
Thanks.
SOLVED.
The problem was spelling mistake!
It change it to 'node_terminus = exec'.
node with 'n' and not with 'm'.
Thanks.
Related
In Azure DevOps, I have an Azure Powershell task to create some resources using ps1 script in repo. This script working fine.
Now I need to split the script and variables into different files.
I created files SB-Config.ps1 for variables and ServiceBus.ps1 with main script. Moved all vars into SB-Config.ps1 .
Both files are in the same folder and in ServiceBus.ps1 I added:
. .\SB-Config.ps1
But Azure Devops fails with error:
What I'm doing wrong and how to get variables from SB-Config.ps1 script, when running ServiceBus.ps1 file?
I am able to reproduce your situation on my side.
Same issue as yours.
You can run this command to output the location of current work space:
Get-Location
I notice the powershell script file on your side is in the sub folder of Default working directory.
So do you set the work space in the powershell script file you are running first?
Set-Location $env:System_DefaultWorkingDirectory\subfolders
In your situation, I think the issue comes from the current work space is System_DefaultWorkingDirectory , the error output means the script can't get the file you want. This issue only occurs when you select 'file path' to run.
How can I get the environment variable from docker file for example I am adding a
ENV URL_PATH="google.com"
in my dockerfile, so can I get the this URL_PATH in my Jmeter.jmx file with the help of User Defined Variable.
On window its working fine with proper {__env(URL_PATH)}
but on docker its not working. How can I solve this problem?
You can use the -e option to pass environment variables into the container when running it.
docker run -e URL_PATH=google.com ...
Docs: https://docs.docker.com/engine/reference/run/#env-environment-variables
As far as I can see __env() is a Custom JMeter Function therefore it is not available in vanilla JMeter so the options are in:
Amend your Dockerfile to include downloading of http://repo1.maven.org/maven2/kg/apc/jmeter-plugins-functions/2.0/jmeter-plugins-functions-2.0.jar to "lib/ext". This way you will be able to use __env() function in Docker environment normally. See Make Use of Docker with JMeter - Learn How for example Docker configuration assuming using JMeter with Plugins.
Switch to __groovy() function. Replace all the occurrences of {__env(URL_PATH)} with the following expression:
${__groovy(System.getenv('URL_PATH'),)}
I am playing around with puppet and am trying to copy a file from my local directory (my laptop) on to my puppet agent. I have two VM's running, one is puppet master and one is puppet agent. I looked up at this answer here but it seems like it was an older version on puppet. I am running puppet 3.4.3 . I have gone through the pro puppet book and the puppet tutorials but find them way to confusing (the former having very glaring typos). It would be BIG help if someone helped me out with the process in simple steps. This is what I have till now.
I created a folder named my_module in /etc/puppet/.
In /etc/puppet/my_module is created two folders files, manifests and a file init.pp .
Init.pp looks like this:
class myfile {
file { "/home/me/myfolder/file.py":
mode => "0440",
owner => 'root',
group => 'root',
source => 'puppet:///modules/module_name/datas.xls',
}
}
I then copied the file file.py to the files folder I created above. I am unsure how to proceed after this step. Any help?
please read this documentation regarding creating your own modules. The module you created is in the wrong location right now. Should be /etc/puppet/modules or wherever the modulepath in /etc/puppet/puppet.conf points to on the puppet master.
The file given with source => 'puppet:///modules/module_name/datas.xls' is the one which will be placed in /home/me/myfolder/file.py on the client where you run the puppet agent -t command to rollout your changes.
Another good source for examples how to use the standard builtin puppet features is Type Reference of puppetlabs.
I am using Go server for continuous integration of our code. For my environment-deploy-template, I wish to set certain environment variables on the stage and then echo those in the property files for the application. What would be the Linux command that I could give in my job to do so?
For example, it could be some thing like :
echo "propName=#{env variable}\n">>prop files location
Could someone please confirm this?
The syntax to get go.cd env variable is ${ENV_VAR} and a full command is:
echo propName=${ENV_VAR} >> props.txt
More details on environment variables: Using Environment Variables in Go
I am trying to create a custom provider for package but for some reasons I keep on getting
err: Could not run Puppet configuration client: Parameter provider
failed: Invalid package provider 'piprs' at
/usr/local/src/ops/services/puppet/modules/test/manifests/init.pp:5
I have added pluginsync=true in puppet.conf in both client and server. I have created the following rb file in module/test/lib/puppet/provider/package/piprs.rb. I am basically trying to create a custom provider for package resource type
#require 'puppet/provider/package'
Puppet::Type.type(:package).provide(:piprs,
:parent => ::Puppet::Provider::Package) do
commands : pip => "/usr/local/bin/pip"
desc "Python packages via `pip`."
def create
pip "freeze"
end
def destroy
end
def exists?
end
end
In the puppet.conf, there is the following source attribute
pluginsource = puppet://puppet/plugins
I am not sure what it is. If you need anymore details, please do post a comment.
First things first - you do realize there is already a Python pip provider in core?
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package/pip.rb
If that isn't what you want - then lets move on ...
For starters - try your module without a Puppet master - this is going to be better for development anyway. You need to make sure Ruby can find the library path:
export RUBYLIB=<path_to_module>/lib
Then, try writing a small test in a .pp file:
package { "mypackage": provider => "piprs" }
And run it locally:
puppet apply mytest.pp
This will rule out a code bug in your provider versus a plugin sync issue.
I notice there is a space between the colon and the command - that isn't your problem is it?
commands : pip => "/usr/local/bin/pip"
If you can get this working without a puppetmaster, your problem is sync related.
There are a couple of things that can go wrong - make sure the file is sync'd properly on the client:
ls /var/lib/puppet/lib/puppet/provider/package
You should see the piprs.rb file there. If it is, you may need to make sure your libdir is set correctly:
puppet --configprint libdir
This should point to /var/lib/puppet/lib in most cases.