-
Notifications
You must be signed in to change notification settings - Fork 342
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
aws_ec2 and aws_rds inventories: An option to prefix hostvar names to prevent accidental collisions #535
Comments
Files identified in the description:
If these files are inaccurate, please update the |
Files identified in the description:
If these files are inaccurate, please update the |
Hi @giner Could you give us an example of a use case? Is this something that you could use |
Hi @jillr, let me illustrate by an example. There are two machines, somehost1 - AWS EC2 instance (from dynamic inventory) and somehost2 - statically defined instance. Please take a look at the playbook and the results below. $ cat play.yml
- hosts: somehost1 # AWS EC2 instance
gather_facts: no
tasks:
- name: Perform this action
debug:
msg: Performing the action
when: state is not defined or state is in ['started']
- hosts: somehost2 # Statically defined instance
gather_facts: no
tasks:
- name: Perform another action
debug:
msg: Performing another action
when: state is not defined or state is in ['started'] $ ansible-playbook -i inventory play.yml
PLAY [somehost1] ***********************************************************************************************************
TASK [Perform this action] *************************************************************************************************
skipping: [somehost1]
PLAY [somehost2] ***********************************************************************************************************
TASK [Perform another action] **********************************************************************************************
ok: [somehost2] =>
msg: Performing another action
PLAY RECAP *****************************************************************************************************************
somehost1 : ok=0 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
somehost2 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 $ ansible -i inventory -m debug -a "var=state" somehost1
PLAY [Ansible Ad-Hoc] ******************************************************************************************************
TASK [debug] ***************************************************************************************************************
ok: [somehost1] =>
state:
code: 16
name: running
PLAY RECAP *****************************************************************************************************************
somehost1 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Add option to prefix and/or suffix hostvar coming from AWS SUMMARY Closes #535 ISSUE TYPE Feature Pull Request COMPONENT NAME Inventory plugins aws_ec2 aws_rds Reviewed-by: Mark Chappell <None> Reviewed-by: None <None> Reviewed-by: Alina Buzachis <None> Reviewed-by: None <None>
…ble-collections#535) * fix issue ansible-collections#343 for missing AWS_SESSION_TOKEN
Summary
aws_ec2 and aws_rds inventory plugins 'pollute' hostvars with key-values which ansible has not control over. There are two problems with this:
It would be useful to have an option of enabling prefixes for host variable names coming from AWS (e.g.
aws_ec2_state
instead ofstate
).Issue Type
Feature Idea
Component Name
aws_ec2 inventory (plugins/inventory/aws_ec2.py), aws_rds inventory (plugins/inventory/aws_rds.py)
Additional Information
Examples
EC2 instance variables without prefixes (without the proposed change)
EC2 instance variables with prefixes (with the proposed change)
RDS instance variables without prefixes (without the proposed change)
RDS instance variables with prefixes (with the proposed change)
Code of Conduct
The text was updated successfully, but these errors were encountered: