community.general/lib/ansible/plugins/action
Toshio Kuratomi 52449cc01a AnsiballZ improvements
Now that we don't need to worry about python-2.4 and 2.5, we can make
some improvements to the way AnsiballZ handles modules.

* Change AnsiballZ wrapper to use import to invoke the module
  We need the module to think of itself as a script because it could be
  coded as:

      main()

  or as:

      if __name__ == '__main__':
          main()

  Or even as:

      if __name__ == '__main__':
          random_function_name()

  A script will invoke all of those.  Prior to this change, we invoked
  a second Python interpreter on the module so that it really was
  a script.  However, this means that we have to run python twice (once
  for the AnsiballZ wrapper and once for the module).  This change makes
  the module think that it is a script (because __name__ in the module ==
  '__main__') but it's actually being invoked by us importing the module
  code.

  There's three ways we've come up to do this.
  * The most elegant is to use zipimporter and tell the import mechanism
    that the module being loaded is __main__:
    * 5959f11c9d/lib/ansible/executor/module_common.py (L175)
    * zipimporter is nice because we do not have to extract the module from
      the zip file and save it to the disk when we do that.  The import
      machinery does it all for us.
    * The drawback is that modules do not have a __file__ which points
      to a real file when they do this.  Modules could be using __file__
      to for a variety of reasons, most of those probably have
      replacements (the most common one is to find a writable directory
      for temporary files.  AnsibleModule.tmpdir should be used instead)
      We can monkeypatch __file__ in fom AnsibleModule initialization
      but that's kind of gross.  There's no way I can see to do this
      from the wrapper.

  * Next, there's imp.load_module():
    * https://github.com/abadger/ansible/blob/340edf7489/lib/ansible/executor/module_common.py#L151
    * imp has the nice property of allowing us to set __name__ to
      __main__ without changing the name of the file itself
    * We also don't have to do anything special to set __file__ for
      backwards compatibility (although the reason for that is the
      drawback):
    * Its drawback is that it requires the file to exist on disk so we
      have to explicitly extract it from the zipfile and save it to
      a temporary file

  * The last choice is to use exec to execute the module:
    * https://github.com/abadger/ansible/blob/f47a4ccc76/lib/ansible/executor/module_common.py#L175
    * The code we would have to maintain for this looks pretty clean.
      In the wrapper we create a ModuleType, set __file__ on it, read
      the module's contents in from the zip file and then exec it.
    * Drawbacks: We still have to explicitly extract the file's contents
      from the zip archive instead of letting python's import mechanism
      handle it.
    * Exec also has hidden performance issues and breaks certain
      assumptions that modules could be making about their own code:
      http://lucumr.pocoo.org/2011/2/1/exec-in-python/

  Our plan is to use imp.load_module() for now, deprecate the use of
  __file__ in modules, and switch to zipimport once the deprecation
  period for __file__ is over (without monkeypatching a fake __file__ in
  via AnsibleModule).

* Rename the name of the AnsiBallZ wrapped module
  This makes it obvious that the wrapped module isn't the module file that
  we distribute.  It's part of trying to mitigate the fact that the module
  is now named __main)).py in tracebacks.

* Shield all wrapper symbols inside of a function
  With the new import code, all symbols in the wrapper become visible in
  the module.  To mitigate the chance of collisions, move most symbols
  into a toplevel function.  The only symbols left in the global namespace
  are now _ANSIBALLZ_WRAPPER and _ansiballz_main.

revised porting guide entry

Integrate code coverage collection into AnsiballZ.

