I am calling ansible playbook from shell and in shell before calling playing book i am sourcing environment variables from file
config.ini:
IPC_IP=1.1.1.1
execute_playbook.sh
#!/bin/bash
set -o errexit
source /tmp/config.ini
ansible-playbook myplaybook.yaml
myplaybook.yaml
---
- hosts: "localhost"
become: yes
gather_facts: yes
tasks:
- name: Add Entry to /etc/hosts
become: yes
lineinfile:
dest: /etc/hosts
line: "{{ lookup('env','IPC_IP') }}\t\t{{ lookup('env','HOSTNAME') }}"
state: present
Now i can get value of HOSTNAME but not able to get IPC_IP value which i am sourcing from file.
export IPC_IP=1.1.1.1