I have a custom Ansible module written that will query my cmdb for host details. Next I need to call the builtin add_host module to iterate over those results and update the Ansible inventory.
Could someone please show a simple example of how to call the builtin module add_host from a custom Ansible module? I have looked around online and can't find any documents that describe specifically this.
When I look at the builin add_host stuff, it appears the module is just being used for the DOC section and as a pointer to the plugin. Looking at the plugin, I'm not sure how I could import/call that remotely.
These are the two files I have on my machine for add_host :
/opt/pyats/lib/python3.7/site-packages/ansible/modules/inventory/add_host.py
/opt/pyats/lib/python3.7/site-packages/ansible/plugins/action/add_host.py
Thank you!
add_host is implemented as an action plugin. Ansible engine will check if an action plugin exists with the same name as a task (add_host) if yes it will invoke that action plugin if not it will try to search for module file name corresponding to the task name.
This is generally done for modules that execute on the control node itself.
Here’s an example of calling one module from another https://github.com/ansible-collections/community.yang/blob/main/plugins/action/get.py#L123. In this case the community.yang.get module (action plugin) internally invokes ansible.netcommon.netconf_get module
Related
I need to enable few callback plugins in my Ansible Tower. For example consider
stdout_callback = yaml
bin_ansible_callbacks = True
these plugins I can directly add to my ansible.cfg file when I use Ansible Engine, but I'm not able to find any solution, where to add these to reflect in Ansible Tower.
You may have a look into the documentation Using callback plugins with Tower. Please take note that
Ansible Tower does not support the stdout callback plugin because Ansible only allows one, and it is already being used by Ansible Tower for streaming event data.
Our code building process is done via an http server which starts the build process after receiving a project uuid from the build command. Once the server starts the compilation, GCC compatible output can be fetched from it.
Note: only my extension is aware of the project uuid which is different per workspace.
AFAIU I can implement it by:
programmatically adding a task which will call a script with the correct workspace uuid. Is this possible?
Having my extension manage the build process. This seems to be far from supported.
Bottom line, I'm trying to avoid asking the user to add anything to the configuration files and I want to completely manage the build process.
Thanks!
As I didn't find a suitable only vscode solution I did the following:
Defined a helper script which I executed as the task. The helper script was respojnsible for the communication against the HTTP server.
I registered the task using vscode.workspace.registerTaskProvider API, and made sure to register it only after figuring out the UUID.
Then in the task itself I executed the helper script.
(A nice task register example can be found here: https://github.com/Microsoft/vscode-extension-samples/tree/master/task-provider-sample)
I couldn't find any information related with running custom system command on this site: cakebuild.net/dsl
How can I do it?
The real command I want to run is 'upx mproject.exe'
If I have understood you correctly, then what you are looking for is the Process Aliases that exist within Cake:
http://cakebuild.net/dsl/process/
These allow you to start any arbitrary process from within your Cake script.
Another option, would be to create a Cake Addin that wraps the tool that you are trying to execute.
I want to upload a module to a Spring XD installation using the REST interface it provides. If the module is brand new, it works as expected. If the module was previously registered, though, the command will fail (again, as expected).
I understand it would be conceptually simple to delete the module and upload it again. The problem with that is that the module is configured by means of a .properties file, under the XD_MODULE_CONFIG_LOCATION hierarchy. Actually, the presence of this file is hindering my ability to delete the module, even if using the xd-shell!
The xd-shell command provides a '--force' option to 'module upload', that solves the problem. Is there any equivalence when using the POST method to register the module?
Thanks in advance.
I just looked at the REST controller for module upload and it looks like adding ?force=true to the URI will do it.
Yes; that's what the shell does:
String uriTemplate = resources.get("modules").toString() + "/{type}/{name}?force={force}";
I'd like to check if some service is running on the local computer before installation of my product. How can I check it?
This can be done through a custom action. With custom code you can find any information you want about a service. That information can then be saved in installer properties which can be used during install.
Since you need access to installer properties, you will have to use a win32 DLL or VBScript custom action. You can find a C++ DLL custom action tutorial here:
http://www.codeproject.com/KB/install/msicustomaction.aspx
Since you're using WiX, you can use CloseApplication in WixUtilExtension to do this. Set #RebootPrompt="no" since you want it to be running and not shut down. Set #Property to a property you then use in a condition to show your warning.