Project

General

Profile

Bug #64488

Updated by Kefu Chai 3 months ago

upgrading cephadm package fails when going from distro package (16.x) to 18.2.1 provided by ceph.io repository 

 after debugging, there are multiple issues 

 
 * postinst script expects homedir of cephadm user in /home/cephadm and does not try to detect it (this is not compatible with debians `/var/lib/cephadm`) 
 (* postinst uses `mkdir /home/cephadm/.ssh` but this should not be fixed with `mkdir -p`) 
 * `adduser --quiet --system...` this does not create homedir for the user on debian bookworm 

 hotfix for installing cephadm package on debian bookworm is now to `useradd cephadm --system -m -d /home/cephadm` before installing cephadm package 

 <pre> ``` 
 jhrtestvm4[root](14:30:41)-(~) 
 -> adduser --system --shell /bin/bash testadduser 
 Adding system user `testadduser' (UID 112) ... 
 Adding new user `testadduser' (UID 112) with group `nogroup' ... 
 Not creating `/nonexistent'. 

 jhrtestvm4[root](14:31:30)-(~) 
 -> getent passwd | grep testadduser 
 testadduser:x:112:65534::/nonexistent:/bin/bash 

 ``` 

 ``` 
 </pre> 


 <pre> 
 Setting up cephadm (18.2.1-1~bpo12+1) ... 
 usermod: unlocking the user's password would result in a passwordless account. 
 You should set a password with usermod -p to unlock this user's password. 
 mkdir: cannot create directory '/home/cephadm/.ssh': No such file or directory 
 dpkg: error processing package cephadm (--configure): 
  installed cephadm package post-installation script subprocess returned error exit status 1 
 Errors were encountered while processing: 
  cephadm 
 W: --force-yes is deprecated, use one of the options starting with --allow instead. 
 E: Sub-process /usr/bin/dpkg returned an error code (1) (corrective) 
 </pre> ``` 


 @/var/lib/dpkg/info/cephadm.postinst@ 

 <pre> `/var/lib/dpkg/info/cephadm.postinst` 
 ``` 
 case "$1" in 
     configure) 
        # create cephadm user 
        # 1. create user if not existing 
        if ! getent passwd | grep -q "^cephadm:"; then 
          echo -n "Adding system user cephadm.." 
          adduser --quiet --system --disabled-password --gecos 'cephadm user for mgr/cephadm' --shell /bin/bash cephadm 2>/dev/null || true 
          echo "..done" 
        fi 

        # 2. make sure user is unlocked 
        if [ -f /etc/shadow ]; then 
            usermod -U -e '' cephadm 
        else 
            usermod -U cephadm 
        fi 

        # set up (initially empty) .ssh/authorized_keys file 
        if ! test -d /home/cephadm/.ssh; then 
            mkdir /home/cephadm/.ssh 
            chown --reference /home/cephadm /home/cephadm/.ssh 
            chmod 0700 /home/cephadm/.ssh 
        fi 
        if ! test -e /home/cephadm/.ssh/authorized_keys; then 
            touch /home/cephadm/.ssh/authorized_keys 
            chown --reference /home/cephadm /home/cephadm/.ssh/authorized_keys 
            chmod 0600 /home/cephadm/.ssh/authorized_keys 
        fi 

     ;; 
     abort-upgrade|abort-remove|abort-deconfigure) 
         : 
     ;; 

     *) 
         echo "postinst called with unknown argument \`$1'" >&2 
         exit 1 
     ;; 
 esac 
 </pre> 


 

 ``` 

Back