-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ansible_mitogen: Support templated become_user
#1148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, but this PR has multiple issues
- as mentioned it needs to use the become plugin, not the connection plugin
- the changelog should be narrower in its claim
- It needs additional tests to confirm that templated become user now works, and that it will stay working in the future.
This is my work in progress for handling become plugin options # Better to use ActionBase.get_become_option? Probably not, as long as
# ansible_mitogen.connection.Connection.reset() assigns a half lobotomised
# self._action
def _become_option(self, name):
plugin = self._connection.become
if plugin is not None:
return plugin.get_option(
name, hostvars=self._task_vars, playcontext=self._play_context,
)
else:
# FIXME BecomeBase.get_option() only does this for become_user,
# become_pass, become_flags, & become_exe.
LOG.warning(
'%r: Used play_context fallback for option %r', self, name,
)
return getattr(self._play_context, name) The FIXME is part of why it's still WIP, the other is that I haven't worked out how to test it yet. |
Should I close this PR? I feel like it`s not the best idea to leave this PR if you are already working on that topic. |
Lets leave it open, in draft. It's as agood a place as any to collect notes, intermiediate test results and generally collaborate. Have you manually tested your code change? Is it working for your playbook(s)? |
Notes:
|
Noticed several commented out tests related to
|
become_user
This reads the become username from the `become_user` attribute of the play context, to the `"become_user"` option of the loaded become plugin. This has been supported by vanilla Ansible since Ansible 2.10 (ansible-base 2.10). To support this I've also switched from using the `play_context.become` (a bool), to `connection.become` (an instance of the appropriate) become plugin. New tests have been added, modelled on those for templated connection parameters (see mitogen-hq#1147, mitogen-hq#1153, mitogen-hq#1159). See - ansible/ansible@480b106 refs mitogen-hq#1083 Co-authored-by: mordek <[email protected]>
a98ee83
to
bf6607e
Compare
@mordekasg I've updated the branch with what I think is the correct combination to get templated I also added you to the list of contributers. If you'd prefer not to be listed or to change the entry, then please let me know. |
I tested my change then and now - you were right, it`s not working or working randomly.
Thank you! Will try to do it today. |
@moreati |
thank you, great news. |
The code reviewed has been replaced by commits I made
refs #1083