Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix support envvars for lookup aws ssm (#837)
Fix support envvars for lookup aws ssm SUMMARY Took over from #623 to apply reviewer's comments and add a changelog fragment. Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...). This should fixes #519 Depends-On: #728 ISSUE TYPE Feature Pull Request COMPONENT NAME aws_ssm ADDITIONAL INFORMATION It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2. This is a simple snippet how it can be used: - name: Load env collections: - amazon.aws gather_facts: no hosts: localhost connection: local vars: my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}" tasks: - name: show the env debug: msg: "{{ my_env }}" Command line test: ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml Output: PLAY [Load env] ************************************************************************************************************************************************************************************************************************************************************* TASK [show the env] ********************************************************************************************************************************************************************************************************************************************************* ok: [localhost] => { "msg": "INIT" } PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************************** localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 Another test with envars: AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml where we remove the endpoint from lookup: - name: Load env collections: - amazon.aws gather_facts: no hosts: localhost connection: local vars: my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}" tasks: - name: show the env debug: msg: "{{ my_env }}" (provides same output) Reviewed-by: Mark Chappell <None>
- Loading branch information