-
Notifications
You must be signed in to change notification settings - Fork 78
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
molecule login results in "Bad port '{port}'" #239
Comments
…nja in the ec2 login_cmd_template This file assumes Jinja templating for the port parameter and passes a Jinja-style "{{ port }}". https://github.com/ansible/molecule/blob/main/src/molecule/command/login.py#L105 When it reaches molecule, it is subsituted in this file and is done by python calling `.format()` on the string. That causes it to not render correctly and gives users issues running molecule login. ref: ansible-community#239
Ran into it as well. The problem is here: This file assumes Jinja templating for the port parameter and passes a Jinja-style "{{ port }}". https://github.com/ansible/molecule/blob/main/src/molecule/command/login.py#L105 ^ Now this happens in this file and is done by python calling I submitted an MR here to fix this up: #240 |
@danielpodwysocki - Glad it's not just me. Appreciate the MR. |
reproduced using vagrant + virtualbox. $ molecule login -s almalinux --host almalinux8
WARNING Driver vagrant does not provide a schema.
WARNING Driver vagrant does not provide a schema.
WARNING Driver docker does not provide a schema.
WARNING Driver vagrant does not provide a schema.
WARNING Driver vagrant does not provide a schema.
WARNING Driver vagrant does not provide a schema.
WARNING Driver vagrant does not provide a schema.
INFO Running almalinux > login
Bad port '{port}'
$ ssh -i [...]/ansible-role-hardening/almalinux/.vagrant/machines/almalinux8/virtualbox/private_key [email protected] -p2222
By accessing this system, you consent to the following conditions:
- This system is for authorized use only.
- Any or all uses of this system and all files on this system may be monitored.
- Communications using, or data stored on, this system are not private.
Last login: Fri Feb 16 11:21:52 2024 from 10.0.2.2
[vagrant@almalinux8 ~]$ # Molecule managed
---
all:
hosts:
almalinux8: &id001
ansible_host: 127.0.0.1
ansible_port: '2222'
ansible_private_key_file: [...]/.cache/molecule/ansible-role-hardening/almalinux/.vagrant/machines/almalinux8/virtualbox/private_key
ansible_ssh_common_args: -o UserKnownHostsFile=/dev/null -o ControlMaster=auto
-o ControlPersist=60s -o ForwardX11=no -o LogLevel=ERROR -o IdentitiesOnly=yes
-o StrictHostKeyChecking=no
ansible_user: vagrant
connection: ssh
almalinux9: &id002
ansible_host: 127.0.0.1
ansible_port: '2200'
ansible_private_key_file: [...]/.cache/molecule/ansible-role-hardening/almalinux/.vagrant/machines/almalinux9/virtualbox/private_key
ansible_ssh_common_args: -o UserKnownHostsFile=/dev/null -o ControlMaster=auto
-o ControlPersist=60s -o ForwardX11=no -o LogLevel=ERROR -o IdentitiesOnly=yes
-o StrictHostKeyChecking=no
ansible_user: vagrant
connection: ssh
vars:
molecule_ephemeral_directory: '{{ lookup(''env'', ''MOLECULE_EPHEMERAL_DIRECTORY'')
}}'
molecule_file: '{{ lookup(''env'', ''MOLECULE_FILE'') }}'
molecule_instance_config: '{{ lookup(''env'', ''MOLECULE_INSTANCE_CONFIG'') }}'
molecule_no_log: '{{ lookup(''env'', ''MOLECULE_NO_LOG'') or not molecule_yml.provisioner.log|default(False)
| bool }}'
molecule_scenario_directory: '{{ lookup(''env'', ''MOLECULE_SCENARIO_DIRECTORY'')
}}'
molecule_yml: '{{ lookup(''file'', molecule_file) | from_yaml }}'
ungrouped:
hosts:
almalinux8: *id001
almalinux9: *id002
vars: {}
|
I am seeing this issue crop up in 23.5.3 where molecule login fails with the Bad Port error mentioned above. However, this does not occur with version 23.5.0. I do not see any difference in the code for molecule login between these two versions. Is this a regression bug and was it in 23.5.0? |
…nja in all drivers login_cmd_template This file assumes Jinja templating for the port parameter and passes a Jinja-style "{{ port }}". https://github.com/ansible/molecule/blob/main/src/molecule/command/login.py#L105 When it reaches molecule, it is subsituted in this file and is done by python calling `.format()` on the string. That causes it to not render correctly and gives users issues running molecule login. ref: ansible-community#239 Fixed all affected plugins.
I updated the PR to cover all plugins, it seems this affects each one of them. |
Seeing this as well with the GCE driver. |
Thanks for the analysis and fix. I applied the change you posted in the PR for the vagrant driver and all is now working. |
…nja in all drivers login_cmd_template This file assumes Jinja templating for the port parameter and passes a Jinja-style "{{ port }}". https://github.com/ansible/molecule/blob/main/src/molecule/command/login.py#L105 When it reaches molecule, it is subsituted in this file and is done by python calling `.format()` on the string. That causes it to not render correctly and gives users issues running molecule login. ref: ansible-community#239 Fixed all affected plugins.
It seems that molecule dropped support for init (see ansible/molecule#4042), so I downgraded to molecule 5.1 and everything worked fine. However, as suggested from IRC I tried to upgrade molecule and removed the files created on initialization of scenario ( #239 fixes this issue with the last version of molecule, but then it fails with molecule 5.1. |
You could see how I patch it for DEB/RPM |
…nja in all drivers login_cmd_template This file assumes Jinja templating for the port parameter and passes a Jinja-style "{{ port }}". https://github.com/ansible/molecule/blob/main/src/molecule/command/login.py#L105 When it reaches molecule, it is subsituted in this file and is done by python calling `.format()` on the string. That causes it to not render correctly and gives users issues running molecule login. ref: ansible-community#239 Fixed all affected plugins.
…nja in all drivers login_cmd_template This file assumes Jinja templating for the port parameter and passes a Jinja-style "{{ port }}". https://github.com/ansible/molecule/blob/main/src/molecule/command/login.py#L105 When it reaches molecule, it is subsituted in this file and is done by python calling `.format()` on the string. That causes it to not render correctly and gives users issues running molecule login. ref: ansible-community#239 Fixed all affected plugins.
@apatard any chance to release this? last GA is now 10 months old. |
I can confirm fdc748f fixes the problem. Any chance to release 🙏 ? |
Using Molecule on MacOS ventura 13.6.4
This seems to be a new issue for me, but when using molecule to test against a remote EC2 instance, when I run "molecule login -s my_scenario", I get
Bad port '{port}'
Molecule converge seems to work fine.
Scenario specific configuration:
ansible_inventory.yml
ansible.cfg
instance_config.yml
molecule.yml
I can use the ssh key defined in the inventory along with the ip address and SSH into the instance manually with no issues.
The text was updated successfully, but these errors were encountered: