openwisp / ansible-openwisp2

Ansible role that installs and upgrades OpenWISP.
https://openwisp.io/docs/dev/ansible/
BSD 3-Clause "New" or "Revised" License
474 stars 137 forks source link

error install source deadsnakes on bullseye #400

Open mikysal78 opened 2 years ago

mikysal78 commented 2 years ago

https://github.com/openwisp/ansible-openwisp2/blob/4f0a14825ccc7abfd9727391a0b2b9027a711d26/tasks/apt.yml#L143

i have this error:

ASK [openwisp.openwisp2: Add deadsnakes PPA] **************************************************************************************************************************************************************************************
Tuesday 13 September 2022  23:07:37 +0200 (0:00:03.758)       0:02:51.539 ***** 
fatal: [controller.nnxx.ninux.org]: FAILED! => changed=false 
  msg: 'Failed to update apt cache: E:The repository ''http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bullseye Release'' does not have a Release file.'

PLAY RECAP ******************************************************************************************************************************************************************************************************************************
controller.nnxx.ninux.org  : ok=46   changed=0    unreachable=0    failed=1    skipped=51   rescued=0    ignored=0   
emsu-io-suefke commented 1 year ago

Pull request to fix this issue: https://github.com/openwisp/ansible-openwisp2/pull/407

mikysal78 commented 1 year ago

Pull request to fix this issue: #407

When will the merge be done? As of today, if you don't have ubuntu, you can't upgrade or install!

mikysal78 commented 1 year ago

I tried after the merge but I get the same error. On my notebook i have os debian11.5 and i have this version of ansible (idem on server):

michele@mikytux:/git/new-server$ ansible --version
ansible [core 2.12.9]
  config file = /git/new-server/ansible.cfg
  configured module search path = ['/home/michele/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /git/new-server/collections
  executable location = /usr/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.0.3
  libyaml = True

my ansible.cfg is:

  michele@mikytux:/git/new-server$ more ansible.cfg 
[defaults]
module_set_locale=True
module_lang=it_IT.UTF-8
remote_port    = 2400
retry_files_enabled = False
nocows = 1

roles_path = roles
collections_paths = collections

ansible_managed = Ansible managed: modified on %d-%m-%Y

# Use the YAML callback plugin.
stdout_callback = yaml

# Display execution times
callback_whitelist = timer, profile_tasks

# Python interpreter discovery
interpreter_python = /usr/bin/python3
python_interprete = python3

# Fact gathering caching
gathering = smart
fact_caching = jsonfile
fact_caching_connection = .ansible_cache
fact_caching_timeout = 28800
emsu-io-suefke commented 1 year ago

Hello Michele,

if your python version = 3.9.2 , then no deadsnakes-ppa (newer Python versions for older systems) should be needed. What I did not understand yet: The system you are installing to (your Ansible -i hosts), what OS is that and is there an OS-provided python already installed? I have recently-ish (maybe 6 weeks ago) installed using Ansible on a virtual machine ( -i hosts ) that had been provided with a then-current Debian 11 installation and that had Python 3.9.2 on the target even before touching it with the OpenWISP playbook, entirely skipping the deadsnakes-ppa install.
The Ansible version you report shows 3.9.2, but as far as I understand
it, that is for
the install controller i.e. the host you start the Ansible playbook on (is there a name for that in Ansible lingo?) .
So, long question short: What is your installation target ?
Also, I guess you can ssh into the target before running the Ansible
playbook, what does  ''python3 --version''  say there?
Best regards,   Martin

On 22.10.22 21:31, Michele Salerno wrote:

|python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]|

mikysal78 commented 1 year ago

Hi, my hosts files (ansible -i hosts...) is this:

## Global Vars
[all:vars]
ansible_python_interpreter=/usr/bin/python3
ansible_port=2400

[common]
controller.nnxx.ninux.org ansible_user=root

[openwisp2]
controller.nnxx.ninux.org ansible_user=root 

[CaptivePortal]
wifi.nnxx.ninux.org ansible_user=root                           

[openvpn]
openvpn.nnxx.ninux.org ansible_user=root

