ansible : pushing results to a database with a webhook - ansible

I want to put my ansible results into a database.
I made a simple php webpage that listen for post data : server name, number of updates to install, etc and write it into a mysql database for later use (with grafana)
---> How can I make my ansible-playbook make a http post from the ansible server to save results?
I have seen uri but looks to work from the client. Maybe callback plugin but did not seen a simple http plugin.
an idea??
Thanks

You should try ansible-cmdb for this. It has options to store Ansible's output in the form of HTML, CSV, SQL, etc.
Option --template sql is available which is helpful in exporting to MySQL Database.

Related

Datadog data validation between on-prem and cloud database

Very new to Datadog and need some help. I have crafted 2 SQL queries (one for on-prem database and one for cloud database) and I would like to run those queries through Datadog and be able display the query results and validate that the daily results fall within an expected variance between the two systems.
I have already set up Datadog on the cloud environment and believe I should use DogStatsD to create a custom metric but I am pretty lost with how I can incorporate my necessary SQL queries in the code to create the metric for eventual display on a dashboard. Any help will be greatly appreciated!!!
You probably want to be using the MySQL integration, and configure the 'custom queries' option: https://docs.datadoghq.com/integrations/faq/how-to-collect-metrics-from-custom-mysql-queries
You can follow those instructions after you configure the base integration https://docs.datadoghq.com/integrations/mysql/#pagetitle (This will give you a lot of use metrics in addition to the custom queries you want to run)
As you mentioned, DogStatsD is a library you can import to whatever script or application in order to submit metrics. But it really isn't a common practice in the slightest to modify the underlying code of your database. So instead it makes more sense to externally run a query on the database, take those results, and send them to datadog. You could totally write a python script or something to do this. However the Datadog agent already has this capability built in, so it's probably easier to just use that.
I am also just assuming SQL refers to MySQL, there are other integration for things like SQL Server, and PostgreSQL, and pretty much every implementation of sql. And the same pattern applies where you would configure the integration, and then add an extra line to the config file where you have the check run your queries.

How do I use ansibel-playbook to connect to mysql to execute SQL statements

I want to connect to mysql through ansible-playbook and execute SQL statements, but there is no relevant module in the official website of ansible. Does anyone know how to operate
When there does not exist an official module to do something, you basically have two choices:
Find a custom module that someone has written that will do it (such as this one).
Write a custom module that will do it.
Do it using the command module or any of the other arbitrary command modules.
In your case, for a one-off playbook, I would typically go with the third option as I don't much care for running custom modules. I would make sure (Via Ansible of course) that mysql was installed on the box you were running against, and build a mysql command line string based on what you need to do which you then run on a host with access to the DB server (or the DB server itself). That's the quickest and dirtiest method.

How can download oracle apex report as PDF?

I have created a Interactive Report page on oracle apex 5.1.4 on my local environment [ windows 10]. I have retrieved data on that page using custom SQL query from different tables. Now I want to download report as PDF using Download option [ Image-1 ]. PDF file is downloading fine but PDF file is not opening. [ Image-2 ]
Note that, In the Instance Settings- Print Server is selected as External Apache (FOP).
I did not get any resources on this topic, Any solution?
If the setting is set to external print server, do you have a print server configured? has that print server been verified to work correctly?
If these are not true, then have you configured apex to use ORDS? If yes then you should be able to set the print server settings to ORDS. You do not get a ton of configuration options out of the box, but you do get a PDF.
Have a look at Dimitri Gielis' blog, Export your APEX Interactive Report to PDF. It seems that your case is described in his case #2:
... you will need to configure a print server like BI Publisher or
Apache-FOP.
How to configure it? No idea, it's beyond my knowledge.

ParseConfig vs ParseQuery - Which is faster/better?

So i'm essentially using a column in my parse server db as a configuration for my app. I now realize parse has a config feature specifically for this.
My question is which is faster/better to use and why? Hitting a query every single time i want to check, or check the parse config. Isn't checking the config variable just another query?
If anyone can provide proper/better/ or any documentation...
ParseConfig is faster because it store the config in the cache while ParseQuery will retrieve it from the DB. But you cannot use ParseConfig for every query operation but only to get things that are relevant to all of your users like: "Message of the day" and more.
Another very cool thing about ParseConfig is that if you don't have network connectivity it will fallback automatically to the client cache.

Mule Connect to remote flat files

I am new to Mule and I have been struggling with a simple issue for a while now. I am trying to connect to flat files (.MDB, .DBF) located on a remote desktop through my Mule application using the generic database connector of Mule. I have tried different things here:
I am using StelsDBF and StelsMDB drivers for the JDBC connectivity. I tried connecting directly using jdbc URL - jdbc:jstels:mdb:host/path
I have also tried to access through FTP by using FileZilla server on remote desktop and using jdbc URL in my app - jdbc:jstels:dbf:ftp://user:password#host:21/path
None of these seem to be working as I am always getting Connection exceptions. If anyone has tried this before, what is the best way to go about it? Connecting a remote flat file with Mule? Your response on this will be greatly appreciated!
If you want to load the contents of the file inside a Mule flow you should use the file or FTP connector, i don't know for sure about your JDBC option.
With the File connector you can access local files (files on the server where mule is running), you could try to mount the folders as a share.
Or run an FTP server like you already tried, that should work.
There is probably an error in your syntax / connection.
Please paste the complete XML of your Mule flow so we can see what you are trying to do.
Your usecase is still not really clear to me, are you really planning to use http to trigger the DB everytime? Anyway did you try putting the file on a local path and use that path in your database url. Here is someone that says he had it working, he created a separate bean.
http://forums.mulesoft.com/questions/6422/setting_property_dynamically_on_jdbcdatasource.html
I think a local path is maybe possible and it's better to test that first.
Also take note of how to refer to a file path, look at the examples for the file connector: https://docs.mulesoft.com/mule-user-guide/v/3.7/file-transport-reference#namespace-and-syntax
If you manage to get it working and you can use the path directly in the JDBC url, you should have a look at the poll scope.
https://docs.mulesoft.com/mule-user-guide/v/3.7/poll-reference
You can use your DB connector as an inbound endpoint when wrapped in a poll scope.
I experienced the same issue when connect to Microsoft Access Database (*.mdb, *.accdb) using Mule Database Connector. After further investigation, it's solved by installing Microsoft Access Database Engine
Another issue, I couldn't pass parameter to construct a query as same as I do for other databases. e.g.: SELECT * FROM emplcopy WHERE id = #[payload.id]
To solve this issue:
I changed the Query type from Parameterized into Dynamic.
I generated the query inside Set Payload transformer (generate the query in form of String, e.g.: SELECT * FROM emplcopy WHERE id = '1').
Finally, put it into the Dynamic query area: #[payload]

Resources