How ansible callbacks are configured - ansible

I have scoured the ansible documentation as well as a few books, google and the source code, but for the life of me I cannot find the answer to this simple question:
How does one change the configuration items that affect the beahavior of ansible callbacks?
-E.g: the mail callback appears, looking at the code, to be able to be configured to send mail to a configurable email address through a configurable SMTP host. How/where/when should these be specified?
TIA
Edit:

Well, OK, if the mail callback (and the base class for callbacks) are anything to go by, there appears to be NO standard configuration mechanism for callbacks. Mail gets SMTPHOST from an environment variable if it's there, and to: appears to be nailed to root.

You can change the email address to your own in the mail.py file
if sender is None:
sender='<root>'
if to is None:
to='<root>'
You can change the root to your own email address, and the each host output will be sent as an email.
Also please make sure you have whitelist the plugins in ansible.cfg file.

First you need to set the callbacks plugins directory and then also whitelist it (I am assuming that you are using Ansible 2.0+) inside the ansible.cfg:
[defaults]
callback_plugins = ./plugins/callback_plugins
callback_whitelist = name_of_your_plugin_here
Hope this will help you.

Unfortunately, you really need to look at the code for now to get the full documentation. Looks like currently the only way to configure it is by setting the SMTPHOST environment variable. The slack plugin allows configuration via either environment variables or by adding settings to the [callback_slack] section of ansible.cfg

Related

look for assistance with the url rewrite module in IIS

I'm trying to set up a reverse proxy for single sign on to an application. the URL to reach my app and the defined authentication method is "http://servername.domain/app/main?authsource=sso_rp"
My current config just sends me to the application login prompt. I've tested my authentication source and confirmed its working. My question is, does my URL rewrite config look like it should? there are no conditions or variables defined. i know I'm missing something simple but this isn't documented on the vendor end so seeking your help.

What is the alternative for instance parameter in snow_record_find ansible module?

I have tested the Ansible snow_record_find module towards my own ServiceNow Developer Instance and it is working fine. However, when I want to implement it in my project Testing environment by using my own company ServiceNow, I got error mentioned "HTTPSConnectionPool(host='domainname.com**.ng.service-now.com**', port=443): Max retries exceeded with url: //ap".
From this link: (https://github.com/ansible/awx/issues/2515), I found out that it has something to do with the instance parameter as the host parameter highlighted by the error shows that the ".service-now.com" is appended to my company ServiceNow instance url.
Hence, I concluded that is why I got this error. But, when I try to find out other alternative parameter for the instance like 'host' or 'url', there isn't anything like that.
Or perhaps, there is other work around that I can do for this? The main objectice here is using this module to retrieve record from ServiceNow table by using Query as shown as in the Ansible snow_record_find documentation: (https://docs.ansible.com/ansible/latest/modules/snow_record_find_module.html)
Thanks in advance
Regrettably, it appears the snow_record_find module only supports instance, and (as you experienced) pysnow prioritizes instance over host
It appears based on some traffic on a similar PR that they are now suggesting that one use the new ansible collections functionality
If you're not on ansible 2.9, then "forking" the snow_record_find.py into the library folder of your playbook is the only recourse I know of through which you can add a host module arg and then pass that arg into pysnow.OAuthClient to behave like you wish

Play configurations for HTTPS only on Heroku

I searched around and have found topics close to this (for example here and here) but I still can't seem to get this working so here goes.
I'm using play 2.6 and deploying to Heroku. I'd like to force the app to only use HTTPS. As the aforementioned post indicates this filter (with the proper Heoku settings) seems like it should solve my problem. But I can't seems to get it working. Basically if I do the simple setup I suggest below it doesn't redirect to https and if I try anything fancy I get errors.
I guess what I'm asking is how does one setup the Procfile, application.conf and Environment variables for the deployment to Heroku. As an FYI I'm using / I'd like to be able to use play's self signed certificates for my non production deployments in case that's causing problems.
===== For the Procfile ====
Normally a simple Procfile might look like:
web: target/universal/stage/bin/my-app -Dhttp.port=${PORT}
But without heroku I'd want to do something like this (see here)
play -Dhttp.port=disabled -Dhttps.port=443
Since Heroku sets up the port/Https automagically how do I merge these two? ie is there a heroku env var like ${HTTPS_PORT} that I should be using?
===== For the application.conf ====
Presumably we want something like this
play.filters.enabled += play.filters.https.RedirectHttpsFilter
play.filters.https.redirectEnabled = true
"play.filters.https.redirectEnabled = true" shouldn't be needed but I put it there just in case. But do I also need to specify play.filters.https.port? (see here). Something like this:
play.filters.enabled += play.filters.https.RedirectHttpsFilter
play.filters.https.redirectEnabled = true
play.filters.https.port=???
Thanks in advance.
==== Edit ===
Thanks #codefinger the answers you gave is correct. I'm going to put the details below for future reference.
As mentioned here you need to tell play to check if the request has already been secured. In this case it essentially means white listing the proxy. So the Proc file can be as simple as:
web: target/universal/stage/bin/my-app -Dhttp.port=${PORT}
But you need to enable the RedirectHttpsFilter and configure the trusted proxies. Note here I've trusted all IPs but based on your app you can restrict that (details here).
play.filters.enabled += play.filters.https.RedirectHttpsFilter
play.http.forwarded.trustedProxies=["0.0.0.0/0", "::/0"]
I think you'll need to enable the play.core.server.common.ForwardedHeaderHandler, which will detect the X-Forwarded-Proto header that Heroku sets.
TLS termination is handled by the Heroku router, which means all request are in plain HTTP when they reach your app. The only way for your app to tell if they are HTTP(S) is which this header.

How to avoid duplicate default configuration for Firefox add-on?

I'm trying to implement some customization for a WebExtensions add-on, but I'm running into code duplication: both the options UI script and the content script need to know the default values for each setting, and AFAIK I can't expect either of them to be run before the other. Is there an elegant way to ensure that the local storage is initialized before either of them run?
Try this. If the storage is never set, the default-value-1 and default-value-2 will be used.
let settings = await browser.storage.local.get({
option1: "default-value-1",
option2: "default-value-2"
});
See more here: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage/StorageArea/get

How do I set the user agent for Ruby's RestClient?

I'm interested in setting my own user agent when using the ruby RestClient gem.
http://github.com/archiloque/rest-client
However, I can't find any documentation on how to do so. Any pointers?
RestClient.get 'http://localhost', :user_agent => "myagent"
See https://github.com/rest-client/rest-client/blob/master/lib/restclient.rb
Not sure the accepted answer is very clear. User agent is set just by a header of the request. And what I see in sources is that they set default user agent by setting :user_agent header to the request. It depends on the way you use the API how you set it. See #default_headers method in the linked source file.

Resources