diff --git a/pyinfra/connectors/vagrant.py b/pyinfra/connectors/vagrant.py index 1f5f18e8c..5249551ba 100644 --- a/pyinfra/connectors/vagrant.py +++ b/pyinfra/connectors/vagrant.py @@ -93,13 +93,13 @@ def _make_name_data(host): "ssh_hostname": host["HostName"], } - for config_key, data_key in ( - ("Port", "ssh_port"), - ("User", "ssh_user"), - ("IdentityFile", "ssh_key"), + for config_key, data_key, data_cast in ( + ("Port", "ssh_port", int), + ("User", "ssh_user", str), + ("IdentityFile", "ssh_key", str), ): if config_key in host: - data[data_key] = host[config_key] + data[data_key] = data_cast(host[config_key]) # Update any configured JSON data if vagrant_host in vagrant_options.get("data", {}): diff --git a/tests/test_connectors/test_vagrant.py b/tests/test_connectors/test_vagrant.py index 6ea17ec05..f653bc7f6 100644 --- a/tests/test_connectors/test_vagrant.py +++ b/tests/test_connectors/test_vagrant.py @@ -75,7 +75,7 @@ def test_make_names_data_with_options(self): ( "@vagrant/ubuntu16", { - "ssh_port": "2222", + "ssh_port": 2222, "ssh_user": "vagrant", "ssh_hostname": "127.0.0.1", "ssh_key": "path/to/key", @@ -85,7 +85,7 @@ def test_make_names_data_with_options(self): ( "@vagrant/centos7", { - "ssh_port": "2200", + "ssh_port": 2200, "ssh_user": "vagrant", "ssh_hostname": "127.0.0.1", "ssh_key": "path/to/key", @@ -109,7 +109,7 @@ def test_make_names_data_with_limit(self): ( "@vagrant/ubuntu16", { - "ssh_port": "2222", + "ssh_port": 2222, "ssh_user": "vagrant", "ssh_hostname": "127.0.0.1", "ssh_key": "path/to/key",