Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
5146e3d0
Commit
5146e3d0
authored
Jul 01, 2014
by
John Jarvis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add and remove ubuntu public keys
parent
0bf4d71c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
playbooks/edx-east/add-ubuntu-key.yml
+32
-0
playbooks/edx-east/remove-ubuntu-key.yml
+28
-0
No files found.
playbooks/edx-east/add-ubuntu-key.yml
0 → 100644
View file @
5146e3d0
# A simple utility play to add a public key to the authorized key
# file for the ubuntu user.
# You must pass in the entire line that you are adding.
# Example: ansible-playbook add-ubuntu-key.yml -c local -i 127.0.0.1, \
# -e "public_key='ssh-rsa SOME_PUBLIC_KEY deployment-201407'" \
# -e owner=jarv -e keyfile=/home/jarv/.ssh/authorized_keys
-
hosts
:
all
vars
:
owner
:
ubuntu
keyfile
:
"
/home/{{
owner
}}/.ssh/authorized_keys"
tasks
:
-
fail
:
msg="You must pass in a public_key"
when
:
public_key is not defined
-
command
:
mktemp
register
:
mktemp
-
name
:
Validate the public key before we add it to authorized_keys
copy
:
>
content="{{ public_key }}"
dest={{ mktemp.stdout }}
# This tests the public key and will not continue if it does not look valid
-
command
:
ssh-keygen -l -f {{ mktemp.stdout }}
-
file
:
>
path={{ mktemp.stdout }}
state=absent
-
lineinfile
:
>
dest={{ keyfile }}
line="{{ public_key }}"
-
file
:
>
path={{ keyfile }}
owner={{ owner }}
mode=0600
playbooks/edx-east/remove-ubuntu-key.yml
0 → 100644
View file @
5146e3d0
# A simple utility play to remove a public key from the authorized key
# file for the ubuntu user
# You must pass in the entire line that you are adding
-
hosts
:
all
vars
:
owner
:
ubuntu
keyfile
:
"
/home/{{
owner
}}/.ssh/authorized_keys"
tasks
:
-
fail
:
msg="You must pass in a public_key_line"
when
:
public_key is not defined
-
command
:
mktemp
register
:
mktemp
-
shell
:
>
grep -Fv '{{ public_key }}' {{ keyfile }} > {{ mktemp.stdout }}
-
shell
:
>
while read line; do ssh-keygen -lf /dev/stdin <<<$line; done <{{ mktemp.stdout }}
executable=/bin/bash
register
:
keycheck
-
fail
:
msg="public key check failed!"
when
:
keycheck.stderr != ""
-
command
:
cp {{ mktemp.stdout }} {{ keyfile }}
-
file
:
>
path={{ keyfile }}
owner={{ owner }}
mode=0600
-
file
:
>
path={{ mktemp.stdout }}
state=absent
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment