clojurepallet

/var/cache/debconf/config.dat-new: Permission denied


I'm getting debconf: DbDriver \"passwords\" warning: could not open /var/cache/debconf/passwords.dat: Permission denied\ndebconf: DbDriver \"config\": could not write /var/cache/debconf/config.dat-new: Permission denied\n#> [packages]: Packages : FAIL\n" when I run this. Looks like it isn't sudoing for whatever reason.

(ns localhost.idk
  (:require (pallet [compute :as compute]
                    [api :as api :refer [lift]]
                    [actions :as actions])))

;; Running this on my local machine
(def my-data-center
  (compute/instantiate-provider
   "node-list"
   :node-list [["localhost" "ed" "127.0.0.1" :ubuntu
                :is-64bit nil]]))

(def user-deadghost
  (api/make-user "deadghost"
                 :password "my-pw"
                 :sudo-password nil)) ; pwless sudo set up

(defn install-ed []
  (pallet.api/lift
   (pallet.api/group-spec
    "ed"
    :phases {:configure (api/plan-fn
                         ;; This works:
                         ;; (pallet.actions/exec-script
                         ;;  ("sudo aptitude install ed"))
                         ;; This is trying to run without sudo:
                          (actions/packages :aptitude ["ed"]))})                         
                         ;; log shows: p.script-builder prefix kw :no-sudo
   :compute my-data-center
   :user user-deadghost))

Script it's running:

#!/usr/bin/env bash
mkdir -p /home/deadghost || exit 1
cd /home/deadghost
set -h
echo '[packages]: Packages...';
{
    { debconf-set-selections <<EOF
debconf debconf/frontend select noninteractive
debconf debconf/frontend seen false
EOF
    } && enableStart() {
        rm /usr/sbin/policy-rc.d
    } && apt-get -q -y install ed+ && dpkg --get-selections
} || { echo '#> [packages]: Packages : FAIL'; exit 1;} >&2 
echo '#> [packages]: Packages : SUCCESS'

exit $?

The error I'm receiving is consistent with the debconf portion not having sudo.


Solution

  • Answer provided by hugod, author of pallet.

    As of pallet 0.8.0-RC.11 when running on localhost the default script prefix is :no-sudo when the default would otherwise be :sudo. This is for historical reasons I don't know the details about.

    To change the script prefix back to sudo, wrap your action with (pallet.action/with-action-options {:script-prefix :sudo} YOUR-ACTION-HERE). So in my case it will look like this:

    (defn install-ed []
      (pallet.api/lift
       (pallet.api/group-spec
        "ed"
        :phases {:configure (api/plan-fn
                             (pallet.action/with-action-options
                               {:script-prefix :sudo}
                               (actions/packages :aptitude ["ed"])))})
       :compute my-data-center
       :user user-deadghost))