Yes @Nagray, you're right! You can access the environment variables on the local server using the lookup plugin. It lets you access the system data and environment variables.
Example: prints HOME env variable
- hosts: all
tasks:
- name: Printing the environment variable in Ansible
debug:
msg: "{{ lookup('env','HOME') }}"
output
------
"msg": "/Users/mdtutorials2"