Commit Graph

788 Commits (f0eb8014484879e4c8de82bb5a6e7c1b52a3490c)

Author SHA1 Message Date
Alex Willmer f0eb801448 Merge branch 'master' into docs-master 4 years ago
Alex Willmer 25ea6dde02 ansible_mitogen: Allow mitogen_fetch to bypass slurp module
This reapplies an earlier change, when this plugin was first introduced to
Mitogen. The plugin was updated to fix

[DEPRECATION WARNING]: The '_remote_checksum()' method is deprecated.

I've elected to short-circuit the if statemtn logic, rather than
deleting/unindenting, to make the code delta much smaller. This should make it
easier to maintain/update.

Fixes #915
4 years ago
Alex Willmer e101cc4f44 mitogen.utils: Preserve docstring of functions decorated @with_router
Co-authored-by: Rezart Qelibari <gast-kontakt+mitogen@astzweig.de>

Replaces #837
Fixes #836
4 years ago
Alex Willmer 96e20a09d6 ansible_mitogen: Add podman connection plugin 4 years ago
Alex Willmer 0417d4d73a Replace os.system() with subprocess.check_call()
Non-zero return codes should raise an exception, not pass silently.
4 years ago
Alex Willmer 2a95d039ab Python 3.10 support 4 years ago
Alex Willmer d2ca8a9423 master.ParentEnumerationMethod: Require matching pkg.__name__
Co-authored-by: Stefano Rivera <stefano@rivera.za.net>

When the requested module (e.g. ansible.module_utils.distro)
- is provided by another module *e.g. distro)
- that itself was a package (e.g. distro 1.7.0)

At runtime
- ansible/module_utils/distro/__init__.py executes
- if https://pypi.org/project/distro/ is present, it's loaded as
ansible.module_utils.distro
- otherwise ansible/module_utils/distro/_distro.py is loaded

