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
87 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
5,158 views
0 votes
0 answers

how can we unarchive multiple different files using ansible-playbook? i tried this yml file its getting error

---   - hosts: all     become: yes     vars:     - path: /home/ansadmin     tasks:     - name: ...READ MORE

Aug 17 in Ansible by Rajendra
• 450 points
159 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
717 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
128 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
203 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer