Skip to content

Enhance connection to servers with only private_ips#35

Closed
jogoossens wants to merge 6 commits intoUpCloudLtd:mainfrom
HOSTED-POWER:main
Closed

Enhance connection to servers with only private_ips#35
jogoossens wants to merge 6 commits intoUpCloudLtd:mainfrom
HOSTED-POWER:main

Conversation

@jogoossens
Copy link
Copy Markdown

Automatic fallback if no public ip's are found

@jogoossens jogoossens requested a review from a team as a code owner December 5, 2025 12:20
@kangasta
Copy link
Copy Markdown
Member

Thank you for the pull request and sorry for the delay with this! I'll try to look into this during next week 👀

Copy link
Copy Markdown
Member

@kangasta kangasta left a comment

Choose a reason for hiding this comment

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

Seems that these changes use quite old version of the collection as their base. Would it be possible to rebase the source branch on top of the latest release.

I did not yet look into the change itself, just noticed the merge conflict warning at the bottom of the page.

Comment thread README.md
Comment on lines +1 to +4
# Fork notes:

This is a fork in order to develop some possible enhancements

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be removed before merging this. Maybe it would be cleaner if you used non-default branch of your fork as the source for the pull request 🤔

if len(possible_addresses) > 0:
self.inventory.set_variable(server.hostname, "ansible_host", to_native(possible_addresses[0]))
else:
connect_with = "private_ipv4" # Fallback to private_ipv4 if not any public address was found
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we could make this fallback configurable by accepting a list as a value for connect_with: #37

@kangasta
Copy link
Copy Markdown
Member

kangasta commented Apr 8, 2026

Hello! 👋 We updated the connect_with option to enable configuring a fallback using that option. The fallback implemented by this PR is available by setting connect_with to ["public_ipv4", "private_ipv4"]:

connect_with:
  - public_ipv4
  - private_ipv4

This is available in v0.10.0 🚢 If no objections, I'll close this PR. Thank you for the improvement suggestion!

@jogoossens
Copy link
Copy Markdown
Author

That sounds good, but would it give the private_ipv4 automatically if no public_ipv4? We'd need like "1 default" parameter to connect

@kangasta
Copy link
Copy Markdown
Member

kangasta commented Apr 8, 2026

Yes, with connect_with: ["public_ipv4", "private_ipv4"] (and network configured to UUID of the network your control server is connected to) the plugin would first check if server has a public IP and, if not, check for a private IP in the configured network.

@kangasta kangasta closed this Apr 21, 2026
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.

2 participants