Commit Graph

188 Commits

Author SHA1 Message Date
David Wilson 8bd34e1e28 ansible: gracefully report connection timeouts as StreamError. 2018-05-03 00:06:51 +01:00
David Wilson 4d1c6d2101 issue #127: ssh: reasonable solution to host key checking.
Ideally it would be possible to specify a callback function, but this is
not possible for proxied connections. So simply provide the 3 most
useful modes, defaulting to the most secure.

Closes #127. Closes #134.
2018-05-02 17:47:06 +01:00
David Wilson 9cc8b21a07 ansible: missing mitogen_su module. 2018-05-02 16:41:35 +01:00
David Wilson 78c401ba4d ansible: support su become method. 2018-05-02 03:49:44 +01:00
David Wilson 3203846708 issue #239: ansible: ignore remote_tmp in new style runner. 2018-05-01 14:06:09 +01:00
David Wilson 94e048a2e5 ansible: ensure FileService uses exact CHUNK_SIZE multiple
9.8% throughput increase with sudo.
2018-05-01 01:57:17 +01:00
David Wilson dafe12b315 ansible: fix AnsibleUnicode crash when processing "~username". 2018-04-30 15:21:26 +01:00
David Wilson e1a3cea2f9 ansible: FileService: don't send empty last chunk 2018-04-30 01:24:59 +01:00
David Wilson 2a56c672ca ansible: FileService docstring updates. 2018-04-29 21:38:43 +01:00
David Wilson f5d22a3ca1 core: support deleting handlers, make Receiver.close() unregister 2018-04-29 19:41:23 +01:00
David Wilson 69e5902e61 issue #212: support explicit acknowledgements in FileService. 2018-04-29 19:30:57 +01:00
David Wilson b0309b539c ansible: disable interpreter recycling for connections.
Must explicitly specify enable_lru=True in ContextService.get() to
trigger recycling.
2018-04-29 09:53:16 +01:00
David Wilson 65e6a44fe7 docs: add links. 2018-04-29 02:31:32 +01:00
David Wilson 90f7b4baea ansible: stub plugin documentation. 2018-04-29 02:18:26 +01:00
David Wilson c85a5b6446 ansible: make call timing more readable 2018-04-29 02:17:10 +01:00
David Wilson bba2a42e44 ansible: add mitogen_sudo method, split out connection subclasses.
Slowly moving towards real implementations in those files.
2018-04-29 01:45:52 +01:00
David Wilson 0a9126c510 ansible: connection plugins missing from previous commit. 2018-04-29 01:22:01 +01:00
David Wilson 7c5bbc5168 setns: support changing user.
To match existing third party plugin.
2018-04-29 00:38:53 +01:00
David Wilson 003f30b5a9 issue #226: test fixes. 2018-04-28 22:10:41 +01:00
David Wilson 6edb3f165d ansible: avoid a race during shutdown. 2018-04-28 22:08:35 +01:00
David Wilson 780b63520f issue #226: don't attempt to fchmod() a pathname 2018-04-28 21:56:23 +01:00
David Wilson 219a202a82 issue #226: ansible: file transfer improvements
* put_data() supports setting mode and times.
* put_file() refuses to copy non-regular files (sockets, FIFOs).
* put_file() saves one RTT for <32KiB files by using put_data() and
  embedding file content in argument list.
* FileService returns dict with size/mode/owner/group/mtime/atime.
* FileService refuses to copy non-regular files.
* transfer_file() preserves file mode.
* transfer_file() preserves atime/mtime.
* transfer_file() optionally preserves ownership.
* transfer_file() optionally calls fsync().
* transfer_file() uses unique temporary file name to avoid conflicting
  with parallel transfers.
* transfer_file() ensures temporary file is deleted on any error.
* write_path() writes to a temporary file and deletes it on failure.
* write_path() uses unique temporary file name to avoid conflicting
  with parallel transfers.
* write_path() supports setting symbolic owner/group.
* write_path() optionally calls fsync().
* write_path() supports setting symbolic mode/mtime/atime.

Closes #226, #227, #229
2018-04-28 21:33:43 +01:00
David Wilson b5be0fd65b ansible: log _get_file() timings. 2018-04-27 10:58:33 +01:00
David Wilson 95039eea11 ansible: make key_from_kwargs() 10x faster
It was half the cost of the service call
2018-04-27 10:44:06 +01:00
David Wilson 098995539d ansible: implement FreeBSD jail support. 2018-04-27 06:21:10 +01:00
David Wilson b1563cd8c1 ansible: hijack lxd connections too. 2018-04-27 04:45:40 +01:00
David Wilson 131bc768c7 ansible: implement LXC support. 2018-04-27 04:40:56 +01:00
David Wilson 6fb3a76e68 master: annotate LogForwarder messages.
mitogen/master.py:
    Annotate forwarded log entries with their original source, logger
    name, and message.

ansible:
    mark stderr in red with -vvv

    Tempting to make this appaer 100% of the time, but some crappy
    bashrcs may cause lots of junk to be printed.
2018-04-27 03:11:06 +01:00
David Wilson 4893889a88 ansible: remove vestiges of old/wrong sudo_exe source. 2018-04-27 01:42:20 +01:00
David Wilson 3fab8a3af5 ansible: connection delegation v1
This implements the first edition of Connection Delegation, where
delegating connection establishment is initially single-threaded.

