After reviewing your comments, you stated that you are trying to create aliases, not for a specific session. Why not create these aliases inside /etc/profile.d on machines for which you need these specific aliases, and not for the user?
Also, from another post that came up when I launched a Google search on Ansible specificics, since I am not an Ansible expert ... It is not possible to transfer the .bashrc source using Ansible (thanks to @chucksmash for the link)
"Steve Midgley
You have two options for using a source with accessibility. One with the command "shell:" and / bin / sh (the default is the default). The "source" is called ".". in / bin / sh. Thus, your team will:
-name: source bashrc sudo: no shell: . /home/username/.bashrc && [the actual command you want run]
Note that you need to run the command after searching for .bashrc b / c, each ssh session is different - each ansible command is run in a separate ssh transaction.
The second option is to force Ansible shell to use bash, and then you can use the "source" command: \
name: source bashrc sudo: no shell: source /home/username/.bashrc && [the actual command you want run] args: executable: /bin/bash
Finally, I want to note that you might want to actually specify "/ etc / profile" if you are on Ubuntu or similar, which more closely mimics a local login. "
bluerojo
source share