We're using Puppet + Foreman to monitor changes in environment by checking custom facts. For example, whenever a custom fact equals 'true' puppet calls the Notify resource with a message sent to the agent log. Puppet includes this message in the agent report and Foreman shows this in UI.
Problem is that whenever a message is thrown, Foreman considers this action as "Applied" and the node status changes to "Active" (blue icon).
We want to keep the node at "No Changes" (Green) plus show the Notify message.
Is that possible in some way? Maybe define a new custom resource type?
Here is the puppet code:
class mymodule::myclass::mysubclass {
if $::fact023 == 'fail' {
notify {'mynotify1':
message => "WARNING: Node ${::fqdn} failed fact023",
loglevel => hiera('warnings_loglevel'),
} } }
See screenshot of Foreman here
Update:
I'll refine the question: Is there a way to use the Notify resource without causing puppet to report that the node has changed? Meaning just print the message to client log (and therefore the message will be visible in report) but without puppet classify the event as an applied configuration?
The reason is that when puppet triggers the Notify resource, Foreman flags the node as being active (changed)
UPDATE #2
I'm thinking about changing Foreman report file so that the UI will ignore Notify events so that the node's status will remain unchanged but still show the message in the report. Can someone point me to the right direction? Thanks!
UPDATE #3
Problem fixed after switching from the "Notify" resource type to custom type "echo" created by some dude in Puppet Forge. Thanks!
It's not completely clear what you are trying to accomplish. One option would be to use the notice function instead of a resource. Functions execute on the puppet master, so you the log will end up in the puppet master's logs instead of the agent report. That also means that it will not count as an applied resource, and the node should appear to be stable.
Related
When I recreate my VM I got the following error:
Problem occurred during request to Azure services. Cloud provider details: Unable to edit or replace deployment 'VM-Name': previous deployment from '8/20/2019 6:20:33 AM' is still active (expiration time is '8/27/2019 5:17:41 AM'). Please see https://aka.ms/arm-deploy for usage details.
Help me please to understand.
What could be the cause of the error ?
UPDATED:
This deployment has not been started previously.
Prior to this, errors were received during creation:
Azure is not available now. Please Try again later
There were several such errors one at a time and then I got that error related to:
Unable to edit or replace deployment
My assumptions about this.
Tell me, am I right or not ?
I launched the image, then after some time I recreated it.
Creation began, but at that moment the connection with Azure was lost.
Then, when the connection was restored, we tried to make a deployment that was not removed in the previous attempt (because there was no connection with Azure).
As a result, we got such an error.
Does this theory make sense?
exactly what it says, there is another deployment with the same name going on at this time, either change the name of the deployment you are trying to queue or wait for the other deployment to finish\fail
This can also occur if you use Bicep templates for your ARM deployement and multiple modules or resources in the template have the same name:
module fooModule '../modules/foo.bicep' = {
name: 'foo'
}
module barModule '../modules/bar.bicep' = {
name: 'foo'
}
I got the same error initially pipeline was working but when retriggered pipeline took more time so i canceled the deployment and made a fresh rerun it encounters. i think i need wait until that deployment filed.
We have a powershell DSC that is being executed to bring a vmss to a desired state.
It was working until we added some more parameters, and then it broke.
I removed everything except the parameters from the script and it still doesn't work.
The full error is
The DSC Extension received an incorrect input: An error occurred while
executing script or module 'IISInstall.ps1': An item with the same
key has already been added..
Please correct the input and retry executing the extension.
We even added logging in the DSC to try to troubleshoot.
It doesn't even seem to make it into the body of the DSC.
What am I doing wrong?
The parameter was called $instanceName. We wanted to use it to add a custom header to IIS to track which instance a response came from.
Turns out if you use $instanceName that steps on the internals of DSC in some way and it will never deploy correctly!
As soon as you remove $instanceName from the parameter list, it will work.
I'm looking for a way to display a notify { ... } message during puppet client run only when using
puppet apply <--verbose | --debug>
puppet agent <--verbose | --debug>
I'd like to display debug messages when interactively/manually running puppet on clients.
Yet, I couldn't find a way to evaluate these switches in my puppet manifests. How could I achieve this for puppet 4.x?
All Puppet resources support the loglevel metaparameter, including notify. Set it to debug to make a resource report on that level.
notify { "this is a debug message": loglevel => "debug" }
Output from such resources is hidden by default.
The verbose option does not imply a specific log level.
I have CruiseControl.NET setup to send out an email if there is a compile error and when the error has been fixed:
<notifications>
<notificationType>Change</notificationType>
</notifications>
However this also sends out an email if the source code repository can't be reached. This is expected since the server is restarted every night.
How can I limit the alert emails to compile errors only?
this also sends out an email if the source code repository can't be reached
You can use the sourceControlErrorHandling tag (action to take when a source control error occurs)
<maxSourceControlRetries>3</maxSourceControlRetries>
<sourceControlErrorHandling>ReportOnRetryAmount</sourceControlErrorHandling>
Setting ReportOnRetryAmount to a high value will lower your exception build email.
Reference: 'Project Configuration Block' documentation.
http://www.cruisecontrolnet.org/projects/ccnet/wiki/Project_Configuration_Block
I don't think CC.NET is able to distinguish a "usual" build failure from source code unavailability. The notification type can be one of the following: {'Always', 'Change', 'Failed', 'Success', 'Fixed', 'Exception'}. I'm not sure I can tell the difference between Failed and Exception - probably, the first is a build failure, including unit test failure, etc., while the other one refers to the CC.NET own code failure.
Anyway, if I were you, I would do one of the following:
experiment with notification types (just in case)
make sure the build process is not triggered when the server is restarting, e.g. if you configured nightly builds, you can schedule those to run after the server restarts
How can we write a puppet manifest code that identifies whether a service(httpd) is running or not on puppet clients/agents. And if not, it should start that service and send out an email ?
class apache {
package { mysql-server: ensure => installed }
if hasstatus == "false" {
service { "mysql":
ensure => running,
require => Package["mysql-server"],
}
}
}
node default {
include apache
}
I know this is not a correct code. But I want to check hasstatus first and if the service status is false then I want to start service and send out an email.
Thanks
Sanket Dangi
I have configured tagmail.conf in puppet master and have also enabled puppet reports but not able to receive mails to my gmail account. I can see puppet agent reports on puppet master but not receiving mails. Do I need to configure mail server for this ?
My Tagmail Conf :
all: xxxxxxx#gmail.com
Puppet isn't an imperative shell script where you need to check the value of X before performing action Y that gets you to state Z. Instead, you specify that you want state Z and Puppet checks the current state and handles the transition.
What this means is that you don't need to check the status of a service before deciding whether to start it or not and instead you declare that the mysql service should be running and Puppet ensures this is the case.
Simply have this in your manifest alongside the package line:
service { "mysql":
ensure => running,
enable => true,
require => Package["mysql-server"],
}
The require line ensures the package is installed before evaluating or starting the service.
To send out notifications you can use the tagmail reporting feature in Puppet. First set up a tagmail file (reference docs) like this at /etc/puppet/tagmail.conf on the master:
mysql, apache: wwwadmins#example.com
And in the master's puppet.conf, set:
[master]
reports = tagmail
Ensure clients have report enabled in puppet.conf:
[agent]
report = true
This should then trigger e-mails relating to any resources with the "mysql" or "apache" tags (class names, module names etc).