what does puppet do when a service's status fails? - puppet

I have this in my event log for one of my nodes in the puppet dash board:
Changed (1)
Service[openstack-keystone] (/etc/puppetlabs/puppet/modules/keystone/manifests/init.pp:129)
Property Message
ensure ensure changed 'stopped' to 'running'
But how can I see what actually command puppet is using to change the service's state from stopped to running?
And how can I change it, if I don't think puppet is doing the correct thing?

You can run puppet agent -t --debug to manually start a puppet run and see the commands being run.
To change the commands, you can consider specifying the provider or the start, stop, status, and restart commands on the service resource. Check out the type reference for more information on the service type's parameters.

1)If you want to see the background work of puppet means how it is applying the catalog.
step1) Stop the puppet master and client daemon. eg:/etc/init.d/puppetmaster stop.
step2) Run the puppet master and puppet agent as a foreground process to see the
- puppet master --no-daemonize (run master as foreground process)
- puppet master --debug --no-daemonize (To debug the puppet master)
- puppet agent --no-daemonize (run agent as foreground)
- puppet agent --debug --no-daemonize (run as foreground and debug)
2) If you think puppet is not doing this properly, you can write your own DSL with puppet types and provider or go with the EXEC to execute commands.Even though if you feel that it is not working as yo then you can write the script to execute on agent nodes.

Related

How can I run Puppet 6 on-demand against multiple remote Linux nodes?

On Puppet 3, I used to use sudo mco puppet runonce -I /hostname-pattern-1/ -I /hostname-pattern-2/ to run Puppet agents on-demand against any node matching one of the hostname patterns.
As of Puppet 5.5.4, MCollective is deprecated, so I can no longer use the mco command.
With Puppet 6, how can I do what I used to be able to do with the mco command?
My server and all my nodes are running Ubuntu 20 (Linux). I'm specifically using Puppet 6.19.1 and Puppet Server 6.14.1.
I know puppet agent -t can be used to run Puppet on-demand, but that has to be done locally on each node, so how can I apply that command (or something equivalent) from the Puppet server to any node matching a pattern?
I know I could hardcode a bunch of hostnames in a Bash script and use SSH to remotely execute the command, but hardcoding hostnames is not as convenient as specifying hostname patterns.
Have you checked choria?
Puppet Bolt might be another alternative, you could write a task to do something more complex, or just run ad-hoc commands
e.g.
bolt command run 'puppet agent -t' --targets servers
You connect bolt to your puppetdb so you won't have to create and update a static inventory

Puppet Unscheduling all events on Stage [main]

I have an issue with Puppet and want to understand it better. When I run puppet agent -t on my client it runs and recognises an Exec command which is triggered from a refresh event.
The Exec doesn't execute at all and I have noticed that a little later in the /var/log/messages there is another input which says
Unscheduling all events on Stage [main]
What I need to know is, is it this Unscheduling that is stopping my Exec command from running?

How to create a httpd container in docker through jenkins job?

I need help in creating the container through Jenkins job.
Let me know the steps to be followed: I have already created 3 jobs in Jenkins, and I want to create httpd container through the jobs created.
Should I install any plugins or write any script ?
Assuling we are not talking about Jenkins in docker, or Jenkins agents in Docker, you need to create your http container manually first, without Jenkins.
That means:
validate your SSH access to the remote server
Check it has Docker installed
execute docker commands to run an http container, s described in Docker httpd
Once that is working, you can replicate the process in a Jenkins Job, provided your remote server (the one with Docker, where you want to run your httpd container) is declared as agent to the main Jenkins controller.

Puppet agent daemon should not start during startup

I have installed puppet agent in my servers.
1.My agent is running automatically and is stopping my apache which is installed via puppet.
puppet agent --configprint runinterval
1800
2.I can kill the process but do not want this process to start during server reboot.
Can someone have any ideas?
Hmm. After installing my agent for the first time, I ran it the first time, to request a certificate from master with
sudo puppet agent --verbose --no-daemonize --onetime
Which (among other things) instructs the agent to not continue running as a daemon.
Then after signing the cert on master I am able to run the agent on demand with.
sudo puppet agent -t
The -t (--test) flag on the agent effectively adds --onetime --verbose --no-daemonize --no-usecacheonfailure --detailed-exitcodes --no-splay --show_diff --no-use_cached_catalog to the agent run. Therefore this way the agent is always run --nodaemonize, and I have not run into the problem of the agent running automatically.
Not sure if this addresses your use case.

Puppet agent on Debian client does not start on boot

I have a Debian VM with puppet client installed.
All is well when I manually run:
puppet agent
after I run it, I can see using "service puppet status" that the process is running OK.
I want this process (starting the puppet agent) to happen automatically on system boot.
I followed the instructions of changing /etc/init.d/puppet so that it starts
START=yes
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/puppet
DAEMON_OPTS=""
NAME=agent
DESC="puppet agent"
PIDFILE="/var/run/puppet/${NAME}.pid"
BUT - when I boot the system, this service does not start !
What am I doing wrong ?
I
You need to set START=yes in /etc/default/puppet instead of right in the initscript.
As an aside, this question would be more suitable on ServerFault.

Resources