[dns_server]
ns1-basilicata.ninux.org ansible_host=141.95.18.146
ns2-basilicata.ninux.org ansible_host=51.178.46.85

My notebook (where I run ansible playbook) is debian 11.5

ichele@mikytux:/git/new-server$ uname -a
Linux mikytux.basilicata.nnxx 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux
michele@mikytux:/git/new-server$ python3 --version
Python 3.9.2
michele@mikytux:/git/new-server$ ll /usr/bin/python*
lrwxrwxrwx 1 root root    9 Jul 28  2021 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3.5M Jul 14  2021 /usr/bin/python2.7
lrwxrwxrwx 1 root root    9 Apr  5  2021 /usr/bin/python3 -> python3.9
-rwxr-xr-x 1 root root 5.3M Feb 28  2021 /usr/bin/python3.9
lrwxrwxrwx 1 root root   33 Feb 28  2021 /usr/bin/python3.9-config -> x86_64-linux-gnu-python3.9-config
lrwxrwxrwx 1 root root   16 Apr  5  2021 /usr/bin/python3-config -> python3.9-config

on server (debian 11.5) (vps on ovh):

root@controller:~ # uname -a
Linux controller.nnxx.ninux.org 5.10.0-19-amd64 #1 SMP Debian 5.10.149-1 (2022-10-17) x86_64 GNU/Linux
root@controller:~ # python3 --version
Python 3.9.2
root@controller:~ # ll /usr/bin/python*
lrwxrwxrwx 1 root root    9 Apr  5  2021 /usr/bin/python3 -> python3.9
lrwxrwxrwx 1 root root   16 Apr  5  2021 /usr/bin/python3-config -> python3.9-config
-rwxr-xr-x 1 root root 5.3M Feb 28  2021 /usr/bin/python3.9
lrwxrwxrwx 1 root root   33 Feb 28  2021 /usr/bin/python3.9-config -> x86_64-linux-gnu-python3.9-config
mikysal78 commented 1 year ago

now try to cange line to file hosts from: controller.nnxx.ninux.org ansible_user=root to [openwisp2] controller.nnxx.ninux.org ansible_user=root ansible_python_interpreter=python3

bat:

TASK [openwisp.openwisp2 : Check installed python version] *****************************************************************************************************************************************************************************************
Monday 24 October 2022  19:38:34 +0200 (0:00:03.453)       0:03:16.545 ******** 
ok: [controller.nnxx.ninux.org]

TASK [openwisp.openwisp2 : Check openwisp2 should install python 3.7] ******************************************************************************************************************************************************************************
Monday 24 October 2022  19:38:37 +0200 (0:00:02.435)       0:03:18.980 ******** 
ok: [controller.nnxx.ninux.org]

TASK [openwisp.openwisp2 : Install software-properties-common] *************************************************************************************************************************************************************************************
Monday 24 October 2022  19:38:37 +0200 (0:00:00.114)       0:03:19.095 ******** 
ok: [controller.nnxx.ninux.org]

TASK [openwisp.openwisp2 : Add deadsnakes PPA] *****************************************************************************************************************************************************************************************************
Monday 24 October 2022  19:38:41 +0200 (0:00:03.849)       0:03:22.944 ******** 
fatal: [controller.nnxx.ninux.org]: FAILED! => changed=false 
  msg: 'Failed to update apt cache: E:The repository ''http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bullseye Release'' does not have a Release file.'
mikysal78 commented 1 year ago

Try to purge from apt python2.7 and reboot my notebook.

TASK [openwisp.openwisp2 : Check installed python version] *****************************************************************************************************************************************************************************************
Monday 24 October 2022  19:58:50 +0200 (0:00:02.779)       0:03:07.376 ******** 
ok: [controller.nnxx.ninux.org]

TASK [openwisp.openwisp2 : Check openwisp2 should install python 3.7] ******************************************************************************************************************************************************************************
Monday 24 October 2022  19:58:53 +0200 (0:00:02.577)       0:03:09.954 ******** 
ok: [controller.nnxx.ninux.org]

TASK [openwisp.openwisp2 : Install software-properties-common] *************************************************************************************************************************************************************************************
Monday 24 October 2022  19:58:53 +0200 (0:00:00.115)       0:03:10.069 ******** 
ok: [controller.nnxx.ninux.org]