ParentEnumerationMethod would wrongly use whatever was in
sys.modules['ansible.module_utils.distro]. Instead we should ascend to
the first parent that has fullname == sys.modules[fullname].__name__.
Then descend to the appropriate .py file on disk.

This bug didn't show up before because until distro 1.7.0 (Feb 2022) the
top-level distro module was a module (distro.py) not a package
(distro/__init__.py)

fixes #906
4 years ago
Alex Willmer 5b8f7dd1be
Start v0.3.3 development 4 years ago
Alex Willmer e8c3fe7881
Fix Trove classifier, bump version
fixes #891

(cherry picked from commit 1a84184838)
4 years ago
Klaus Zerwes 54b9115f20
Update docs/ansible_detailed.rst
fixed supported ansible / python version listing

Co-authored-by: Alex Willmer <alex@moreati.org.uk>
4 years ago
Klaus Zerwes 56c341790c prepare support for ansible community 5 aka. core 2.12 4 years ago
Alex Willmer 552819e765 mitogen.parent: Detect and avoid Python2.7 wrapper on macOS 11 & 12
Without this errors such as the following occur
```
✗ MITOGEN_LOG_LEVEL=DEBUG python3 foo.py
Python: execv: (null): No such file or directory
Traceback (most recent call last):
  File "foo.py", line 16, in <module>
    target = router.local(python_path='/usr/bin/python2.7', debug=True)
  File "/Users/alex/src/mitogen2/mitogen/parent.py", line 2486, in local
    return self.connect(u'local', **kwargs)
  File "/Users/alex/src/mitogen2/mitogen/parent.py", line 2446, in connect
    return self._connect(klass, **mitogen.core.Kwargs(kwargs))
  File "/Users/alex/src/mitogen2/mitogen/parent.py", line 2426, in _connect
    conn.connect(context=context)
  File "/Users/alex/src/mitogen2/mitogen/parent.py", line 1708, in connect
    raise self.exception
mitogen.parent.EofError: EOF on stream; last 100 lines received:
MITO000
MITO001
```

Before
```
$ ./preamble_size.py
SSH command size: 625
Bootstrap (mitogen.core) size: 17007 (16.61KiB)

                              Original          Minimized           Compressed
mitogen.parent            97496 95.2KiB  50355 49.2KiB 51.6%  12663 12.4KiB 13.0%
mitogen.fork               8436  8.2KiB   4130  4.0KiB 49.0%   1648  1.6KiB 19.5%
mitogen.ssh               10892 10.6KiB   6952  6.8KiB 63.8%   2113  2.1KiB 19.4%
mitogen.sudo              12089 11.8KiB   5924  5.8KiB 49.0%   2249  2.2KiB 18.6%
mitogen.select            12325 12.0KiB   2929  2.9KiB 23.8%    964  0.9KiB 7.8%
mitogen.service           41644 40.7KiB  22431 21.9KiB 53.9%   5886  5.7KiB 14.1%
mitogen.fakessh           15599 15.2KiB   8011  7.8KiB 51.4%   2624  2.6KiB 16.8%
mitogen.master            48732 47.6KiB  24569 24.0KiB 50.4%   6768  6.6KiB 13.9%
```

After
```
$ ./preamble_size.py
SSH command size: 705
Bootstrap (mitogen.core) size: 17007 (16.61KiB)

                              Original          Minimized           Compressed
mitogen.parent            97885 95.6KiB  50516 49.3KiB 51.6%  12728 12.4KiB 13.0%
mitogen.fork               8436  8.2KiB   4130  4.0KiB 49.0%   1648  1.6KiB 19.5%
mitogen.ssh               10892 10.6KiB   6952  6.8KiB 63.8%   2113  2.1KiB 19.4%
mitogen.sudo              12089 11.8KiB   5924  5.8KiB 49.0%   2249  2.2KiB 18.6%
mitogen.select            12325 12.0KiB   2929  2.9KiB 23.8%    964  0.9KiB 7.8%
mitogen.service           41644 40.7KiB  22431 21.9KiB 53.9%   5886  5.7KiB 14.1%
mitogen.fakessh           15599 15.2KiB   8011  7.8KiB 51.4%   2624  2.6KiB 16.8%
mitogen.master            48733 47.6KiB  24570 24.0KiB 50.4%   6771  6.6KiB 13.9%
```
4 years ago
Alex Willmer 465ac8abff ansible: Fix AttributeError in kubectl connection 4 years ago
Alex Willmer e194a6367f ci: Fix version comparisons involving double digits
See https://gist.github.com/moreati/e7507c5b606b12ec0ddafcb7c8debbf1
4 years ago
Alex Willmer e6bc53ca3a mitogen.parent: Remove tabs from minimized first stage
Saves 4 bytes

Before
```
$ python preamble_size.py
SSH command size: 629
Bootstrap (mitogen.core) size: 17007 (16.61KiB)

                              Original          Minimized           Compressed
mitogen.parent            97497 95.2KiB  50356 49.2KiB 51.6%  12665 12.4KiB 13.0%
mitogen.fork               8436  8.2KiB   4130  4.0KiB 49.0%   1648  1.6KiB 19.5%
mitogen.ssh               10892 10.6KiB   6952  6.8KiB 63.8%   2113  2.1KiB 19.4%
mitogen.sudo              12089 11.8KiB   5924  5.8KiB 49.0%   2249  2.2KiB 18.6%
mitogen.select            12325 12.0KiB   2929  2.9KiB 23.8%    964  0.9KiB 7.8%
mitogen.service           41644 40.7KiB  22431 21.9KiB 53.9%   5886  5.7KiB 14.1%
mitogen.fakessh           15599 15.2KiB   8011  7.8KiB 51.4%   2624  2.6KiB 16.8%
mitogen.master            48732 47.6KiB  24569 24.0KiB 50.4%   6768  6.6KiB 13.9%
```

After
```
$ python preamble_size.py
SSH command size: 625
Bootstrap (mitogen.core) size: 17007 (16.61KiB)

                              Original          Minimized           Compressed
mitogen.parent            97496 95.2KiB  50355 49.2KiB 51.6%  12663 12.4KiB 13.0%
mitogen.fork               8436  8.2KiB   4130  4.0KiB 49.0%   1648  1.6KiB 19.5%
mitogen.ssh               10892 10.6KiB   6952  6.8KiB 63.8%   2113  2.1KiB 19.4%
mitogen.sudo              12089 11.8KiB   5924  5.8KiB 49.0%   2249  2.2KiB 18.6%
mitogen.select            12325 12.0KiB   2929  2.9KiB 23.8%    964  0.9KiB 7.8%
mitogen.service           41644 40.7KiB  22431 21.9KiB 53.9%   5886  5.7KiB 14.1%
mitogen.fakessh           15599 15.2KiB   8011  7.8KiB 51.4%   2624  2.6KiB 16.8%
mitogen.master            48732 47.6KiB  24569 24.0KiB 50.4%   6768  6.6KiB 13.9%
```
4 years ago
Alex Willmer dd6d73db37 mitogen.parent: Eliminate use of platform module in first stage
This reduces the size of the initial SSH command by 204 bytes, & may fix errors
running Mitogen on  macOS. AFAICT platform was used but not imported.

Before
```
$ python ./preamble_size.py
SSH command size: 833
Bootstrap (mitogen.core) size: 17007 (16.61KiB)

                              Original          Minimized           Compressed
mitogen.parent            97565 95.3KiB  50427 49.2KiB 51.7%  12689 12.4KiB 13.0%
mitogen.fork               8436  8.2KiB   4130  4.0KiB 49.0%   1648  1.6KiB 19.5%
mitogen.ssh               10892 10.6KiB   6952  6.8KiB 63.8%   2113  2.1KiB 19.4%
mitogen.sudo              12089 11.8KiB   5924  5.8KiB 49.0%   2249  2.2KiB 18.6%
mitogen.select            12325 12.0KiB   2929  2.9KiB 23.8%    964  0.9KiB 7.8%
mitogen.service           41644 40.7KiB  22431 21.9KiB 53.9%   5886  5.7KiB 14.1%
mitogen.fakessh           15599 15.2KiB   8011  7.8KiB 51.4%   2624  2.6KiB 16.8%
mitogen.master            48732 47.6KiB  24569 24.0KiB 50.4%   6768  6.6KiB 13.9%
```

After
```
$ python preamble_size.py
SSH command size: 629
Bootstrap (mitogen.core) size: 17007 (16.61KiB)

                              Original          Minimized           Compressed
mitogen.parent            97543 95.3KiB  50357 49.2KiB 51.6%  12665 12.4KiB 13.0%
mitogen.fork               8436  8.2KiB   4130  4.0KiB 49.0%   1648  1.6KiB 19.5%
mitogen.ssh               10892 10.6KiB   6952  6.8KiB 63.8%   2113  2.1KiB 19.4%
mitogen.sudo              12089 11.8KiB   5924  5.8KiB 49.0%   2249  2.2KiB 18.6%
mitogen.select            12325 12.0KiB   2929  2.9KiB 23.8%    964  0.9KiB 7.8%
mitogen.service           41644 40.7KiB  22431 21.9KiB 53.9%   5886  5.7KiB 14.1%
mitogen.fakessh           15599 15.2KiB   8011  7.8KiB 51.4%   2624  2.6KiB 16.8%
mitogen.master            48732 47.6KiB  24569 24.0KiB 50.4%   6768  6.6KiB 13.9%
```
4 years ago
Alex Willmer c61c063b4f Support for Ansible 3 & 4
fixes #834

Co-authored-by: Claude Becker (@upekkha)
Co-authored-by: Dolph Mathews (@dolph)
4 years ago
Denis Zalevskiy 84c567e265
Add podman connection support
Shameless copy of buildah connection with modifications of invocation to
fit podman CLI.

Signed-off-by: Denis Zalevskiy <dez@aiven.io>
4 years ago
Denis Zalevskiy 10caa4a104
Fix typo in buildah context creation docs
Signed-off-by: Denis Zalevskiy <dez@aiven.io>
4 years ago
Alex Willmer c5c65ab0d2 ci: Switch Continuous Integration to Tox
Also
 - Simplifies adding support for additional Ansible versions
 - Unifies Python package versioning in CI and local test environments
 - Matches Python versions tested, with those declared in setup.py
 - Expands targets covered by automated Ansible tests to
    - centos6, centos8
    - debian9, debian11
    - ubuntu1604, ubuntu2004
4 years ago
Alex Willmer e76eefb8be Fix miscellaneous spelling/formatting 4 years ago
Alex Willmer da3772cbff Increment version to 0.3.1.dev0 4 years ago
Alex Willmer a990eb3d77 CI: Remove obsolete reverse shell historically used to debug CI
This reverse shell was historically used to debug CI jobs interactively.
It is not used anymore, and may be causing jobs to hang, then timeout.
There is no reason to keep it, and removing it simplifies CI jobs.

Additionally it has been reported as flagged by security scanners, so
removing it makes Mitogen easier to package/adopt.

fixes #847
4 years ago
Philippe Kueck bdbc9fe827
changelog entry for #827 5 years ago
Steven Robertson 234dde5fc1 check Ansible version before loaders are loaded 5 years ago
Alex Willmer bce3bab3e8 Add the msvcrt moduleto the default module deny list
Commit https://github.com/python/cpython/commit/880d42a3b247 (first
released in Python 3.8a0) moved an import of msvcrt from an if <win32>
block, into a try/except block. So now the import is tried even on Linux
or MacOS.

