[go: nahoru, domu]

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

Add quotes around each host in inventory #88

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bambamboole
Copy link
Contributor
@bambamboole bambamboole commented Apr 30, 2023

This PR "fixes" how the inventory is parsed.

Before it has surrounded the comma delimited hosts with double quotes.
For me this ended up in something like:

ANSIBLE_HOST_KEY_CHECKING='False' 'ansible-playbook' 'general.yml' '--private-key=/Users/user_name/Projects/private/server/storage/app/ssh_keys/01GZ920GJKRZTWQ6DBD0Z623FN' '--user=user_name' '--inventory="111.92.169.113,"'

But Ansible can't connect to the host by having it formatted like this.
Adding quotes arounf each host resolves the issue for me:

ANSIBLE_HOST_KEY_CHECKING='False' 'ansible-playbook' 'general.yml' '--private-key=/Users/user_name/Projects/private/server/storage/app/ssh_keys/01GZ920GJKRZTWQ6DBD0Z623FN' '--user=user_name' '--inventory="111.92.169.113",'

This could be an issue for host names with spaces in it, or what do you think?

I changed it to wrap each host with quotes. I think this should solve both cases :)

@maschmann
Copy link
Owner

Hi :-)
We really added the double quotes to be able to use spaces in hostnames. For some instances, like e.g. AWS VM names, spaces might be present in hostnames. On the other hand, if present, double quotes do no harm to the hostlist string.

Not sure what breaks the host list, though: What OS did you test it on and also with which Ansible version?
might be the combination of "," with the quotes.

@bambamboole
Copy link
Contributor Author

I am developing on macOS and use one of the latest versions of Ansible. Not at home currently, but can check later.
Would you accept the PR if I extend it and add quotes to hosts containing spaces?

@bambamboole bambamboole changed the title Remove quotes around hosts Add quotes around each host in inventory Apr 30, 2023
@bambamboole
Copy link
Contributor Author

@maschmann I updated the PR to facilitate hosts with spaces in it.

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.

None yet

2 participants