Only, .bashrc isn't run by the shell module even if bash is used. Testing 
by adding
export BASHRC_RAN="# bashrc ran"
to .bashrc and running the shell module to
echo $BASHRC_RAN
bears this out.

On Friday, January 21, 2022 at 9:20:59 AM UTC-5 [email protected] wrote:

> [email protected] schrieb am Freitag, 21. Januar 2022 um 10:32:52 UTC+2:
>
>>
>> On 01/21/2022 8:15 AM Roland Müller <[email protected]> wrote: 
>>
>>
>> [email protected] schrieb am Mittwoch, 19. Januar 2022 um 17:38:49 
>> UTC+2: 
>>
>> On 19.01.22 11:53, Stefan Hornburg (Racke) wrote: 
>> > On 19/01/2022 11:34, dulhaver via Ansible Project wrote: 
>> >> 
>> >> can anybody tell me whether the ~/.bashrc of a become_user is being 
>> >> read on TASK execution, so you could rely on aliases, environment 
>> >> variables or PATH to be effective? 
>> > As far as know it is not being read. And I doubt that is a good idea 
>> > if the goal is idempotence. 
>> ok, thx 
>>
>>
>> But doesn't reading of .bashrc and other bash files depend on the Ansible 
>> module that is used, and whether the module executes inside a bash shell? 
>>  E.g., module 'shell' uses the bash shell unless some other shell is 
>> configured explicitly. Thus, one can execute remote with 'shell' commands 
>> with the same settings as in interactive login. 
>>
>> I was not thinking about shell module tbh. 
>>
>> Still, do I understand you correctly that you mean something like 
>>    ... .bashrc may not be read for most of Ansible modules but it *is* 
>> read for shell and maybe command module?
>>
>
> I mean .bashrc is only read when the used ansible module uses bash. The 
> become_user functionality - that is done before the module execution - does 
> not use bash (as others already answered above).
>
> The command module executes the provided command as such and shell uses a 
> shell (normally bash) to execute the command.
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1036ee13-0c2c-4f3e-bf0c-50000bdeef44n%40googlegroups.com.

Reply via email to