spantaleev / matrix-docker-ansible-deploy

🐳 Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker
GNU Affero General Public License v3.0
4.92k stars 1.05k forks source link

python3-apt must be installed and visible from /usr/bin/python. #2301

Open Taubin opened 1 year ago

Taubin commented 1 year ago

Playbook Configuration:

My vars.yml file looks like this:

---
# The bare domain name which represents your Matrix identity.
# Matrix user ids for your server will be of the form (`@user:<matrix-domain>`).
#
# Note: this playbook does not touch the server referenced here.
# Installation happens on another server ("matrix.<matrix-domain>").
#
# If you've deployed using the wrong domain, you'll have to run the Uninstalling step,
# because you can't change the Domain after deployment.
#
# Example value: example.com
matrix_domain: [redacted]

# The Matrix homeserver software to install.
# See:
#  - `roles/custom/matrix-base/defaults/main.yml` for valid options
# - the `docs/configuring-playbook-IMPLEMENTATION_NAME.md` documentation page, if one is available for your implementation choice
matrix_homeserver_implementation: synapse

# A secret used as a base, for generating various other secrets.
# You can put any string here, but generating a strong one is preferred (e.g. `pwgen -s 64 1`).
matrix_homeserver_generic_secret_key: '[redacted]'

# This is something which is provided to Let's Encrypt when retrieving SSL certificates for domains.
#
# In case SSL renewal fails at some point, you'll also get an email notification there.
#
# If you decide to use another method for managing SSL certificates (different than the default Let's Encrypt),
# you won't be required to define this variable (see `docs/configuring-playbook-ssl-certificates.md`).
#
# Example value: someone@example.com
matrix_ssl_lets_encrypt_support_email: '[redacted]'

# A Postgres password to use for the superuser Postgres user (called `matrix` by default).
#
# The playbook creates additional Postgres users and databases (one for each enabled service)
# using this superuser account.
devture_postgres_connection_password: '[redacted]'

Matrix Server:

Ansible: If your problem appears to be with Ansible, tell us:

