Member-only story

Read an environment variable — Ansible lookup plugin env

How to automate the reading of HOME environmental variable and use it in your Ansible Playbook code with lookup plugin env.

Luca Berton
4 min readFeb 18, 2022

How to read an environment variable on Ansible Controller with Ansible?
I’m going to show you a live demo with some simple Ansible code.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

Ansible read an environment variable

  • ansible.builtin.env
  • Read the value of environment variables

Let’s deep dive into the Ansible lookup plugin env.
Plugins are a way to expand the Ansible functionality. With lookup plugins specifically, you can load variables or templates with information from external sources.
The full name is `ansible.builtin.env`, it’s part of `ansible-core` and is included in all Ansible installations.
The purpose of the `env` lookup plugin is to read the value of environment variables.

Parameters and Return Value

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet