Ansible : get playbook result - notifications

I am using Ansible to deploy a PHP website into my servers (production, staging, etc), and I would like to get a notification (via skype).
For it I need learn ansible to send post request (with some params) when any ansible task starts or finishes (with result : success/failed or with error description)
Help me please with realization of all this stuff since I have any ideas about it. =(

You have to write your own callback plugin.
Take a look at slack notification plugin.

Related

Thruk cgi authentication override

I have the latest version of thruk installed with naemon and livestatus. I want to be able to post commands from a python script to cmd.cgi from the same server without the interference of authentication. I have tried the settings of:
use_authentication=0
default_user_name=thrukadmin
but it doesn't seem to work in the thruk gui. When trying to post to the cgi from the thruk gui I get the error, "I'm sorry Dave......"
Any thoughts on why this not working right? The apache server on that system uses ldap to authenticate to the gui, could this be an issue?
Other thoughts?
It's much easier, you don't even need Thruk in the middle. You can simply write to Naemons command_file.
The external command list at https://www.naemon.org/documentation/developer/externalcommands/ contains an example for every possible command.
Here is a shell snippet which schedules a host downtime:
printf "[%lu] SCHEDULE_HOST_DOWNTIME;host1;1478648441;1478638441;1;0;3600;naemonadmin;This is an example comment.\n" `date +%s` > /var/lib/naemon/naemon.cmd
When using Thruk, you can use thruks cli script to send commands:
thruk r -d comment_data=test /hosts/localhost/cmd/schedule_host_downtime
Authentication is only required if you want to send commands by HTTP.

Debugging Parse Cloud-Code

What would be the best way to debug Parse Cloud Code? Currently it's a mess of logging to the console and checking logs. Does anyone have a good workable solution?
During development, you should begin by testing against a local hosted server. I.e., I use VS Code. You can set breakpoints and watch variables for their values. You can set up a tool like ngrok to get a remote URL for your local endpoint so you can test with non-local hosted clients if you'd like.
We also use Slack extensively. We've created our own slack bot, and it has several channels it reports relevant information too, triggered from our parse-server. One of these is a dev error channel. Instead of console.logs, which are hard to sift through and find what you're looking for, we push important information to Slack. We don't switch every single console.log to a slack message, just the important "Hey something went wrong here's the information" messages. This brings them to our attention so we can identify and resolve them way faster. Slack is awesome. I recommend using slack, even on a solo project.
at the moment you can access your Logs using a console.log() or console.error() for functions and all general logs of everything that happens with your app, at Back4App you can access using: Server Settings -> Logs -> Settings -> Server System Log.
Or functions and all logs generated by Parse server, they're: request.log.info() and request.log.error(), at Back4App you can access using: Dashboard -> Logs.

What is proper way for fixtures while using chimp with Meteor

I'm playing with chimp testing tool. At the moment I can easily run cucumber and mocha tests. The problem is that I don't know how to add DB fixtures. I'd like to have initial data before running some tests (e.g. add test user into system).
BTW that data can be added only by authenticated user and users can be create only by admin or from server level.
Can't find any docs about this for now. Any suggestions?
If you are using Meteor, you can pass the DDP parameter on the command line --DDP=http://localhost:3000 and then use server.execute to run code on the server. This code can then setup data.
If you are not using Meteor, you can use a HTTP call using request.get('http://localhost:8080/addUser').
Through HTTP / DDP you can access the server and create a testing backdoor to setup the data you need.

How to stop a build in Jenkins via the REST api ?

I have a job in Jenkins. A website of our own triggers builds of this job via the REST api. Sometimes we want to abort the build. Sometimes, it can be before the build is even started. In such cases we have the queueItem # instead of the build #.
How to do so via the REST api ?
If the build has started, by POST on:
http://<Jenkins_URL>/job/<Job_Name>/<Build_Number>/stop
Will stop/cancel the current build.
If the build has not started, you have the queueItem, then POST on:
http://<Jenkins_URL>/queue/cancelItem?id=<queueItem>
This is assuming your Jenkins Server has not been secured, otherwise you need to add BASIC authentication for a user with Cancel privileges.
Actually this question is already answered. So I will add, how to find id=<queueItem> , which I got stuck on finding this solution, which will helpful for others.
So, you can get <queueItem>, by - http://jenkins:8081/queue/api/json
Sample Output will be of json type like this one -
[{"_class":"hudson.model.Cause$RemoteCause","shortDescription":"Started by remote host 172.18.0.2","addr":"172.18.0.2","note":null}]}],"blocked":false,"buildable":false,"id":117,"inQueueSince":16767552,"params":"\nakey\t=AKIQ\nskey=1bP0RuNkr19vGze/bcb4ijDqVr8o\nnameofr=us\noutputtype=json\noid=284102\nadminname=admin","stuck":false,"task"
You have to take "id":117, and parse it to -
queueItem =117.
http://<Jenkins_URL>/queue/cancelItem?id=queueItem
Maybe you want to remotely send a post http request to stop a running build, there is a clue FYI, the jenkins job can stop another job(running build), like any jenkins admin click the X button when job is running.
Http Request Plugins is required by Jenkins ver2.17
Uncheck the Prevent Cross Site Request Forgery exploits option. Manager Jenkins -> Configure Global Security -> Uncheck
Setup Http Request Plugins's authorization. Manager Jenkins -> Configure System -> HTTP Request Basic/Digest Authentication -> add. Make sure the user has the job cancel permission
Job A is running. In job B, add build step as HTTP Request, URL: http://Jenkins_URL/job/Job_A_Name/lastBuild/stop, HTTP mode: POST, Authorization select the user you have just set, then build job B.
Done
If you only need to cancel the active build from a certain job you can use this batch script (windows .bat syntax):
REM #Echo off
CLS
REM CANCEL ACTIVE BUILD
REM PARAMETER 1 ACTIVE JOB NAME
if [%1] == [] GOTO NO_ARGUMENT
SET domain=https://my.jenkins.com/job/
SET path=/lastBuild/stop
SET url=%domain%%1%path%
"\Program Files\Git\mingw64\bin\curl.exe" -X POST %url% --user user:pass"
GOTO THEEND
:NO_ARGUMENT
Echo You need to pass the active jobname to cancel last build execution
:THEEND
Path to your local curl needs to set.

$_POST undefined from remote server POST

I am writing a Drupal 7 module which is listening for HTTP POST messages to be sent by a 3rd party remote application. For testing I am sending messages using the Firefox Poster extension.
If I POST the message, the following code fails to place any value in my local vars (I get 'undefined index'):
$transId = urldecode($_POST['c2s_transaction_id']);
However, if I send the message using GET, the vars get populated fine with the following code:
$transId = urldecode($_REQUEST['c2s_transaction_id']);
This is true on both my local WAMP setup and on a shared hosting package.
I have never worked with HTTP POST messages before and have no idea where the problem might be. Could it be Drupal, the web server, or my code? Can anyone suggest how I might resolve this?
Many thanks,
Polly
Drupal removes the $_POST/$_GET in the system, just use $_REQUEST instead.