forked from mitogen-hq/mitogen
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible_mitogen: Handle templated connection passwords and ansible_ss…
…h_password This switches `ansible_mitogen.transport_config.PlayContextSpec.password()` to Ansible's plugin option framework. As a result - The relatively recent `ansible_ssh_password` variable is now respected. - The SSH connection password can be templated and specified as a play variable. Task variables will probably also work, but testing was blocked by mitogen-hq#1132. There is a chance this change will cause a regression in another connection plugin (e.g. mitogen_docker), but nothing turned up in the test suite. I intend ot migrate other connection configuration to `ansible_mitogen.transport_config.PlayContextSpec._connect_option()`, the next candidate is the remote port. fixes mitogen-hq#1107
- Loading branch information
Showing
8 changed files
with
72 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,35 +32,20 @@ | |
import os.path | ||
import sys | ||
|
||
from ansible.plugins.connection.ssh import ( | ||
DOCUMENTATION as _ansible_ssh_DOCUMENTATION, | ||
) | ||
|
||
DOCUMENTATION = """ | ||
name: mitogen_ssh | ||
author: David Wilson <[email protected]> | ||
connection: mitogen_ssh | ||
short_description: Connect over SSH via Mitogen | ||
description: | ||
- This connects using an OpenSSH client controlled by the Mitogen for | ||
Ansible extension. It accepts every option the vanilla ssh plugin | ||
accepts. | ||
version_added: "2.5" | ||
options: | ||
ssh_args: | ||
type: str | ||
vars: | ||
- name: ssh_args | ||
- name: ansible_ssh_args | ||
- name: ansible_mitogen_ssh_args | ||
ssh_common_args: | ||
type: str | ||
vars: | ||
- name: ssh_args | ||
- name: ansible_ssh_common_args | ||
- name: ansible_mitogen_ssh_common_args | ||
ssh_extra_args: | ||
type: str | ||
vars: | ||
- name: ssh_args | ||
- name: ansible_ssh_extra_args | ||
- name: ansible_mitogen_ssh_extra_args | ||
""" | ||
""" + _ansible_ssh_DOCUMENTATION.partition('options:\n')[2] | ||
|
||
try: | ||
import ansible_mitogen | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- name: integration/ssh/templated_by_inv.yml | ||
hosts: tt_targets_inventory | ||
gather_facts: false | ||
tasks: | ||
- meta: reset_connection | ||
- name: Templated variables in inventory | ||
ping: |
10 changes: 10 additions & 0 deletions
10
tests/ansible/integration/ssh/templated_by_play_taskvar.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- name: integration/ssh/templated_by_play_taskvar.yml | ||
hosts: tt_targets_bare | ||
gather_facts: false | ||
vars: | ||
ansible_password: "{{ 'has_sudo_nopw_password' | trim }}" | ||
|
||
tasks: | ||
- meta: reset_connection | ||
- name: Templated variables in play | ||
ping: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters