I have JSON file with contents
env_variables.json
{ "server": "{{server}}" , "notes": "{{notes}}" }
and ansible-playbook as below: (to upload a lambda with the environment variables)
playbook.yml
- hosts: localhost
vars:
server: localhost
notes: hello this is localhost
tasks:
- name: Lambda creation/updation
lambda:
name: ansible_test
state: present
region: "eu-west-1"
role: 'arn:aws:iam::xyz:role/xyz_lambda'
zip_file: '{{ item.path }}'
runtime: 'python3.6'
environment_variables: "{{ lookup('file','/env_variables.json') | from_json }}"
handler: 'lambda_function.lambda_handler'
How can I use the above-mentioned "env_variables.json" file format to insert the environment variables with values mentioned in the "vars" directive of playbook.yml?