aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk>2015-03-12 15:01:06 +0000
committerNathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk>2015-03-12 15:01:06 +0000
commit0cc3c651aac4ebcee5ce9f9f36cc23863b8d753c (patch)
tree2de79185f5d689ca7407ff2e3c8cb3b556b58fbd
Initial commit
-rw-r--r--Makefile12
-rw-r--r--README15
-rw-r--r--inventory1
-rw-r--r--keys/global/.gitkeepdirs0
-rw-r--r--playbook.yml18
5 files changed, 46 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..fefafa3
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@
+ifdef LIMIT
+ ARGS += -l $(LIMIT)
+endif
+
+ifndef INVENTORY
+ ARGS += -i inventory
+else
+ ARGS += -i $(INVENTORY)
+endif
+
+all: inventory playbook.yml
+ ansible-playbook playbook.yml $(ARGS)
diff --git a/README b/README
new file mode 100644
index 0000000..8f66c73
--- /dev/null
+++ b/README
@@ -0,0 +1,15 @@
+Okay, so this is simple.
+
+1. populate the inventory file with hosts and the username to add like this:
+
+myhost username=myname
+theirhost username=theirname
+theirhost username=myname
+
+2. Add any ssh keys required to the keys directory, one key per file, as myname.pub.
+
+2a. If you want to add a key to all users, stick it in the keys/global/ directory.
+
+3. make
+
+3a. make can take LIMIT= or INVENTORY= arguments
diff --git a/inventory b/inventory
new file mode 100644
index 0000000..e0baaa3
--- /dev/null
+++ b/inventory
@@ -0,0 +1 @@
+myhost username=myname
diff --git a/keys/global/.gitkeepdirs b/keys/global/.gitkeepdirs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/keys/global/.gitkeepdirs
diff --git a/playbook.yml b/playbook.yml
new file mode 100644
index 0000000..6a4bdd5
--- /dev/null
+++ b/playbook.yml
@@ -0,0 +1,18 @@
+---
+- hosts: all
+ sudo: yes
+ tasks:
+ - name: Create user
+ user: name={{ username }}
+
+ - name: Upload user key
+ authorized_key: user={{ username }}
+ key="{{ item }}"
+ with_file:
+ - keys/{{ username }}.pub
+
+ - name: Upload global keys
+ authorized_key: user={{ username }}
+ key="{{ lookup('file', item) }}"
+ with_fileglob:
+ - keys/global/*.pub