Skip to content
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 fix hostnames #862

Conversation

alinabuzachis
Copy link
Collaborator

@alinabuzachis alinabuzachis commented Jun 3, 2022

SUMMARY

aws_ec2- fix hostnames bugs

Should fix #582 and #583

  1. Fix returned hosts when
hostnames:
- tag:Tag1,Tag2
  1. Fix returned hosts when
hostnames:
- tag:Tag1
- tag:Tag2
  1. Fix returned hosts when
hostnames:
- tag:Tag1=Test1,Tag2=Test2

Given and EC2 instance with the following tags

tags:
  Tag1: Test1
  Tag2: Test2

Instead of only returning

"aws_ec2": {
    "hosts": [
        "Test1"
    ]
},
"tag_Name_instance_02": {
    "hosts": [
        "Test1"
    ]
},
"tag_Tag1_Test1": {
    "hosts": [
        "Test1"
    ]
},
"tag_Tag2_Test2": {
    "hosts": [
        "Test1"
    ]
}

It returns now

{
"_meta": {
   "hostvars": {
         "Test1": {
                "ami_launch_index": 0,
                "ansible_host": "10.210.0.101",
                   ...},
         "Test2": {
                 "ami_launch_index": 0,
                 "ansible_host": "10.210.0.101",
                   ...},
    },
    "all": {
        "children": [
            "aws_ec2",
            "tag_Name_instance_02",
            "tag_Tag1_Test1",
            "tag_Tag2_Test2",
            "ungrouped"
        ]
    },
    "aws_ec2": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Name_instance_02": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Tag1_Test1": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Tag2_Test2": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    }
}



ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

aws_ec2

ADDITIONAL INFORMATION

Signed-off-by: Alina Buzachis <[email protected]>
@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review integration tests/integration inventory inventory plugin needs_triage plugins plugin (any type) tests tests labels Jun 3, 2022
@alinabuzachis alinabuzachis force-pushed the aws_ec2/fix_hostnames branch from ac153ec to 0ba6958 Compare June 3, 2022 12:45
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 5m 50s
✔️ build-ansible-collection SUCCESS in 4m 52s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 9m 53s
✔️ ansible-test-sanity-aws-ansible-2.9-python38 SUCCESS in 14m 11s
✔️ ansible-test-sanity-aws-ansible-2.11-python38 SUCCESS in 9m 27s
ansible-test-units-amazon-aws-python38 FAILURE in 6m 12s
ansible-test-units-amazon-aws-python39 FAILURE in 5m 25s
✔️ ansible-test-splitter SUCCESS in 2m 28s
integration-amazon.aws-1 FAILURE in 24m 34s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
✔️ integration-community.aws-1 SUCCESS in 36m 59s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@alinabuzachis alinabuzachis force-pushed the aws_ec2/fix_hostnames branch 2 times, most recently from 5ba0047 to 90fc36c Compare June 3, 2022 14:01
@alinabuzachis alinabuzachis changed the title aws_ec2 fix hostnames [WIP] aws_ec2 fix hostnames Jun 3, 2022
@ansibullbot ansibullbot added the WIP Work in progress label Jun 3, 2022
@alinabuzachis alinabuzachis force-pushed the aws_ec2/fix_hostnames branch from 90fc36c to 49bba77 Compare June 3, 2022 14:20
@alinabuzachis alinabuzachis force-pushed the aws_ec2/fix_hostnames branch from 49bba77 to 0ff5348 Compare June 3, 2022 14:22
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 4m 25s
✔️ build-ansible-collection SUCCESS in 5m 44s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 9m 07s
✔️ ansible-test-sanity-aws-ansible-2.9-python38 SUCCESS in 12m 32s
✔️ ansible-test-sanity-aws-ansible-2.11-python38 SUCCESS in 8m 49s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 7m 14s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 55s
✔️ ansible-test-splitter SUCCESS in 2m 44s
✔️ integration-amazon.aws-1 SUCCESS in 44m 11s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
✔️ integration-community.aws-1 SUCCESS in 34m 46s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@alinabuzachis alinabuzachis changed the title [WIP] aws_ec2 fix hostnames aws_ec2 fix hostnames Jun 3, 2022
Signed-off-by: Alina Buzachis <[email protected]>
@ansibullbot ansibullbot removed the WIP Work in progress label Jun 3, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 03s
✔️ build-ansible-collection SUCCESS in 4m 43s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 9m 52s
✔️ ansible-test-sanity-aws-ansible-2.9-python38 SUCCESS in 11m 22s
✔️ ansible-test-sanity-aws-ansible-2.11-python38 SUCCESS in 8m 58s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 36s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 5m 55s
✔️ ansible-test-splitter SUCCESS in 2m 35s
integration-amazon.aws-1 RETRY_LIMIT in 1m 38s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@alinabuzachis
Copy link
Collaborator Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 4m 46s
✔️ build-ansible-collection SUCCESS in 4m 51s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 10m 53s
✔️ ansible-test-sanity-aws-ansible-2.9-python38 SUCCESS in 11m 40s
✔️ ansible-test-sanity-aws-ansible-2.11-python38 SUCCESS in 11m 13s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 54s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 01s
✔️ ansible-test-splitter SUCCESS in 2m 29s
✔️ integration-amazon.aws-1 SUCCESS in 38m 09s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
✔️ integration-community.aws-1 SUCCESS in 48m 58s
✔️ integration-community.aws-2 SUCCESS in 34m 50s
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

Comment on lines 13 to 16
# can also be specified using
# - tag:Tag1,Tag2
# or
# - tag:Tag1=Test1,Tag2=Test2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible I'd like to see an integration test of at least one of these.
"tag:Tag1,Tag2" wouldn't be the 'usual' way to write tags in a filter (see #582), so if that leaked into a filter it's more likely to break things than "tag:Tag1,tag:Tag2" appearing in a filter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the integration tests for - tag:Tag1=Test1,Tag2=Test2.

@alinabuzachis alinabuzachis force-pushed the aws_ec2/fix_hostnames branch 2 times, most recently from af9d0fe to 0e40a4a Compare June 22, 2022 11:34
@alinabuzachis alinabuzachis force-pushed the aws_ec2/fix_hostnames branch from 85fcd49 to b696b03 Compare June 22, 2022 11:36
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 24s
✔️ build-ansible-collection SUCCESS in 4m 42s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 9m 22s
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 11m 01s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 10m 44s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 04s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 7m 15s
✔️ ansible-test-splitter SUCCESS in 2m 30s
integration-amazon.aws-1 FAILURE in 44m 50s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
✔️ integration-community.aws-1 SUCCESS in 15m 29s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

Signed-off-by: Alina Buzachis <[email protected]>
@alinabuzachis alinabuzachis force-pushed the aws_ec2/fix_hostnames branch from b696b03 to 0891fba Compare June 22, 2022 14:13
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 3m 35s
✔️ build-ansible-collection SUCCESS in 4m 50s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 10m 30s
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 9m 32s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 43s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 55s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 35s
✔️ ansible-test-splitter SUCCESS in 2m 28s
✔️ integration-amazon.aws-1 SUCCESS in 47m 14s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
✔️ integration-community.aws-1 SUCCESS in 15m 59s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@alinabuzachis alinabuzachis requested a review from jillr June 22, 2022 17:00
@alinabuzachis alinabuzachis requested a review from markuman June 23, 2022 11:19
@tremble tremble added the mergeit Merge the PR (SoftwareFactory) label Jun 24, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 4m 16s
✔️ build-ansible-collection SUCCESS in 4m 51s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 11m 44s
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 9m 57s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 41s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 7m 25s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 05s
✔️ ansible-test-splitter SUCCESS in 2m 51s
✔️ integration-amazon.aws-1 SUCCESS in 43m 31s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit ca33389 into ansible-collections:main Jun 24, 2022
@github-actions
Copy link

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@tremble tremble added the backport-4 PR should be backported to the stable-4 branch label Jun 24, 2022
@patchback
Copy link

patchback bot commented Jun 24, 2022

Backport to stable-4: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-4/ca33389025293863a0884a0a0295bb4cfd46688c/pr-862

Backported as #899

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jun 24, 2022
aws_ec2 fix hostnames

SUMMARY

aws_ec2- fix hostnames bugs
Should fix #582 and #583

Fix returned hosts when

hostnames:
- tag:Tag1,Tag2

Fix returned hosts when

hostnames:
- tag:Tag1
- tag:Tag2

Fix returned hosts when

hostnames:
- tag:Tag1=Test1,Tag2=Test2

Given and EC2 instance with the following tags
tags:
  Tag1: Test1
  Tag2: Test2

Instead of only returning
"aws_ec2": {
    "hosts": [
        "Test1"
    ]
},
"tag_Name_instance_02": {
    "hosts": [
        "Test1"
    ]
},
"tag_Tag1_Test1": {
    "hosts": [
        "Test1"
    ]
},
"tag_Tag2_Test2": {
    "hosts": [
        "Test1"
    ]
}

It returns now
{
"_meta": {
   "hostvars": {
         "Test1": {
                "ami_launch_index": 0,
                "ansible_host": "10.210.0.101",
                   ...},
         "Test2": {
                 "ami_launch_index": 0,
                 "ansible_host": "10.210.0.101",
                   ...},
    },
    "all": {
        "children": [
            "aws_ec2",
            "tag_Name_instance_02",
            "tag_Tag1_Test1",
            "tag_Tag2_Test2",
            "ungrouped"
        ]
    },
    "aws_ec2": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Name_instance_02": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Tag1_Test1": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Tag2_Test2": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    }
}

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

aws_ec2
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Markus Bergholz <[email protected]>
(cherry picked from commit ca33389)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jun 24, 2022
[PR #862/ca333890 backport][stable-4] aws_ec2 fix hostnames

This is a backport of PR #862 as merged into main (ca33389).
SUMMARY

aws_ec2- fix hostnames bugs
Should fix #582 and #583

Fix returned hosts when

hostnames:
- tag:Tag1,Tag2


Fix returned hosts when

hostnames:
- tag:Tag1
- tag:Tag2


Fix returned hosts when

hostnames:
- tag:Tag1=Test1,Tag2=Test2

Given and EC2 instance with the following tags
tags:
  Tag1: Test1
  Tag2: Test2

Instead of only returning
"aws_ec2": {
    "hosts": [
        "Test1"
    ]
},
"tag_Name_instance_02": {
    "hosts": [
        "Test1"
    ]
},
"tag_Tag1_Test1": {
    "hosts": [
        "Test1"
    ]
},
"tag_Tag2_Test2": {
    "hosts": [
        "Test1"
    ]
}

It returns now
{
"_meta": {
   "hostvars": {
         "Test1": {
                "ami_launch_index": 0,
                "ansible_host": "10.210.0.101",
                   ...},
         "Test2": {
                 "ami_launch_index": 0,
                 "ansible_host": "10.210.0.101",
                   ...},
    },
    "all": {
        "children": [
            "aws_ec2",
            "tag_Name_instance_02",
            "tag_Tag1_Test1",
            "tag_Tag2_Test2",
            "ungrouped"
        ]
    },
    "aws_ec2": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Name_instance_02": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Tag1_Test1": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Tag2_Test2": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    }
}




 
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

aws_ec2
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell <None>
jatorcasso pushed a commit to jatorcasso/amazon.aws that referenced this pull request Jun 27, 2022
aws_ec2 fix hostnames

SUMMARY

aws_ec2- fix hostnames bugs
Should fix ansible-collections#582 and ansible-collections#583

Fix returned hosts when

hostnames:
- tag:Tag1,Tag2


Fix returned hosts when

hostnames:
- tag:Tag1
- tag:Tag2


Fix returned hosts when

hostnames:
- tag:Tag1=Test1,Tag2=Test2

Given and EC2 instance with the following tags
tags:
  Tag1: Test1
  Tag2: Test2

Instead of only returning
"aws_ec2": {
    "hosts": [
        "Test1"
    ]
},
"tag_Name_instance_02": {
    "hosts": [
        "Test1"
    ]
},
"tag_Tag1_Test1": {
    "hosts": [
        "Test1"
    ]
},
"tag_Tag2_Test2": {
    "hosts": [
        "Test1"
    ]
}

It returns now
{
"_meta": {
   "hostvars": {
         "Test1": {
                "ami_launch_index": 0,
                "ansible_host": "10.210.0.101",
                   ...},
         "Test2": {
                 "ami_launch_index": 0,
                 "ansible_host": "10.210.0.101",
                   ...},
    },
    "all": {
        "children": [
            "aws_ec2",
            "tag_Name_instance_02",
            "tag_Tag1_Test1",
            "tag_Tag2_Test2",
            "ungrouped"
        ]
    },
    "aws_ec2": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Name_instance_02": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Tag1_Test1": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    },
    "tag_Tag2_Test2": {
        "hosts": [
            "Test1",
            "Test2"
        ]
    }
}




 
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

aws_ec2
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Markus Bergholz <[email protected]>
@flowerysong
Copy link
Contributor

flowerysong commented Aug 16, 2022

This is a massively breaking change, not a bugfix. hostnames was designed as an ordered list of hostname candidates, with the first working one used. Switching to using all working candidates results in the same host being added to the inventory multiple times (#950), which is not what most people want.

I can see why someone might want the new behaviour, but it should default to off.

With this change:

    "az_us_east_2b": {
        "hosts": [
            "ec2-18-221-212-154.us-east-2.compute.amazonaws.com",
            "ec2-3-14-67-171.us-east-2.compute.amazonaws.com",
            "ip-10-0-81-209.us-east-2.compute.internal",
            "ip-10-0-81-33.us-east-2.compute.internal",
            "set-byakhee.jail.x.mail.umich.edu",
            "unimpeded-nunobiki.mx.x.mail.umich.edu"
        ]
    },

After reverting to the previous working version:

    "az_us_east_2b": {
        "hosts": [
            "set-byakhee.jail.x.mail.umich.edu",
            "unimpeded-nunobiki.mx.x.mail.umich.edu"
        ]
    },

@yamjoepobuda
Copy link

This is a massively breaking change, not a bugfix.

We had a number of systems break due to this change. We rely on host_vars being a static value. This introduced literal chaos and caused a number of hosts to fallback to role defaults.

@markuman
Copy link
Member

markuman commented Sep 1, 2022

Maybe a new parameter unique_hostnames with default(true) must be introduced, that brings the old behaviour back.
What do you think @alinabuzachis?

@alinabuzachis
Copy link
Collaborator Author

Maybe a new parameter unique_hostnames with default(true) must be introduced, that brings the old behaviour back.
What do you think @alinabuzachis?

Yes, we can also do that. @tremble what do you think instead?

@tremble
Copy link
Contributor

tremble commented Sep 1, 2022

I'd head in that direction

Might it also be worth exposing "hostname_" groups so that all of the hostnames can be accessed?

@goneri
Copy link
Member

goneri commented Sep 15, 2022

For the record, I'm working on a fix for this, cf #950

-> #1026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-4 PR should be backported to the stable-4 branch bug This issue/PR relates to a bug community_review has_issue integration tests/integration inventory inventory plugin mergeit Merge the PR (SoftwareFactory) plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_ec2.yml file hostnames example file doesn't work
7 participants