diff options
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | README | 15 | ||||
-rw-r--r-- | inventory | 1 | ||||
-rw-r--r-- | keys/global/.gitkeepdirs | 0 | ||||
-rw-r--r-- | playbook.yml | 18 |
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) @@ -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 |