-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/support envvars for lookup aws ssm #623
Fix/support envvars for lookup aws ssm #623
Conversation
Build failed.
|
Build failed.
|
Build failed.
|
Build failed.
|
recheck |
recheck |
Build failed.
|
recheck |
@Cicatrice can you also add a channgelog fragment please? |
recheck |
recheck |
recheck |
193f0b4
to
c06cbba
Compare
@Cicatrice could you also please add a changelog fragment for this fix https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to? Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to submit this PR.
2 minor things:
- Please add a changelog fragment https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to
- boto3_conn already catches the various botocore exceptions, there's no need to re-catch them.
try: | ||
client = boto3_conn(module=self, **cli_boto_params) | ||
except ( | ||
botocore.exceptions.ProfileNotFound, | ||
botocore.exceptions.PartialCredentialsError, | ||
botocore.exceptions.ClientError, | ||
botocore.exceptions.ParamValidationError, | ||
): | ||
raise AnsibleError("Insufficient credentials found.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try: | |
client = boto3_conn(module=self, **cli_boto_params) | |
except ( | |
botocore.exceptions.ProfileNotFound, | |
botocore.exceptions.PartialCredentialsError, | |
botocore.exceptions.ClientError, | |
botocore.exceptions.ParamValidationError, | |
): | |
raise AnsibleError("Insufficient credentials found.") | |
client = boto3_conn(module=self, **cli_boto_params) |
The botocore exceptions are already caught
Superseded by #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>
Fix support envvars for lookup aws ssm SUMMARY Took over from ansible-collections#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 ansible-collections#519 Depends-On: ansible-collections#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> (cherry picked from commit 9639325)
Fix support envvars for lookup aws ssm SUMMARY Took over from ansible-collections#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 ansible-collections#519 Depends-On: ansible-collections#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> (cherry picked from commit 9639325)
Fix support envvars for lookup aws ssm SUMMARY Took over from ansible-collections#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 ansible-collections#519 Depends-On: ansible-collections#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> (cherry picked from commit 9639325)
Fix support envvars for lookup aws ssm SUMMARY Took over from ansible-collections#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 ansible-collections#519 Depends-On: ansible-collections#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> (cherry picked from commit 9639325)
Fix support envvars for lookup aws ssm (#837) This is a manual backport to stable-3 because #837 failed to be automatically backported. 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 (cherry picked from commit 9639325) SUMMARY ISSUE TYPE Bugfix Pull Request Docs Pull Request Feature Pull Request New Module Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Joseph Torcasso <None> Reviewed-by: Mark Chappell <None>
…nsible-collections#623) Added support for InputTransformer attribute of cloudwatchevent_rule SUMMARY EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage. ISSUE TYPE Feature Pull Request COMPONENT NAME aws.cloudwatchevent_rule ADDITIONAL INFORMATION ... "targets": [ { "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic", "id": "MySNSTopic", "input_transformer": { "input_paths_map": { "instance": "$.detail.instance-id", "state": "$.detail.state" }, "input_template": "\"<instance> is in state <state>\"" } } ] Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: Avishay Bar <[email protected]> Reviewed-by: Jill R <None> Reviewed-by: Mark Chappell <None> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections/community.aws@bd097b5
…nsible-collections#623) Added support for InputTransformer attribute of cloudwatchevent_rule SUMMARY EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage. ISSUE TYPE Feature Pull Request COMPONENT NAME aws.cloudwatchevent_rule ADDITIONAL INFORMATION ... "targets": [ { "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic", "id": "MySNSTopic", "input_transformer": { "input_paths_map": { "instance": "$.detail.instance-id", "state": "$.detail.state" }, "input_template": "\"<instance> is in state <state>\"" } } ] Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: Avishay Bar <[email protected]> Reviewed-by: Jill R <None> Reviewed-by: Mark Chappell <None> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections/community.aws@bd097b5
…nsible-collections#623) Added support for InputTransformer attribute of cloudwatchevent_rule SUMMARY EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage. ISSUE TYPE Feature Pull Request COMPONENT NAME aws.cloudwatchevent_rule ADDITIONAL INFORMATION ... "targets": [ { "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic", "id": "MySNSTopic", "input_transformer": { "input_paths_map": { "instance": "$.detail.instance-id", "state": "$.detail.state" }, "input_template": "\"<instance> is in state <state>\"" } } ] Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: Avishay Bar <[email protected]> Reviewed-by: Jill R <None> Reviewed-by: Mark Chappell <None> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections/community.aws@bd097b5
…nsible-collections#623) Added support for InputTransformer attribute of cloudwatchevent_rule SUMMARY EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage. ISSUE TYPE Feature Pull Request COMPONENT NAME aws.cloudwatchevent_rule ADDITIONAL INFORMATION ... "targets": [ { "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic", "id": "MySNSTopic", "input_transformer": { "input_paths_map": { "instance": "$.detail.instance-id", "state": "$.detail.state" }, "input_template": "\"<instance> is in state <state>\"" } } ] Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: Avishay Bar <[email protected]> Reviewed-by: Jill R <None> Reviewed-by: Mark Chappell <None> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections/community.aws@bd097b5
…nsible-collections#623) Added support for InputTransformer attribute of cloudwatchevent_rule SUMMARY EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage. ISSUE TYPE Feature Pull Request COMPONENT NAME aws.cloudwatchevent_rule ADDITIONAL INFORMATION ... "targets": [ { "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic", "id": "MySNSTopic", "input_transformer": { "input_paths_map": { "instance": "$.detail.instance-id", "state": "$.detail.state" }, "input_template": "\"<instance> is in state <state>\"" } } ] Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: Avishay Bar <[email protected]> Reviewed-by: Jill R <None> Reviewed-by: Mark Chappell <None>
…nsible-collections#623) Added support for InputTransformer attribute of cloudwatchevent_rule SUMMARY EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage. ISSUE TYPE Feature Pull Request COMPONENT NAME aws.cloudwatchevent_rule ADDITIONAL INFORMATION ... "targets": [ { "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic", "id": "MySNSTopic", "input_transformer": { "input_paths_map": { "instance": "$.detail.instance-id", "state": "$.detail.state" }, "input_template": "\"<instance> is in state <state>\"" } } ] Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: Avishay Bar <[email protected]> Reviewed-by: Jill R <None> Reviewed-by: Mark Chappell <None>
…nsible-collections#623) Added support for InputTransformer attribute of cloudwatchevent_rule SUMMARY EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage. ISSUE TYPE Feature Pull Request COMPONENT NAME aws.cloudwatchevent_rule ADDITIONAL INFORMATION ... "targets": [ { "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic", "id": "MySNSTopic", "input_transformer": { "input_paths_map": { "instance": "$.detail.instance-id", "state": "$.detail.state" }, "input_template": "\"<instance> is in state <state>\"" } } ] Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: Avishay Bar <[email protected]> Reviewed-by: Jill R <None> Reviewed-by: Mark Chappell <None>
Depends-On: ansible/ansible-zuul-jobs#1424
SUMMARY
Working on support in
lookup
pluginamazon.aws.aws_ssm
forendpoint
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
COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems
LookupModule
cannot benefit fromAnsibleAWSModule
(it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR usesboto3_conn
andget_aws_connection_info
defined inutils.ec2
.This is a simple snippet how it can be used:
Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
Another test with envars:
where we remove the
endpoint
fromlookup
:(provides same output)