https://docs.python.org/3/library/msvcrt.html is a Windows specific
builtin.
5 years ago
Alex Willmer 1e72ebaf8b tests: Update test coverage to Python 3.9
The Travis Linux distribution must be upgraded because the Trusty
(Ubuntu 14.04) image does not have Python 3.9. Xenial (Ubuntu 16.04) is
the earliest version that offers Python 3.9.

I have not chosen a later release, in order to aid restoration of Python
2.4 - 2.6 tests.
5 years ago
David Wilson fad6eb1b47 Bump copyright year and use generic author name (testing Travis) 5 years ago
David Wilson 8b2bb9e43f Merge remote-tracking branch 'origin/master' into docs-master
* origin/master: (277 commits)
  Fix DjangoMixin test imports for setuptools >= 50.0
  Add ansible.legacy.setup to be fixed on py3.5
  code cleanup + adds 0.2.10 + 0.3.0 changelog
  adding clarifying comments
  fix py3.5.1-3.5.3 setup import error for Ansible 2.10
  tests: Fix AttributeError in callback plugins used by test suite
  code review changes, using when statements and adding trailing comma
  ssh: Match newer ssh host key prompt that accepts the fingerprint
  🎉 no more warnings, only load specific collection subdirs instead of top-level collection path (ie no ansible_collections/google, only ansible_collections/google/cloud, etc)
  ansible 2.10 no longer has a  at the end of the error msg... 🤦
  skip vanilla Ansible 2.10 hanging task if not is_mitogen
  vanilla ansible is now running but is really slow; bump timeout
  try vanilla ansible 2.10 on Mac
  travis is having trouble running vanilla Ansible so migrating to Azure
  disable debops since it breaks with ansible 2.10
  install all required debops extras for ansible
  netaddr needs to be on the Ansible controller, not in target nodes
  forgot to update apt cache
  turn off host key checking with ad-hoc python-netaddr install and add back in debops command line
  don't need to ci_lib run setting up python-netaddr
  need to specify strategy plugin for ansible ad-hoc
  need python-netaddr in docker target containers for debops
  adding hopefully new-style import that works for Ansible 2.10
  make sure to apt-get update first before install
  apt needs sudo
  disable python <= 2.6 tests
  install missing python-netaddr for debops
  revert missing interpreter change, it breaks with Mitogen and without Mitogen, something else might be causing new-style detection to not work
  oops, broke new-style missing interpreter detection. Regex should match now
  fix custom_python_new_style_missing_interpreter, looks like Ansible 2.10 changed how new-style module detection works
  add workaround for TravisCI 4MB log limit job termination
  fix regression in Darwin 19 (OSX 10.15+) ansible python interpreter detection
  something broke with Mac 10.14 with dscl, before trying a hack see if OS upgrade works
  don't run sshpass install through run
  azure tests don't like sshpass v1.06 so pegging to 1.05
  fix Error: Calling Non-checksummed download of sshpass formula file from an arbitrary URL is disabled
  result length is 3 in Azure, 4 on local Mac
  fixed ansible_become_pass test, looks like regression on Ansible's end
  localhost_ansible tests now pass, adding -vvv to ansible_tests to get more debug info there
  fixed issue of switching between mitogen and non-mitogen strategies
  fix yml parsing
  oops, yml file can't be empty
  ignore another flaky test that works locally
  fix ansible version check error
  fix runner_one_job ansible version comparison
  oops, 0664 not 0666
  fix fixup_perms2() test
  default copy perms look like 0644 now based on ansible source and docs
  missed a format call var
  remove ansible from github tag install setup in test config files
  add support for ansible_collections site-package (from pip ansible==2.10.0 install) + switch to ansible 2.10.0 rather than github tag
  remove debugging
  remove synchronize fail test for azure
  ignore synchronize for now, made ticket
  try and get some visibility into test failures
  fix venv install
  see if sys.path is being loaded properly on azure
  print didn't work because verbosity, throw valueerror to see
  more debugging, synchronize is being weird on azure
  python3 needs python3-venv
  tests are in a bad state...somehow both apt and brew can exist on azure using a linux job with an ubuntu vm image???
  need to group all python install commands together
  python3 tests are broken...
  cffi super old, try and update it
  try a different psycopg2 package as well
  need to install psycopg2-binary in the created venv
  fix 'struct _is' error hopefully
  brew is missing postgresql
  awesome, /usr/local/bin/python2.7 already exists
  missed a format
  wrong letter 🤦 what am I doing
  missed a )
  missed a ,
  clean up azure python version used
  print what's being ran in tests
  try running ansible_mitogen 2.10 tests with python3
  check sys.path issue
  add back in ansible tests but don't run synchronize
  turn off failing Ansible-only tests for now, also raising errors to see what Azure is gonna do with collections
  removed duplicate install and added debug dump of collection loading to see what tests are doing
  ansible.posix.synchronize isn't being loaded in tests but is locally, reducing v count to get around azure devops scroll bug
  hopefully this also fails the same way
  any amount of v is too much v, even when viewing tests in raw log file mode
  add missing collections 🤦
  verify collection is working as expected
  can't replicate but think it's because synchronize is now a collection
  2 v freezes things...this is impossible to debug
  figure out what synchronize is now
  put future import in wrong place
  3 v is too much v for azure devops to render
  add some debugging info, was able to run the failed synchronize test locally just fine using test framework, not sure what's going on
  test cleanup and trying to replicate synchronize fails
  warnings silenced, see if can put back in vvv
  try and suppress mode warning clogging up logs
  logs too verbose, unable to load test page
  run tests with verbose logging
  perhaps a modern debops version will work
  travis pip is 9 from what the logs say
  remove ansible 2.4-specific test
  fix fixup_perms2 default file mode
  ...
5 years ago
Steven Robertson f489478127 code cleanup + adds 0.2.10 + 0.3.0 changelog 5 years ago
Steven Robertson 8d3da2dbd2
Merge branch 'master' into patch-1 5 years ago
Alex Willmer 79b4c0f815 tests: Fix AttributeError in callback plugins used by test suite
CALLBACK_VERSION et al are documented as required in
https://docs.ansible.com/ansible/2.10/dev_guide/developing_plugins.html#callback-plugins.
The need for document_fragment is noted in
cfa8075537/lib/ansible/plugins/callback/default.py (L28-L32)

Fixes #758

This addresses the following error, seen while running
`ansible_tests.py`.

```
TASK [Gathering Facts gather_timeout=10, gather_subset=['all']]
****************
task path:
/home/alex/src/mitogen/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml:4
[WARNING]: Failure using method (v2_runner_on_start) in callback plugin
(<ansible.plugins.callback.nice_stdout.CallbackModule object at
0x7f76b3dad090>): 'show_per_host_start'
Callback Exception:
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py",
line 372, in send_callback
    method(*new_args, **kwargs)
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/default.py",
line 240, in v2_runner_on_start
    if self.get_option('show_per_host_start'):
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py",
line 91, in get_option
    return self._plugin_options[k]
Callback Exception:
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py",
line 372, in send_callback
    method(*new_args, **kwargs)
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/default.py",
line 240, in v2_runner_on_start
    if self.get_option('show_per_host_start'):
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py",
line 91, in get_option
    return self._plugin_options[k]
[task 339882] 00:00:08.172036 D ansible_mitogen.affinity: CPU mask for
WorkerProcess: 0x000004
Callback Exception:
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py",
line 372, in send_callback
    method(*new_args, **kwargs)
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/default.py",
line 240, in v2_runner_on_start
    if self.get_option('show_per_host_start'):
File
"/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py",
line 91, in get_option
    return self._plugin_options[k]
```
5 years ago
Alex Willmer b0ce29dcfd ssh: Match newer ssh host key prompt that accepts the fingerprint
This fixes an ERROR in test_accept_enforce_host_keys() while running the
test suite.

