1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/changelogs/fragments
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
..
42647-win_updates.yaml return wu result from inner job (#42647) 2018-07-11 18:01:42 -07:00
42669-add_ssl_zabbix_inventory.yaml Zabbix inventory improvement (#42669) 2018-07-14 09:10:16 -04:00
43024-nclu-empty-net-commands.yaml NCLU Module: Improve performance by not operating on empty lines (#43024) 2018-07-20 11:38:29 -04:00
add_file_lock_feature.yaml Simple file locking feature (#42024) 2018-07-10 14:13:27 -07:00
add_random_mac_filtter.yaml Add random_mac string filter (#39775) 2018-06-21 15:56:54 -05:00
admin-users-default-change.yaml Make admin_users only contain root and toor because admin is used for non-privileged accounts 2018-06-05 17:01:40 -07:00
ansiballz_one_interpreter.yml AnsiballZ improvements 2018-07-26 20:07:25 -07:00
ansiballz_streamline_imports.yaml Remove an unnecessary import from the ansiballz wrapper (#41747) 2018-06-21 12:04:55 +10:00
any_unparsed_is_failed.yaml Introduce inventory.any_unparsed_is_failed configuration setting (#41171) 2018-06-06 09:28:58 +05:30
avoid_cwd_vars.yml avoid loading vars on unspecified basedir (cwd) (#42067) 2018-06-29 16:45:38 -07:00
aws_core_is_boto3_error_code.yml Add AWS boto3 error code exception function is_boto3_error_code (#41202) 2018-06-12 12:15:16 -04:00
aws_s3_async_fix.yaml Fix async for aws_s3 - fixes #40281 (#40826) 2018-06-07 15:09:22 -04:00
aws_s3_decryption_fix.yaml aws_s3: don't decrypt file before uploading - fixes #39287 (#39634) 2018-06-06 16:16:16 -04:00
aws_s3_fix_custom_endpoints.yaml [aws] Remove walrus conditional in aws_s3 module when using custom s3_url (#36832) 2018-06-07 15:07:52 -04:00
basic_booleans_backward_compat.yaml Restore BOOLEANS import in basic.py (#42008) 2018-07-02 10:27:16 -04:00
batch_mode_elasticsearch_plugin.yaml Add the possiblity to force a plugin installation (#41688) 2018-06-27 12:36:51 -04:00
callback_plugin_merge.yml Merge various stdout callback plugins into 'default' (#41058) 2018-06-24 23:00:07 -05:00
clarify_error_message.yml better error messasge (#42770) 2018-07-19 12:13:09 -04:00
cleanup__file__.yaml Port modules away from __file__ 2018-07-09 15:51:20 -07:00
command_shell_check_mode.yaml Enable check_mode in command module (#40428) 2018-07-23 14:06:41 -07:00
connection_reset.yaml changed winrm _reset to reset and make ssh reset show warning (#42651) 2018-07-11 20:22:01 -07:00
console_color.yml Allow to specifically customize console's color 2018-07-24 13:21:58 -04:00
deprecated-__file__.yaml AnsiballZ improvements 2018-07-26 20:07:25 -07:00
docker-default-ssl.yml Fix ssl_version default value. (#42955) 2018-07-20 11:32:04 -04:00
elasticsearch_plugin-showSTDERRonFailure.yaml elasticsearch_plugin - Show STDERR on module failures. (#41954) 2018-06-29 17:28:17 -04:00
ensure_text_source.yaml ensure 'text' source assumptions (#42522) 2018-07-10 09:45:37 -04:00
file_attributes.yaml Remove extra line in file_attributes.yaml 2018-06-14 09:56:36 -07:00
file_touch_check_mode.yaml Fix file module with check_mode - Fixes #42111 (#42115) 2018-06-29 11:19:34 -07:00
file_touch_diff.yaml Fix file state=touch not returning diff information 2018-06-20 14:51:27 -07:00
fix-255-exit-code.yaml Separate some 255 exit codes that are not ssh errors 2018-07-09 15:51:20 -07:00
fix-open-url.yml Only assume GET if no data, otherwise POST (#43133) 2018-07-23 07:30:10 -07:00
from_yaml_all_filter_plugin.yaml Add from_yaml_all to support multi document yaml strings (#43037) 2018-07-25 16:12:22 -04:00
gce-sort-fix.yaml Add changelog for gce_net sort fix 2018-06-16 13:10:23 -07:00
inventory_dir_ext_compare_fix.yaml Make sure we are comparing bytes extensions in inventory plugins (#42475) 2018-07-09 12:24:51 -04:00
irc_py3_compat.yaml fix irc module to work with py3 (#42267) 2018-07-10 09:42:14 -04:00
lineinfile-empty-regexp.yml Add warning when using an empty regexp in lineinfile (#42013) 2018-06-29 17:15:43 -07:00
no_log_fix_for_connection_exceptions.yaml Add changelog entry for the no_log fix 2018-06-12 10:25:30 -07:00
passwordstore-lookup-backup.yaml Add backup option to passwordstore lookup (and improve doc) (#39676) 2018-06-08 10:33:53 -04:00
pause-stdout-redirection.yaml Fix pause module so it does not stack trace when redirecting stdout. (#42217) 2018-07-06 17:19:55 -04:00
pause-try-except-curses.yaml Fix NameError in pause module (#42038) 2018-07-11 11:49:32 -04:00
preserve_delegate_nolog.yml preserve delegation info on no_log (#42577) 2018-07-11 20:41:37 -04:00
puppet_debugging_options.yaml Add additional puppet options (#42218) 2018-07-06 13:52:17 -04:00
remote_tmp_de-escalated_user.yaml Fix remote_tmp when become with non admin user (#42396) 2018-07-06 10:49:19 -07:00
remove-unused-ansible-remote-temp.yaml ANSIBLE_REMOTE_TMP was an implementation of unified temp that was later changed 2018-07-25 16:57:46 -07:00
syslog_facility-for-journald.yml Add syslog_facility parameter handling with systemd.journal (#41078) 2018-06-07 12:23:13 -07:00
template_output_encoding.yml Allow specifying the output encoding in the template module (#42171) 2018-07-25 13:10:40 -07:00
user-freebsd-createhome-name-fix.yaml fix a (forgotten?) change in moving createhome -> create_home (#42711) 2018-07-16 16:55:57 -04:00
user_freebsd_always_changed_bugfix.yaml Only report change when home directory is different on FreeBSD (#42865) 2018-07-19 10:07:00 -04:00
v2.7.0-initial-commit.yaml Initial commit for 2.7.0 development. 2018-05-25 21:23:28 -07:00
win_become_async_older_hosts.yml runas + async - get working on older hosts (#41772) 2018-06-26 14:40:49 +10:00
win_chocoalatey_install_tls12.yml win_chocolatey: add TLSv1.2 support for install phase (#41992) 2018-07-13 13:38:24 +10:00
win_chocolatey-bugfixes.yaml win_chocolatey: refactor module to fix bugs and add new features (#43013) 2018-07-24 07:52:13 +10:00
win_chocolatey-return-rc-always.yml win_chocolatey: always return the rc return value (#41883) 2018-06-25 08:23:31 +10:00
win_domain-dns-typo-fix.yml win_domain: fix typo in cmdlet call (#41993) 2018-06-27 11:29:45 +10:00
win_iis_webapppool-output-fix.yml win_iis_webapppool: do not output some cmdlet outputs (#41884) 2018-06-26 11:19:09 +10:00
win_reboot-fixes.yml win_reboot: fix 2.6 issues and better handle post reboot reboot (#42330) 2018-07-11 09:12:29 +10:00
win_security_policy-empty-value.yaml win_security_policy: Allow setting a value to empty (#42051) 2018-07-13 14:08:14 +10:00
win_updates-async-fix.yml win_updates fix when win_updates is run with async (#41756) 2018-06-20 14:52:24 -07:00
win_user-validate-fixes.yaml win_user: use different method to validate credentials that does not rely on SMB/RPC (#43059) 2018-07-24 08:16:42 +10:00
winrm_kinit-remove-pass-log.yml Stop displaying kinit pass input on a failure (#41882) 2018-06-26 05:49:19 +10:00
wrcwd_ansible.cfg.yml fix changelog (#42272) 2018-07-03 14:31:19 -04:00