TASK [openwisp.openwisp2 : Add deadsnakes PPA] *****************************************************************************************************************************************************************************************************
Monday 24 October 2022  19:58:56 +0200 (0:00:03.674)       0:03:13.743 ******** 
fatal: [controller.nnxx.ninux.org]: FAILED! => changed=false 
  msg: 'Failed to update apt cache: E:The repository ''http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bullseye Release'' does not have a Release file.'

PLAY RECAP *****************************************************************************************************************************************************************************************************************************************
controller.nnxx.ninux.org  : ok=47   changed=0    unreachable=0    failed=1    skipped=51   rescued=0    ignored=0   

Playbook run took 0 days, 0 hours, 4 minutes, 5 seconds
Monday 24 October 2022  19:59:48 +0200 (0:00:51.792)       0:04:05.535 ******** 
=============================================================================== 
openwisp.openwisp2 : Add deadsnakes PPA ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 51.79s
Stouts.postfix : Install requirements (Debian) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 27.68s
openwisp.influxdb : Restart influxdb ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 11.76s
Update APT package cache -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9.23s
Stouts.postfix : Configure postfix pt. 1 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 7.73s
openwisp.openwisp2 : Update APT package cache ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 6.66s
Gathering Facts ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 5.97s
openwisp.influxdb : Add influxdb key -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 5.04s
Stouts.postfix : Ensure Postfix is started -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 4.49s
openwisp.influxdb : Install gpg (update apt cache first) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 4.09s
geerlingguy.certbot : Ensure pre and post hook folders exist. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 4.06s
openwisp.influxdb : Install system dependencies --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 4.01s
openwisp.openwisp2 : Install postgresql client drivers -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3.89s
openwisp.influxdb : Install gpg-agent (update apt cache first) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 3.85s
openwisp.openwisp2 : Install redis ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3.83s
geerlingguy.certbot : Create post hook to start services. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3.80s
geerlingguy.certbot : Create pre hook to stop services. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3.78s
openwisp.openwisp2 : Install system packages ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 3.78s
Stouts.postfix : Configure postfix pt. 4 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3.78s
openwisp.openwisp2 : Install geographic libraries ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3.73s
michele@mikytux:/git/new-server$ ll /usr/bin/python*
lrwxrwxrwx 1 root root    9 Apr  5  2021 /usr/bin/python3 -> python3.9
-rwxr-xr-x 1 root root 5.3M Feb 28  2021 /usr/bin/python3.9
lrwxrwxrwx 1 root root   33 Feb 28  2021 /usr/bin/python3.9-config -> x86_64-linux-gnu-python3.9-config
lrwxrwxrwx 1 root root   16 Apr  5  2021 /usr/bin/python3-config -> python3.9-config

now is installed only python 3.9

mikysal78 commented 1 year ago

is normal when run:

- debug:
    msg: "Python version: {{ openwisp2_should_install_python_37 }}"

result is:

TASK [openwisp.openwisp2 : debug] ******************************************************************************************************************************************************************************************************************
Tuesday 25 October 2022  23:28:40 +0200 (0:00:00.296)       0:03:04.838 ******* 
ok: [controller.nnxx.ninux.org] => 
  msg: |-
    Python version: False
mikysal78 commented 1 year ago

I try comment task/apt.yml lines:

#    - name: Add deadsnakes PPA
#      apt_repository:
#        repo: ppa:deadsnakes/ppa
#        state: present

and now

TASK [openwisp.openwisp2 : Install Python 3.7] *****************************************************************************************************************************************************************************************************
Wednesday 26 October 2022  00:29:57 +0200 (0:00:03.607)       0:03:22.186 ***** 
FAILED - RETRYING: [controller.nnxx.ninux.org]: Install Python 3.7 (5 retries left).
FAILED - RETRYING: [controller.nnxx.ninux.org]: Install Python 3.7 (4 retries left).
FAILED - RETRYING: [controller.nnxx.ninux.org]: Install Python 3.7 (3 retries left).
FAILED - RETRYING: [controller.nnxx.ninux.org]: Install Python 3.7 (2 retries left).
FAILED - RETRYING: [controller.nnxx.ninux.org]: Install Python 3.7 (1 retries left).
fatal: [controller.nnxx.ninux.org]: FAILED! => changed=false 
  attempts: 5
  msg: No package matching 'python3.7' is available
