Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix automated-admin-user to take defaults from session :user

  • Loading branch information...
commit 887b590bc3c134684b28527225c4602e7b9a8f73 1 parent d59317a
@hugoduncan hugoduncan authored
View
11 automated-admin-user/src/pallet/crate/automated_admin_user.clj
@@ -3,6 +3,7 @@
[pallet.action.user :as user]
[pallet.crate.ssh-key :as ssh-key]
[pallet.utils :as utils]
+ [pallet.session :as session]
[pallet.thread-expr :as thread-expr]
[pallet.crate.sudoers :as sudoers]))
@@ -11,13 +12,11 @@
permission to sudo without password, so that passwords don't have to appear
in scripts, etc."
([session]
- (automated-admin-user
- session
- (:username utils/*admin-user*)
- (:public-key-path utils/*admin-user*)))
+ (let [user (or (session/admin-user session) utils/*admin-user*)]
+ (automated-admin-user session (:username user) (:public-key-path user))))
([session username]
- (automated-admin-user
- session username (:public-key-path utils/*admin-user*)))
+ (let [user (or (session/admin-user session) utils/*admin-user*)]
+ (automated-admin-user session username (:public-key-path user))))
([session username & public-key-paths]
(->
session
View
47 automated-admin-user/test/pallet/crate/automated_admin_user_test.clj
@@ -3,10 +3,16 @@
(:require
[pallet.build-actions :as build-actions]
[pallet.action :as action]
+ [pallet.action.exec-script :as exec-script]
[pallet.action.user :as user]
+ [pallet.core :as core]
+ [pallet.crate.automated-admin-user :as automated-admin-user]
[pallet.crate.ssh-key :as ssh-key]
[pallet.crate.sudoers :as sudoers]
- pallet.utils)
+ [pallet.live-test :as live-test]
+ [pallet.phase :as phase]
+ [pallet.utils :as utils]
+ [clojure.contrib.logging :as logging])
(:use
clojure.test
pallet.test-utils))
@@ -70,5 +76,44 @@
user-name (slurp (pallet.utils/default-public-key-path)))))
(first
(build-actions/build-actions
+ {:user (utils/make-user user-name)}
+ (automated-admin-user)))))))
+ (testing "with session username"
+ (let [user-name "fredxxx"]
+ (is (= (first
+ (build-actions/build-actions
{}
+ (sudoers/install)
+ (user/user user-name :create-home true :shell :bash)
+ (sudoers/sudoers
+ {} {} {user-name {:ALL {:run-as-user :ALL :tags :NOPASSWD}}})
+ (ssh-key/authorize-key
+ user-name (slurp (pallet.utils/default-public-key-path)))))
+ (first
+ (build-actions/build-actions
+ {:user (utils/make-user user-name)}
(automated-admin-user))))))))
+
+(deftest live-test
+ ;; tests a node specific admin user
+ (live-test/test-for
+ [image (live-test/images)]
+ (logging/trace
+ (format "automated-admin-user live test: image %s" (pr-str image)))
+ (live-test/test-nodes
+ [compute node-map node-types]
+ {:pgtest
+ (->
+ (core/server-spec
+ :phases {:bootstrap (phase/phase-fn
+ (automated-admin-user/automated-admin-user))
+ :verify (phase/phase-fn
+ (exec-script/exec-checked-script
+ "check automated admin user functional"
+ (pipe (echo @SUDO_USER) (grep "fred"))))}
+ :count 1
+ :node-spec (core/node-spec :image image)
+ :environment {:user {:username "fred"}}))}
+ (is
+ (core/lift
+ (val (first node-types)) :phase [:verify] :compute compute)))))
View
16 pom.xml
@@ -241,7 +241,7 @@
<dependency>
<groupId>org.cloudhoist</groupId>
<artifactId>java</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.cloudhoist</groupId>
@@ -301,7 +301,7 @@
<dependency>
<groupId>org.cloudhoist</groupId>
<artifactId>postgres</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.6.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.cloudhoist</groupId>
@@ -356,7 +356,7 @@
<dependency>
<groupId>org.cloudhoist</groupId>
<artifactId>ssh-key</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.cloudhoist</groupId>
@@ -376,7 +376,7 @@
<dependency>
<groupId>org.cloudhoist</groupId>
<artifactId>tomcat</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.6.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.cloudhoist</groupId>
@@ -396,12 +396,12 @@
<dependency>
<groupId>org.cloudhoist</groupId>
<artifactId>zeromq</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.cloudhoist</groupId>
<artifactId>zookeeper</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.2-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
@@ -487,7 +487,7 @@
</repositories>
<properties>
- <pallet.version>0.5.1-SNAPSHOT</pallet.version>
- <jclouds.version>1.0-beta-9c</jclouds.version>
+ <pallet.version>0.6.2-SNAPSHOT</pallet.version>
+ <jclouds.version>1.0.0</jclouds.version>
</properties>
</project>
Please sign in to comment.
Something went wrong with that request. Please try again.