Thursday, 30 July 2020

How to print Environment Variables in the Remote Servers using Ansible

We use ansible 'facts' to print environment variables of remote client.
‘ansible_env’ will garther all environment variables. Make sure 'gather_facts' is enabled/true.

Below playbook will print the env variable on client:

- hosts: all
  gather_facts: true
  tasks:
    - name: Printing all the environment variables in client
      debug:
        msg: "{{ ansible_env }}"


Sample Output:


No comments:

Post a Comment