-
Notifications
You must be signed in to change notification settings - Fork 163
Support templating in ansible_user #344
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
base: main
Are you sure you want to change the base?
Support templating in ansible_user #344
Conversation
Before this change it is not possible to use templating for the ansible_user e.g: ansible_user: "{{ some_variable }}"
@@ -347,6 +347,7 @@ def run(self, tmp=None, task_vars=None): | |||
|
|||
else: | |||
user = task_vars.get('ansible_user') or self._play_context.remote_user | |||
user = self._templar.template(user) |
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.
the vars were always the wrong thing to get, the correct info should be from the connection itself using get_option
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.
Seems like a good suggestion. Would we need to parse ssh_args to get the user? Or is that exposed as an option? Do we need to consider other connection plugins other than ssh?
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.
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.
all connections at this point should be relying on get_option
some older ones might still be using play_context.<data>
but this is incorrect as it does not always reflect changes do to modifiers in the task (mostly loops). In no case should you be using variables directly.
SUMMARY
Before this change it is not possible to use templating for the ansible_user e.g:
The error you see looks like:
The module arguments look like:
In this case I'm using:
ISSUE TYPE
COMPONENT NAME
synchronize
ADDITIONAL INFORMATION