zuloogeta.blogg.se

Json query ansible
Json query ansible











json query ansible json query ansible

Using other modules in this manner allows us to avoid duplicating code and is very common in modules related to file operations. The above code is run after a temporary file is generated using the templating engine, which all occurs on the Ansible controller side. Original_basename=os.path.basename(source), # L175-184 on the devel branch at the time of writing For example, the 'template' action uses the 'copy' and 'file' modules to do the real work of copying the templated file to the remote system: # from plugins/action/template.py Modules are executed remotely by the '_execute_module()' method, which can also accept other parameters to allow you to run more than one module remotely to create some complex actions. New action plugins usually only need to subclass ActionBase and override the 'run()' method. Self._execute_module(tmp=tmp, task_vars=task_vars), # remove as modules might hide due to nolog Results = super(ActionModule, self).run(tmp, task_vars) # (comments and most blank lines have been removed for brevity)įrom _future_ import (absolute_import, division, print_function)įrom import ActionBaseįrom import merge_hash The following code is the entirety of the 'normal' action plugin. Tasks which use 'async' have a special action plugin, which is used to launch the task using the 'async_wrapper' module. If Ansible finds an action plugin with the same name as the module, that action plugin is used, otherwise the 'normal' action plugin is used. The template action plugin itself creates the template file locally as a temporary file, and then uses the copy or file modules to push it out to the target system. If you look at template.py in the modules directory, it’s basically a Python stub with documentation strings, everything is done by the action plugin. A good example of this is the template module. Anytime you run a module, Ansible first runs an action plugin.Īction plugins are a layer between the executor engine and the module and allow for controller-side actions to be taken before the module is executed. One of the core critical plugins used by Ansible are action plugins. In this blog, I’ll review each of these plugins and offer a high-level overview on how to write your own plugin to extend Ansible functionality. Essentially, Ansible uses plugins to extend what the system is doing under the hood. Did you know a large portion of Ansible’s functionality comes from the Ansible plugin system? These important pieces of code augment Ansible’s core functionality such as parsing and loading inventory and Playbooks, running Playbooks and reading the results.













Json query ansible