...ignoring

want to install python3.7 when I have python 3.9? Something in the version control is wrong!

however for the ubuntu repo there is not exist bullseye. a 'ubuntu or other distribution' check is required ´``` The repository ''http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bullseye Release'' does not have a Release file.'

mikysal78 commented 1 year ago

@emsu-io-suefke i try modify the file apt.yml to:

- name: Should Install Python 3.7
  block:
    - name: Check installed python version
      command: "{{ openwisp2_python }} --version"
      register: openwisp2_installed_python
      changed_when: false
    - name: Check openwisp2 should install python 3.7
      set_fact:
        openwisp2_should_install_python_37: |
          {{ ansible_python_version is version_compare('3.7', 'le') }}

    - name: Check openwisp2 should install python 3.9
      set_fact:
        openwisp2_should_install_python_39: |
          {{ ansible_python_version is version_compare('3.9', 'ge') }}

- debug:
    msg: "Python version 37: {{ openwisp2_should_install_python_37 }}"
- debug:
    msg: "Python version 39: {{ openwisp2_should_install_python_39 }}"

- name: Install Python 3.7 and required packages from ppa:deadsnakes/ppa
  block:
    - name: Install software-properties-common
      apt:
        name:
          - software-properties-common
      ignore_errors: true
      retries: 5
      delay: 10
      register: result
      until: result is success
    - name: Add deadsnakes PPA
      apt_repository:
        repo: ppa:deadsnakes/ppa
        state: present
    - name: Install Python 3.7
      apt:
        name:
          - python3.7
          - python3.7-dev
          - python3.7-venv
      ignore_errors: true
      retries: 5
      delay: 10
      register: result
      until: result is success
    - name: Set python 3.7
      set_fact:
        openwisp2_python: python3.7
  when: openwisp2_should_install_python_37

- name: Install Python 3.9 and required packages
  block:
    - name: Install software-properties-common
      apt:
        name:
          - software-properties-common
      ignore_errors: true
      retries: 5
      delay: 10
      register: result
      until: result is success
    - name: Install Python 3.9
      apt:
        name:
          - python3.9
          - python3.9-dev
          - python3.9-venv
      ignore_errors: true
      retries: 5
      delay: 10
      register: result
      until: result is success
    - name: Set python 3.9
      set_fact:
        openwisp2_python: python3.9
  when: openwisp2_should_install_python_39

- name: Install python3 packages
  apt:
    name:
      - python3-pip
      - python3-dev
      - python3-virtualenv
  retries: 5
  delay: 10
  register: result
  until: result is success
  when:
    - not openwisp2_should_install_python_37
    - not openwisp2_should_install_python_39

On the debug i have this:

TASK [openwisp.openwisp2 : debug] ******************************************************************************************************************************************************************************************************************
Saturday 05 November 2022  00:16:49 +0100 (0:00:00.108)       0:03:32.269 ***** 
ok: [controller.nnxx.ninux.org] => 
  msg: |-
    Python version 37: False

TASK [openwisp.openwisp2 : debug] ******************************************************************************************************************************************************************************************************************
Saturday 05 November 2022  00:16:50 +0100 (0:00:00.112)       0:03:32.382 ***** 
ok: [controller.nnxx.ninux.org] => 
  msg: |-
    Python version 39: True

TASK [openwisp.openwisp2 : Install software-properties-common] *************************************************************************************************************************************************************************************
Saturday 05 November 2022  00:16:50 +0100 (0:00:00.102)       0:03:32.484 ***** 
ok: [controller.nnxx.ninux.org]

TASK [openwisp.openwisp2 : Add deadsnakes PPA] *****************************************************************************************************************************************************************************************************
Saturday 05 November 2022  00:16:53 +0100 (0:00:03.775)       0:03:36.260 ***** 
^C [ERROR]: User interrupted execution

how can this problem be solved?