        (map :file)
        last))
 
-(defn install-terminus-into [puppet-dir]
-  ;; various pieces of the terminus have to actually be inside of puppet itself to work
-  (let [base-dir "puppet"
-        base-uri (.toURI (io/file base-dir))
-        terminus-files (->> (fs/find-files base-dir #".*")
-                            (filter #(.isFile %))
-                            (map #(-> (.relativize base-uri (.toURI %))
-                                      .getPath)))]
-    (doseq [relative-path terminus-files]
-      (let [in (str base-dir "/" relative-path)
-            out (str puppet-dir "/" relative-path)]
-        (println "Copying puppetdb terminus file" in "to" out)
-        (fs/copy+ in out)))))
-
 (defn puppet-server-config-with-name [node-name]
   {:main {:certname "localhost"}
    :agent {:server "localhost"}

              (assoc opts :certname certname)))

(defn run-puppet-node-deactivate [pdb-server certname-to-deactivate]
  (install-terminus-into (mri-agent-dir))
  (with-synchronized-command-processing pdb-server 1 tu/default-timeout-ms
    (bundle-exec {}
                 "puppet" "node" "deactivate"
                 "--confdir" "target/puppetserver/master-conf"
                 "--color" "false"
                 certname-to-deactivate)))

(defn run-puppet-node-status [pdb-server certname]
  (install-terminus-into (mri-agent-dir))
  (bundle-exec {}
               "puppet" "node" "status" certname
               "--confdir" "target/puppetserver/master-conf"
               "--color" "false"))

(defn run-puppet-facts-find [puppet-server certname]
  (let [{:keys [conf-dir]} (server-info puppet-server)]
    (-> (bundle-exec {}
                     "puppet" "facts" "find" certname
                     "--confdir" conf-dir
                     "--terminus" "puppetdb")
        :out
        json/parse-string)))


      (apply bundle-exec env
             "puppet" "apply" (.getCanonicalPath manifest-file)
             "--confdir" (.getCanonicalPath agent-conf-dir)
             "--vardir" "puppet"
             extra-puppet-args))))

(def date-formatter (tfmt/formatters :date-time))
