When trying to get a value from AWS SSM, Ansible Playbook using Python3 as an interpreter generates the following error:
fatal: [localhost-py3]: FAILED! => {"changed": false, "msg": "AnsibleError: An unhandled exception occurred while templating '{{ lookup('aws_ssm', 'server_listeners', decrypt=false, region=’eu-west-1′) }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while running the lookup plugin 'aws_ssm'. Error was a <class 'ansible.errors.AnsibleError'>, original message: botocore and boto3 are required for aws_ssm lookup."}
The Ansible documentation says that dependencies are needed for PIP:
- boto3
- botocore
But the error was still present until the "ansible" module was added to the PIP dependency
Solution:
--- - name: Ensure boto3, botocore and ansible modules are installed pip: name: - boto3 - botocore - ansible executable: /usr/bin/pip3