Pyinfra tries to collect postgresql fact on wrong host
See original GitHub issueDescribe the bug
While running postgresql.PostgresqlDatabases
fact, pyinfra does not take into consideration postgresql_host
conditional logic.
To Reproduce
databases = host.get_fact(postgresql.PostgresqlDatabases, postgresql_user="admin", postgresql_password="admin",
postgresql_host="localhost" if host.data.node=="master" else "192.168.56.10")
Here is the error log:
psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
[192.168.56.11] Is the server running on that host and accepting TCP/IP connections?
Expected behavior
With the fact collection above, pyinfra would not run the conditional logic for host selection, and default to host as localhost
regardless of which server it is running on. Since one of the servers, I am targeting, is running the postgres its host needs to be localhost, while others are not running postgres and thus the host they use to connect to postgres needs to be different (ip in this case). Thus, I would expect that the conditional logic in postgresql_host
field is respected when choosing a host to connect to.
Meta
- Include output of
pyinfra --support
. - How was pyinfra installed (source/pip)?
pip
- Include pyinfra-debug.log (if one was created)
- Consider including output with
-vv
and--debug
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Postgresql Facts - pyinfra Documentation
host.get_fact(PostgresqlDatabases, psql_user=None, psql_password=None, psql_host=None, psql_port=None). Returns a dict of PostgreSQL databases and metadata:.
Read more >Add more patterns/examples for deploys · Issue #200 - GitHub
I would like to see more patterns/examples for deploys. Ansible's docs usually contain a useable snippet as a starting point.
Read more >psql: error: connection to server at "127.0.0.1", port 5432 failed
Im trying to use PostgreSQL with django and I get that error when running ... server running on that host and accepting TCP/IP...
Read more >10 Things I Hate About PostgreSQL | by Rick Branson - Medium
10 Things I Hate About PostgreSQL | by Rick Branson | Medium. PostgreSQL performance degrades rapidly with more connections. Credit: brandur.org.
Read more >Trying Ansible alternatives in python - Bystroushaak's blog
After spending evening by studying Ansible alternatives, I've decided to use pyinfra, and I am quite happy with it.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will check v2.0.dev0 because ignoring errors is not really an option. Thank you 😃
v2 is now out which should resolve this, please re-open or make a new issue if there are still problems 😃