Skip to content

Conversation

@thekad
Copy link
Collaborator

@thekad thekad commented Jun 9, 2025

SUMMARY

Fixes #434

It is basically the same as #438 but with a few extra checks.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

plugins/inventory/gcp_compute.py

ADDITIONAL INFORMATION

Fixes ansible-collections#434

It is basically the same as ansible-collections#438 but with a few extra checks, don't want
to rebase the whole thing.

Signed-off-by: Jorge Gallegos <[email protected]>
@codecov
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 30.31%. Comparing base (4d9aa19) to head (d8ca8a2).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
plugins/inventory/gcp_compute.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #689      +/-   ##
==========================================
- Coverage   30.31%   30.31%   -0.01%     
==========================================
  Files         177      177              
  Lines       19752    19754       +2     
  Branches     3246     3247       +1     
==========================================
  Hits         5988     5988              
- Misses      13757    13759       +2     
  Partials        7        7              
Flag Coverage Δ
sanity 29.60% <0.00%> (-0.01%) ⬇️
units 61.51% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thekad
Copy link
Collaborator Author

thekad commented Jun 9, 2025

This is the dynamic inventory configuration I used to test this, there is no integration test for dynamic inventory as far as I can tell:

---
plugin: google.cloud.gcp_compute
zones:
  - us-central1-a
  - us-central1-f
projects:
  - it-cloud-gcp-eco-ansible-gcp
filters:
  - status = RUNNING
service_account_file: /path/to/my/sa.json
auth_kind: serviceaccount
scopes:
 - 'https://www.googleapis.com/auth/cloud-platform'
 - 'https://www.googleapis.com/auth/compute.readonly'
keyed_groups:
  # Create groups from GCE labels
  - prefix: gcp
    key: labels
name_suffix: .redhat.com
hostnames:
  # List host by name instead of the default public ip
  - hostname
  - name

Copy link
Collaborator

@p3ck p3ck left a comment

Choose a reason for hiding this comment

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

LGTM - If you want to add some inventory test cases you can look at how it's done in azure...

https://github.com/ansible-collections/azure/tree/dev/tests/integration/targets/inventory_azure

@thekad
Copy link
Collaborator Author

thekad commented Jun 9, 2025

Oh cool, I was just looking into how to test this, thanks

@thekad
Copy link
Collaborator Author

thekad commented Jun 10, 2025

LGTM - If you want to add some inventory test cases you can look at how it's done in azure...

https://github.com/ansible-collections/azure/tree/dev/tests/integration/targets/inventory_azure

I have added a whole new integration test to assert the changes in this tiny commit, PTAL @p3ck

Signed-off-by: Jorge Gallegos <[email protected]>
@thekad thekad requested a review from SirGitsalot June 10, 2025 21:10
@thekad
Copy link
Collaborator Author

thekad commented Jun 10, 2025

This one supersedes #219 as well

@SirGitsalot SirGitsalot merged commit 43d8fd6 into ansible-collections:master Jun 20, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inventory plugin: adding the instance hostname field as inventory hostname

3 participants