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 Debian 7 backend #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Debian 7 backend #3

wants to merge 1 commit into from

Conversation

tchatow
Copy link

@tchatow tchatow commented Nov 19, 2024

No description provided.

@olegbck
Copy link
Collaborator

olegbck commented Nov 19, 2024

Instead of introducing net_backend, let's do this:

  1. Rename VM_TYPE_LINUX to VM_TYPE_UBUNTU = "ubuntu".
  2. Add VM_TYPE_DEBIAN = "debian".
  3. In the new set_network_interface_ip() of LinuxVM check for vm_type. If vm_type is VM_TYPE_UBUNTU, call set_network_interface_ip_netplan(). If vm_type is VM_TYPE_DEBIAN, call set_network_interface_ip_ifupdown().
  4. Rename type: "linux" to type: "ubuntu" in all Ubuntu blueprints
  5. Don't forget about changes in every part of the code, that is using VM_TYPE_LINUX.

This way we won't be exposing any details about the network interface.

Copy link
Collaborator

@olegbck olegbck left a comment

Choose a reason for hiding this comment

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

The changes don't work on my side. I first had SSH connection issues that were solved in the comment below. Then I had this error:

fatal: [debian1]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "failed": true, "module_stderr": "Shared connection to 127.0.0.1 closed.\r\n", "module_stdout": "/bin/sh: 1: /usr/bin/python3: not found\r\n", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127, "warnings": ["No python interpreters found for host debian1 (tried ['python3.12', 'python3.11', 'python3.10', 'python3.9', 'python3.8', 'python3.7', '/usr/bin/python3', 'python3'])"]}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}

Okay, so I added ansible_python_interpreter=/usr/bin/python to the inventory.ini file, but now I see a much bigger problem when I try to run ansible-playbook for CVEX/ansible/linux_router.yml:

fatal: [debian1]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"exception": "Traceback (most recent call last):\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1732197050.687829-265310-66440703984384/AnsiballZ_setup.py", line 107, in \r\n _ansiballz_main()\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1732197050.687829-265310-66440703984384/AnsiballZ_setup.py", line 99, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1732197050.687829-265310-66440703984384/AnsiballZ_setup.py", line 44, in invoke_module\r\n from ansible.module_utils import basic\r\n File "/tmp/ansible_ansible.legacy.setup_payload_x_lYCY/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/basic.py", line 17\r\n msg=f"ansible-core requires a minimum of Python version {'.'.join(map(str, _PY_MIN))}. Current version: {''.join(sys.version.splitlines())}",\r\n ^\r\nSyntaxError: invalid syntax\r\n", "failed": true, "module_stderr": "Shared connection to 127.0.0.1 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1732197050.687829-265310-66440703984384/AnsiballZ_setup.py", line 107, in \r\n _ansiballz_main()\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1732197050.687829-265310-66440703984384/AnsiballZ_setup.py", line 99, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File "/home/vagrant/.ansible/tmp/ansible-tmp-1732197050.687829-265310-66440703984384/AnsiballZ_setup.py", line 44, in invoke_module\r\n from ansible.module_utils import basic\r\n File "/tmp/ansible_ansible.legacy.setup_payload_x_lYCY/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/basic.py", line 17\r\n msg=f"ansible-core requires a minimum of Python version {'.'.join(map(str, _PY_MIN))}. Current version: {''.join(sys.version.splitlines())}",\r\n ^\r\nSyntaxError: invalid syntax\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}

Does it actually work on your side? What's the trick?

@@ -56,7 +56,7 @@ def get_ansible_inventory(self) -> Path:
f"ansible_port={self.vag.port()} "
f"ansible_user={self.vag.user()} "
f"ansible_ssh_private_key_file={self.vag.keyfile()} "
f"ansible_ssh_common_args='-o StrictHostKeyChecking=no'")
f"ansible_ssh_common_args='-o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-rsa'")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't seem to be enough. I had to add also these parameters to overcome SSH connection issues:
-o PubkeyAcceptedKeyTypes=+ssh-rsa -o UserKnownHostsFile=/dev/null

Copy link
Author

Choose a reason for hiding this comment

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

What version of ansible are you using?

Copy link
Collaborator

Choose a reason for hiding this comment

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

$ ansible --version
ansible [core 2.17.1]

$ apt list | grep ansible

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

ansible-core/jammy-updates,jammy-updates 2.12.0-1ubuntu0.1 all
ansible-lint/jammy,jammy 5.4.0-2 all
ansible-mitogen/jammy,jammy 0.3.1-3 all
ansible/jammy,jammy 2.10.7+merged+base+2.10.8+dfsg-1 all
python-ansible-runner-doc/jammy,jammy 2.1.1-1 all
python-networking-ansible-doc/jammy,jammy 17.0.0-2 all
python3-ansible-runner/jammy,jammy 2.1.1-1 all
python3-networking-ansible/jammy,jammy 17.0.0-2 all

Copy link
Author

Choose a reason for hiding this comment

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

Ok, it appears Ansible 2.17 dropped Python 2.7. So we would need some other process to bootstrap this system. This actually seems like a rather significant limitation for reproducibility - for instance as Ubuntu 22 becomes out of date.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. We may need our own custom version of Debian 7 box with Python3 pre-installed in it. I'll take care of that.

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