Error while using lambda_facts module

Hi Team,

We are using lambda_facts module of ansible to fetch existing aws lambda details but facing below issue while running -

TASK [Get lambda info if it already exists] **************************************************************************
Thursday 02 December 2021 22:06:49 -0800 (0:00:00.339) 0:00:24.123 *****
fatal: [localhost]: FAILED! => {“changed”: false, “module_stderr”: “main:95: RuntimeWarning: Parent module ‘ansible.modules’ not found while handling absolute import\n__main__:96: RuntimeWarning: Parent module ‘ansible.modules’ not found while handling absolute import\n__main__:97: RuntimeWarning: Parent module ‘ansible.modules’ not found while handling absolute import\n__main__:98: RuntimeWarning: Parent module ‘ansible.modules’ not found while handling absolute import\n__main__:99: RuntimeWarning: Parent module ‘ansible.modules’ not found while handling absolute import\n__main__:100: RuntimeWarning: Parent module ‘ansible.modules’ not found while handling absolute import\n__main__:104: RuntimeWarning: Parent module ‘ansible.modules’ not found while handling absolute import\nTraceback (most recent call last):\n File "master:/ws/shivania-sjc/qa/bender/ansible/playbooks/mitogen/ansible_mitogen/runner.py", line 975, in _run\n self._run_code(code, mod)\n File "master:/ws/shivania-sjc/qa/bender/ansible/playbooks/mitogen/ansible_mitogen/runner.py", line 941, in _run_code\n exec(‘exec code in vars(mod)’)\n File "", line 1, in \n File "master:/usr/lib/python2.7/site-packages/ansible/modules/cloud/amazon/lambda_facts.py", line 401, in \n File "master:/usr/lib/python2.7/site-packages/ansible/modules/cloud/amazon/lambda_facts.py", line 389, in main\nAttributeError: ‘module’ object has no attribute ‘config_details’\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}

Please let me know how we can resolve this.

Regards,
Shivani

What is the output of ‘ansible --version’ ?

-bash-4.2$ ansible --version

ansible 2.7.5
config file = /ws/shivania-sjc/qa/bender/ansible/playbooks/ansible.cfg
configured module search path = [u’/ws/shivania-sjc/qa/bender/ansible/library’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

That version is 3 years old now
(https://github.com/ansible/ansible/blob/stable-2.7/changelogs/CHANGELOG-v2.7.rst#v2-7-5),
and has been EOL for a while:
https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html#ansible-core-changelogs
Given that the cloud modules have seen many improvements, I would
start with a newer ansible version.

What does the playbook look like?
And also, did your playbook work before and started failing? Or has it
never worked?

And also, did your playbook work before and started failing? Or has it never worked? – Yes, the playbook was working before, now it’s giving error on task ( name: Get lambda info if it already exists)

  • hosts: localhost

name: Create a CloudFront distribution for UI components bucket

roles:

  • common

  • aws

connection: local

gather_facts: True

vars:

node_runtime: “nodejs12.x”

cdn_lambda_name: “AddHeadersToCDNResponses-{{ ec2_tag_environment }}”

tasks:

Get web vars so we can set the CDN URL correctly

  • include_vars: environment/{{ ec2_tag_environment }}/web_vars.yml

  • include_vars: aws_s3_bucket_names.yml

  • set_fact:

aws_cloudfront_cname: “cdn.{{ cloud_web_domain }}”

  • debug: var=aws_cloudfront_cname

  • name: Create IAM role for CloudFront lambda function

iam:

profile: “{{ aws_profile_name }}”

iam_type: role

name: CloudFront-Lambda-{{ ec2_tag_environment }}

state: present

trust_policy_filepath: templates/aws-cloudfront-lambda-role.j2

register: lambda_role_facts

  • debug: var=lambda_role_facts

  • name: Create a zip archive of the AddHeadersToCDNResponses lambda function

archive:

path: aws_lambda_code/AddHeadersToCDNResponses/*

dest: aws_lambda_code/AddHeadersToCDNResponses.zip

format: zip

  • name: Get lambda info if it already exists

lambda_facts:

query: config

function_name: “{{ cdn_lambda_name }}”

profile: “{{ aws_profile_name }}”

region: “{{ aws_region }}”

Yes, the playbook was working before, now it's giving error on task (
name: Get lambda info if it already exists)

Then something must have changed on your control node. But I don't know what.
Since you are using a system managed ansible installation, that can be
many things.