ci_coverage
ci_complete
2018-07-26 20:07:25 -07:00
..
__init__.py AnsiballZ improvements 2018-07-26 20:07:25 -07:00
add_host.py add_host: check if name or hostname arg is provided 2018-02-12 15:24:45 -05:00
aireos.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
aireos_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
aruba.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
aruba_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
asa.py Let called functions use `method` keyword (#43086) 2018-07-22 15:26:44 -04:00
asa_config.py py2/py3 compat fix (#40614) 2018-05-24 15:13:22 -05:00
assemble.py Rename original_basename parameter in various file-related modules 2018-05-17 15:24:56 -07:00
assert.py Improve code style 2018-06-21 13:59:50 -04:00
aws_s3.py Fix async for aws_s3 - fixes #40281 (#40826) 2018-06-07 15:09:22 -04:00
bigip.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
bigiq.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
ce.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
ce_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
ce_template.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
cnos.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
cnos_config.py Lenovo typofix (#40865) 2018-05-30 15:23:26 +05:30
command.py Normalize usage of temp and tmp on tmp (#36221) 2018-02-15 09:01:02 -08:00
copy.py ensure copy action plugin returns an invocation in result (#41426) 2018-06-20 14:35:47 -04:00
debug.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
dellos6.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
dellos6_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
dellos9.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
dellos9_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
dellos10.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
dellos10_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
edgeos_config.py EdgeOS module improvements (#39530) 2018-05-22 12:22:18 -04:00
enos.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
enos_config.py Lenovo typofix (#40865) 2018-05-30 15:23:26 +05:30
eos.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
eos_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
fail.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
fetch.py fetch: set fail_on_missing: True as default as per docs (#36469) 2018-02-21 18:10:23 +10:00
fortios_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
group_by.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
include_vars.py Fix typo in ignore_unknown_extensions doc 2018-07-26 09:28:33 -04:00
ios.py Don't close persistent connection socket on command timeout (#43071) 2018-07-23 07:07:06 +05:30
ios_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
iosxr.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
iosxr_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
ironware.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
ironware_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
junos.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
junos_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_banner.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_base.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
net_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_get.py Idempotency for net_get and net_put modules (#42307) 2018-07-05 20:15:25 +05:30
net_interface.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_l2_interface.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_l3_interface.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_linkagg.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_lldp.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_lldp_interface.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_logging.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_ping.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_put.py ios_file: Don't leave leftover files behind (#42622) 2018-07-12 12:26:14 +05:30
net_static_route.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_system.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_user.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_vlan.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
net_vrf.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
netconf_config.py
normal.py Normalize usage of temp and tmp on tmp (#36221) 2018-02-15 09:01:02 -08:00
nxos.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
nxos_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
onyx_config.py issue:38321 fix onyx_config module failed while using python = 3.5 (#38343) 2018-04-11 08:01:54 -06:00
ops_config.py
package.py Normalize usage of temp and tmp on tmp (#36221) 2018-02-15 09:01:02 -08:00
patch.py Fix the script and patch plugins tempfile ownership 2018-02-19 13:07:58 -08:00
pause.py Fix NameError in pause module (#42038) 2018-07-11 11:49:32 -04:00
raw.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
script.py Added executable parameter to the script module (#36969) 2018-05-25 14:40:48 -05:00
service.py Normalize usage of temp and tmp on tmp (#36221) 2018-02-15 09:01:02 -08:00
set_fact.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
set_stats.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
shell.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
sros.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
sros_config.py First bit of fixing temporary to have one source of truth (#35747) 2018-02-07 15:11:36 -08:00
synchronize.py Use _remote_is_local=True for local connection in synchronize (#40833) 2018-05-30 13:28:11 -07:00
telnet.py adds a new feature to the telnet action plugin 2018-07-12 10:11:55 -04:00
template.py Allow specifying the output encoding in the template module (#42171) 2018-07-25 13:10:40 -07:00
unarchive.py Rename original_basename parameter in various file-related modules 2018-05-17 15:24:56 -07:00
uri.py Add src parameter for uri module that can be used in place of body. Supports binary files (#33689) 2018-05-31 11:43:00 -05:00
vyos.py Support setting persistent command timeout per task basis (#42847) 2018-07-20 10:04:53 +05:30
vyos_config.py Fix edgeos_config: {backup: yes} (#37619) 2018-03-21 12:48:09 -04:00
wait_for_connection.py changed winrm _reset to reset and make ssh reset show warning (#42651) 2018-07-11 20:22:01 -07:00
win_copy.py Rename original_basename parameter in various file-related modules 2018-05-17 15:24:56 -07:00
win_reboot.py changed winrm _reset to reset and make ssh reset show warning (#42651) 2018-07-11 20:22:01 -07:00
win_template.py
win_updates.py win_updates fix when win_updates is run with async (#41756) 2018-06-20 14:52:24 -07:00