include_vars expects a yaml formatted file, so that won't understand
your shell environment variables file.
You could write an ansible task that parses that .env file.
But I would just source that .env file from the shell that ansible
runs from and be done with it.
On Mon, 26 Dec 2022 at 17:28, Simon Hryszko <
szev...@gmail.com> wrote:
>
> Hey,
>
> I need to use same file for ansible and bash envirements so I made file $HOME/.env with
> ```
> export main_username=simon
> export env=xd
> ```
>
> I have this task in my ansible script:
> ```
> - name: Load environment variables
> include_vars: /home/simon/.env
> ```
> But this task:
> ```
> - name: debug (print env)
> ansible.builtin.debug:
> var: main_username
> ```
>
> Return:
> TASK [debug (print env)] *******************************************************************************************************************************************************************************************
> ok: [localhost] => {
> "main_username": "VARIABLE IS NOT DEFINED!"
> }
>
>
> Does anyone may be able to help?
>
> --
> 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
ansible-proje...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/53926d6c-5e56-4c8d-be14-97ff6baec9efn%40googlegroups.com.