I have create ansible role to create multiple lambda function, where I am passing some parameters from variable file. My variable file looks like
Variable file
S3BucketName: "test_bucket"
S3Key1: "test.zip"
runtime: "python3.6"
handler1: "test.lambda_handler"
role1: "test_role_arn"
memory_size: "128"
timeout: "180"
s3_key2: "temp.zip"
role2: "temp_role_Arn"
handler2: "temp.lambda_handler"
In my playbook, I am using ansible loop to create multiple aws lambda functions at the same time. when I am using variable in with_items.
Playbook file
- hosts: localhost
roles:
- ansible-lambda
vars_files:
- "ansible-lambda/vars/cf_vars.yaml"
lambda:
name: '{{ item.name }}'
region: "{{ aws_region }}"
state: "{{state}}"
runtime: "{{ runtime }}"
timeout: "{{timeout}}"
memory_size : "{{memory_size}}"
s3_bucket: "{{ S3BucketName}}"
s3_key: '{{ item.s3_key }}'
role: '{{ item.role }}'
handler: '{{ item.handler }}'
with_items:
- name: test
s3_key: "{{ S3Key1 }}" #refering to variable 1
- name: temp
s3_key: "{{ S3Key2 }}" #refering to variable 2
- debug:
msg: "Lambda creation Complete!!"
Following is the error:
fatal: [localhost]: FAILED! => {"msg": "'S3Key1' is undefined"}
This playbook works, when I pass the absolute values instead of variables. I mean s3_key: test.zip
how to use variables in with item?