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

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
    - name: Multiple environment​ variables in a single line ansible task
        msg: "{{ lookup('env','USER','HOME','SHELL') }}"

"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,560 points
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,560 points
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
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
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.