ansible_mitogen/strategy.py:
ansible_mitogen/plugins/connection/*:

  Begin splitting connection.Connection into subclasses, exposing them
  directly as "mitogen_ssh", "mitogen_local", etc. connection types.

  This is far from removing strategy.py, but it's a tiny start.

ansible_mitogen/connection.py:

  * config_from_play_context() and config_from_host_vars() build up a
    huge dictionary containing either more or less PlayContext contents,
    or our best attempt at reconstructing a host's connection config
    from its hostvars, where that config is not the current
    WorkerProcess target.

    They both produce the same format with the same keys, allowing
    remaining code to have a single input format.

    These dicts contain fields named after how Ansible refers to them,
    e.g. "sudo_exe".

  * _config_from_via() parses a basic connection specification like
    "username@inventory_name" into one of the aforementioned dicts.

  * _stack_from_config() produces a list of dicts describing the order
    in which (Mitogen) connections should be established, such that each
    element is proxied via= the previous element. The dicts produced by
    this function use Mitogen keyword arguments, the former di.

    These dicts contain fields named after how Mitogen refers to them,
    e.g. "sudo_path".

  * Pass the stack to ContextService, which is responsible for actual
    setup of the full chain.

ansible_mitogen/services.py:

  Teach get() to walk the supplied stack, establishing each connection
  in turn, creating refounts for it before continuing.

  TODO: refcounting is broken in a variety of cases.
2018-04-27 01:23:23 +01:00
David Wilson 7c6ce726aa ansible: rename variable to reflect correct time unit 2018-04-22 15:14:47 +01:00
David Wilson 2f1df7f82d ansible: FileService wasn't sleeping properly.
"_schedule_pending" is a function, "_pending_by_stream" is the map we
want to test.
2018-04-22 14:27:41 +01:00
David Wilson 86c9978e09 Ensure mod.__file__ is set; closes #210. 2018-04-22 13:29:50 +01:00
David Wilson b2abe74ab6 issue #210: run DebOps under v2.5.1 too. 2018-04-22 13:21:58 +01:00
David Wilson 89fc842ca8 ansible: typo. 2018-04-22 04:41:25 +01:00
David Wilson 21082cec40 ansible: fix ugly formatting. 2018-04-22 04:04:58 +01:00
David Wilson 376fc85000 ansible: FileService docstrings. 2018-04-22 03:58:29 +01:00
David Wilson cf30e88a3e ansible: implement missing FileService.on_shutdown() 2018-04-22 03:35:35 +01:00
David Wilson 5913be64d7 docs: remove last remaining major risk :D 2018-04-22 02:50:04 +01:00
David Wilson cb73c44084 ansible: implement streaming in Connection.put_file().
This is the function the copy module uses.
2018-04-22 02:48:06 +01:00
David Wilson 29087018c7 ansible: implement streaming in FileService.
This commit only uses it for the target.get_file() helper, which is only
used for transferring modules. The next commit wires it into the
Connection.transfer_file() API, which is the method the copy module
uses.
2018-04-22 02:41:48 +01:00
David Wilson 8c3b1fcf15 ansible: disable script interpreter processing for new-style
Re: #199
2018-04-21 20:59:36 +01:00
David Wilson 2f02b5c0b1 ansible: prevent Unicode strings leaking into sys.argv
The module name comes from YAML via Jinja2.. it's always Unicode. Mixing
it into a temporary directory name produces a Unicode tempdir name,
which ends up in sys.argv via TemporaryArgv.
2018-04-21 20:26:53 +01:00
David Wilson dc4433ace6 issue #202: ansible: forget all dependent contexts on Stream disconnect
This is a partial fix, there are still at least 2 cases needing covered:

- In-progress connections must have CallError or similar sent to any
  waiters
- Once connection delegation exists, it is possible for other worker
  processes to be active (and in any step in the process), trying to
  communicate with a context that we know can no longer be communicated
  with. The solution to that isn't clear yet.

Additionally ensure root has /bin/bash shell in both Docker images.
2018-04-21 19:04:19 +01:00
David Wilson c5fe817db2 ansible: tidy up log repr slightly 2018-04-21 18:19:55 +01:00
David Wilson e7831a801f issue #195: handle non-ASCII scripts in runner.py. 2018-04-20 20:47:07 +01:00
David Wilson 85e1f5f515 ansible: remove JobResultService, more compatible async jobs; closes #191.
And by "compatible" I mean "terrible". This does not implement async job
timeouts, but I'm not going to bother, upstream async implementation is
so buggy and inconsistent it resists even having its behaviour captured
in tests.
2018-04-20 17:02:48 +01:00
David Wilson 296683b130 ansible: always display Mitogen errors and warnings.
They're no longer buried in -vvv output.
2018-04-19 22:10:52 +01:00
David Wilson 810f557514 issue #195: MITOGEN_DUMP_THREAD_STACKS=1 2018-04-18 23:37:42 +01:00
David Wilson f06ae05734 issue #195: add extra logging around FileService and get_file(). 2018-04-18 23:14:23 +01:00