Skip to content

Commit e8fcd02

Browse files
committed
Fixes #1319 - Improve how ssh_args are loaded
This refactors how `ssh_args` are loaded since the private method `_ssh_args` on `PlayContext` has been removed in Ansible 2.11. Instead, we load the ssh plugin and get the option directly.
1 parent c694c4a commit e8fcd02

File tree

1 file changed

+6
-1
lines changed
  • lib/trellis/plugins/callback

1 file changed

+6
-1
lines changed

lib/trellis/plugins/callback/vars.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import re
55
import sys
6+
import os
67

78
from __main__ import cli
89
from ansible.module_utils.six import iteritems
@@ -14,6 +15,7 @@
1415
from ansible.template import Templar
1516
from ansible.utils.unsafe_proxy import wrap_var
1617
from ansible import context
18+
from ansible.plugins.loader import connection_loader
1719

1820

1921
class CallbackModule(CallbackBase):
@@ -94,6 +96,9 @@ def darwin_without_passlib(self):
9496
return True
9597

9698
def v2_playbook_on_play_start(self, play):
99+
play_context = PlayContext(play=play)
100+
connection = connection_loader.get('ssh', play_context, os.devnull)
101+
97102
env = play.get_variable_manager().get_vars(play=play).get('env', '')
98103
env_group = next((group for key,group in iteritems(play.get_variable_manager()._inventory.groups) if key == env), False)
99104
if env_group:
@@ -102,7 +107,7 @@ def v2_playbook_on_play_start(self, play):
102107
for host in play.get_variable_manager()._inventory.list_hosts(play.hosts[0]):
103108
hostvars = play.get_variable_manager().get_vars(play=play, host=host)
104109
self.raw_vars(play, host, hostvars)
105-
host.vars['ssh_args_default'] = PlayContext(play=play)._ssh_args.default
110+
host.vars['ssh_args_default'] = connection.get_option('ssh_args')
106111
host.vars['cli_options'] = self.cli_options()
107112
host.vars['cli_ask_pass'] = self._options.get('ask_pass', False)
108113
host.vars['cli_ask_become_pass'] = self._options.get('become_ask_pass', False)

0 commit comments

Comments
 (0)