Print multiple env variables using ansible playbook

0 votes
How do I get multiple environment variables using ansible playbook?

I need home, shell and user in my output.

Thank you
Jan 24 in Ansible by Tom
48 views

1 answer to this question.

0 votes

Hey @Tom, you can use the lookup plugin to print environment variables. To print multiple env variables, just modify your arguments a little, something like this:

- hosts: all
  gather_facts: False
  tasks:
    - name: Multiple environment​ variables in a single line ansible task
      debug:
        msg: "{{ lookup('env','USER','HOME','SHELL') }}"

output
------
"msg": "root,/Users/user,/bin/sh"
answered Jan 24 by Rick

Related Questions In Ansible

0 votes
1 answer

ansible playbook: using multiple variables in loops

Use an indexed hostname, and then define ...READ MORE

answered Jul 16, 2018 in Ansible by DareDev
• 6,810 points
3,553 views
0 votes
1 answer

Using multiple config files using same template in a role in ansible

Go through this include_role module: tasks: - ...READ MORE

answered Jun 5, 2018 in Ansible by DareDev
• 6,810 points
336 views
0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,620 points
72 views
0 votes
1 answer

Execute a command using ansible playbook

Hey @Reshma, You can use the URI ...READ MORE

answered Jan 17 in Ansible by Sameer
92 views
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer