From c1c8d5c31e652dcc02c54e5109fb71ea48b676eb Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 26 May 2019 12:06:14 +0100 Subject: [PATCH] issue #587: 2.8 PlayContext lacks sudo_flags attribute. This is a huge bodge. --- ansible_mitogen/strategy.py | 4 ++-- ansible_mitogen/transport_config.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ansible_mitogen/strategy.py b/ansible_mitogen/strategy.py index 1060e3b5..b6b9aaf2 100644 --- a/ansible_mitogen/strategy.py +++ b/ansible_mitogen/strategy.py @@ -276,8 +276,8 @@ class StrategyMixin(object): class_only=True, ) if play_context.connection is not Sentinel: - # 2.8 appears to defer computing this value until it's inside the - # worker. TODO: figure out where this value has moved. + # 2.8 appears to defer computing this until inside the worker. + # TODO: figure out where it has moved. ansible_mitogen.loaders.connection_loader.get( name=play_context.connection, class_only=True, diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index ad1cab3e..d5f15b10 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -380,8 +380,9 @@ class PlayContextSpec(Spec): for term in ansible.utils.shlex.shlex_split( first_true(( self._play_context.become_flags, - self._play_context.sudo_flags, - # Ansible 2.3. + # Ansible <=2.7. + getattr(self._play_context, 'sudo_flags', ''), + # Ansible <=2.3. getattr(C, 'DEFAULT_BECOME_FLAGS', ''), getattr(C, 'DEFAULT_SUDO_FLAGS', '') ), default='')