ansible [core 2.14.0]
  config file = None
  configured module search path = ['/home/taubin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/taubin/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/taubin/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/taubin/.local/bin/ansible
  python version = 3.10.8 (main, Oct 12 2022, 19:14:09) [GCC 7.5.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Problem description:

Running the playbook to upgrade, I receive the following error:

python3-apt must be installed and visible from /usr/bin/python.

Full output:

~/matrix-docker-ansible-deploy$ ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,ensure-matrix-users-created,start

PLAY [Set up a Matrix server] ********************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************
ok: [matrix.[redacted]]

TASK [custom/matrix_playbook_migration : ansible.builtin.include_tasks] **************************************************************************************************
included: /home/taubin/matrix-docker-ansible-deploy/roles/custom/matrix_playbook_migration/tasks/validate_config.yml for matrix.[redacted]

TASK [custom/matrix_playbook_migration : (Deprecation) Catch and report renamed Matrix playbook settings] ****************************************************************
skipping: [matrix.[redacted]] => (item={'old': 'matrix_vars_yml_snapshotting_enabled', 'new': 'devture_playbook_state_preserver_vars_preservation_enabled'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_vars_yml_snapshotting_src', 'new': 'devture_playbook_state_preserver_vars_preservation_src'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_playbook_commit_hash_preservation_enabled', 'new': 'devture_playbook_state_preserver_commit_hash_preservation_enabled'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_ntpd_package', 'new': 'devture_timesync_ntpd_package'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_ntpd_service', 'new': 'devture_timesync_ntpd_service'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_systemd_unit_home_path', 'new': 'devture_systemd_docker_base_systemd_unit_home_path'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_systemd_path', 'new': 'devture_systemd_docker_base_systemd_path'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_host_command_docker', 'new': 'devture_systemd_docker_base_host_command_docker'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_host_command_sh', 'new': 'devture_systemd_docker_base_host_command_sh'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_host_command_systemctl', 'new': 'devture_systemd_docker_base_host_command_systemctl'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_container_retries_count', 'new': 'devture_playbook_help_container_retries_count'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_container_retries_delay', 'new': 'devture_playbook_help_container_retries_delay'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_geturl_retries_count', 'new': 'devture_playbook_help_geturl_retries_count'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_geturl_retries_delay', 'new': 'devture_playbook_help_geturl_retries_delay'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_nginx_proxy_synapse_cache_path', 'new': 'matrix_synapse_reverse_proxy_companion_synapse_cache_path'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_nginx_proxy_synapse_cache_enabled', 'new': 'matrix_synapse_reverse_proxy_companion_synapse_cache_enabled'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_docker_installation_enabled', 'new': 'matrix_playbook_docker_installation_enabled'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_docker_package_name', 'new': '<Not applicable. Docker is installed using https://github.com/geerlingguy/ansible-role-docker now>'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_systemd_services_list', 'new': 'devture_systemd_service_manager_services_list_additional'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_common_after_systemd_service_start_wait_for_timeout_seconds', 'new': 'devture_systemd_service_manager_up_verification_delay_seconds'})
skipping: [matrix.[redacted]] => (item={'old': 'matrix_systemd_services_autostart_enabled', 'new': 'devture_systemd_service_manager_services_autostart_enabled'})
skipping: [matrix.[redacted]]

TASK [custom/matrix_playbook_migration : (Deprecation) Catch and report matrix_postgres variables] ***********************************************************************
skipping: [matrix.[redacted]]

TASK [custom/matrix_playbook_migration : ansible.builtin.include_tasks] **************************************************************************************************
included: /home/taubin/matrix-docker-ansible-deploy/roles/custom/matrix_playbook_migration/tasks/cleanup_usr_local_bin.yml for matrix.[redacted]

TASK [custom/matrix_playbook_migration : Find leftover matrix scripts in /usr/local/bin] *********************************************************************************
ok: [matrix.[redacted]]

TASK [custom/matrix_playbook_migration : Ensure /usr/local/bin does not contain matrix scripts] **************************************************************************
skipping: [matrix.[redacted]]

TASK [galaxy/geerlingguy.docker : Load OS-specific vars.] ****************************************************************************************************************
ok: [matrix.[redacted]]

TASK [galaxy/geerlingguy.docker : include_tasks] *************************************************************************************************************************
skipping: [matrix.[redacted]]

TASK [galaxy/geerlingguy.docker : include_tasks] *************************************************************************************************************************
included: /home/taubin/matrix-docker-ansible-deploy/roles/galaxy/geerlingguy.docker/tasks/setup-Debian.yml for matrix.[redacted]

TASK [galaxy/geerlingguy.docker : Ensure old versions of Docker are not installed.] **************************************************************************************
[WARNING]: Updating cache and auto-installing missing dependency: python3-apt
fatal: [matrix.[redacted]]: FAILED! => changed=false
  msg: python3-apt must be installed and visible from /usr/bin/python.

PLAY RECAP ***************************************************************************************************************************************************************
matrix.[redacted]           : ok=6    changed=0    unreachable=0    failed=1    skipped=4    rescued=0    ignored=0

My hosts file is below:

# We explicitly ask for your server's external IP address, because the same value is used for configuring Coturn.
# If you'd rather use a local IP here, make sure to set up `matrix_coturn_turn_external_ip_address`.
#
# To connect using a non-root user (and elevate to root with sudo later),
# replace `ansible_ssh_user=root` with something like this: `ansible_ssh_user=username become=true become_user=root`
#
# For improved Ansible performance, SSH pipelining is enabled by default in `ansible.cfg`.
# If this causes SSH connection troubles, disable it by adding `ansible_ssh_pipelining=False`
# to the host line below or by adding `ansible_ssh_pipelining: False` to your variables file.
#
# If you're running this Ansible playbook on the same server as the one you're installing to,
# consider adding an additional `ansible_connection=local` argument to the host line below.
#
# Ansible may fail to discover which Python interpreter to use on the host for some distros (like Ubuntu 20.04).
# You may sometimes need to explicitly add the argument `ansible_python_interpreter=/usr/bin/python3`
# to the host line below.

[matrix_servers]
matrix.[redacted] ansible_host=[redacted] ansible_ssh_user=[redacted] become=true become_user=root ansible_connection=local ansible_python_interpreter=/usr/bin/python

Python3-apt is installed:

sudo apt-get install python3-apt --reinstall
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/149 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 105589 files and directories currently installed.)
Preparing to unpack .../python3-apt_1.6.5ubuntu0.7_amd64.deb ...
Unpacking python3-apt (1.6.5ubuntu0.7) over (1.6.5ubuntu0.7) ...
Setting up python3-apt (1.6.5ubuntu0.7) ...
/usr/lib/python3.10/subprocess.py:955: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
  self.stdin = io.open(p2cwrite, 'wb', bufsize)

Describe what you're doing, what you expect to happen and what happens instead here. Tell us what you've tried and what you're aiming to achieve.

I am attempting to upgrade my installation using the instructions here

I haven't upgraded in a while so it's entirely possible it's something dumb I'm missing and if so I sincerely apologize. I have tried googling to fix this on my own, however the answers I've found have not worked. Including reinstalling pip, reinstalling apt and adding a symlink: sudo cp apt_pkg.cpython-34m-i386-linux-gnu.so apt_pkg.so

Additional context Add any other context about the problem here.

spantaleev commented 1 year ago

Reading here may help: https://stackoverflow.com/questions/51622712/ansible-requires-python-apt-but-its-already-installed

You can try ansible_python_interpreter=/usr/bin/python3 in your hosts file, instead of using /usr/bin/python.

You can SSH into the server and see what /usr/bin/python --version and what /usr/bin/python3 --version say.

Taubin commented 1 year ago

Thank you for that, it's at least gotten me a step farther:

ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,ensure-matrix-users-created,start

PLAY [Set up a Matrix server] ********************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************************
fatal: [matrix.[redacted]]: FAILED! => changed=false
  ansible_facts: {}
  failed_modules:
    ansible.legacy.setup:
      failed: true
      module_stderr: |-
        sudo: a password is required
      module_stdout: ''
      msg: |-
        MODULE FAILURE
        See stdout/stderr for the exact error
      rc: 1
  msg: |-
    The following modules failed to execute: ansible.legacy.setup

PLAY RECAP ***************************************************************************************************************************************************************
matrix.[redacted]           : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
Taubin commented 1 year ago

Removed become=true user=sudo

Unfortunately I'm running into the same error after changing /usr/bin/python to /usr/bin/python3

nukeop commented 10 months ago

I'm getting this same error after an update. Did you manage to fix it somehow? The package is installed and visible from python3, making this very confusing.