Fixes #756
5 years ago
Steven Robertson 7d4a57d16a
Merge branch 'master' into patch-1 5 years ago
Nicolas Mattia 4d48f140a8 Fix typo in Ansible documentation 6 years ago
Luiz Ribeiro 0e47280e43
Fix mitogen_ssh_keepalive_interval documentation 6 years ago
Scott Buchanan fa7c0191ee
correct latest ansible version supported 6 years ago
Steven Robertson 2d7e019dd2
Update docs/ansible_detailed.rst
Co-Authored-By: Jacob Floyd <cognifloyd@gmail.com>
6 years ago
Steven Robertson 1dddfadf32 removing note saying ansible 2.8 interpreter discovery doesn't work 6 years ago
David Wilson a98017d478 Merge commit 'refs/pull/origin/653' into docs-master
* commit 'refs/pull/origin/653':
  docs: fixes minor typo (pefectly -> perfectly)
  docs: fix link
  docs: update Changelog note with correct time and add footnote
  docs: insert 'representative'
  docs: add bug links to Changelog.
  docs: another Changelog typo.
  docs: fix broken changelog link
  docs: changelog typos
  docs: changelog typos
6 years ago
Steven Robertson e8f3154cab Merge branch 'master' into complexAnsiblePythonInterpreterArg 6 years ago
David Wilson c44cba030e issue #660: update Changelog. 6 years ago
David Wilson d6329f3446 Merge devel/290 @ 79b979ec8544ef5d8620c64068d4a42fabf50415 6 years ago
Steven Robertson bca9d9bf67 added info to ansible_detailed.rst explaining new ansible_python_interpreter functionality 6 years ago
Percy Grunwald 6ea2cef5c5 docs: fixes minor typo (pefectly -> perfectly) 6 years ago
David Wilson 03b051ff11 docs: fix link 7 years ago
David Wilson 146bcd38fb docs: update Changelog note with correct time and add footnote
Looking at textedit window before closing, I notice the Mitogen time was
taken from /usr/bin/time while the Ansible time was taken from the
profile callback plugin.
7 years ago
David Wilson a285488f65 docs: insert 'representative' 7 years ago
David Wilson b02fedc83f docs: add bug links to Changelog. 7 years ago
David Wilson f95aadc3c5 docs: another Changelog typo. 7 years ago