Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
commonkeys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ansible
Roles
commonkeys
Commits
deb53cae
Commit
deb53cae
authored
7 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
ansible-playbooks/general#72 Always use import_tasks or include_tasks instead of just include
parent
e533402c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tasks/admin_keys.yml
+15
-11
15 additions, 11 deletions
tasks/admin_keys.yml
tasks/main.yml
+3
-3
3 additions, 3 deletions
tasks/main.yml
tasks/user_keys.yml
+42
-38
42 additions, 38 deletions
tasks/user_keys.yml
with
60 additions
and
52 deletions
tasks/admin_keys.yml
+
15
−
11
View file @
deb53cae
---
---
# file: roles/commonkeys/tasks/admin_keys.yml
# file: roles/commonkeys/tasks/admin_keys.yml
-
name
:
"
Read
public
key
of
admin
user"
-
block
:
shell
:
cat /home/{{ username }}/.ssh/id_rsa.pub
register
:
pubkey
-
name
:
"
Read
public
key
of
admin
user"
shell
:
cat /home/{{ username }}/.ssh/id_rsa.pub
-
name
:
"
Distribute
public
key
of
admin
user"
register
:
pubkey
authorized_key
:
user='{{ username }}'
-
name
:
"
Distribute
public
key
of
admin
user"
key="{{ hostvars[item].pubkey.stdout }} {{ item }}"
authorized_key
:
path='/home/{{ username }}/.ssh/fresh_auth_keys_tunnel_{{ item }}'
user='{{ username }}'
with_items
:
'
{{
groups.all
}}'
key="{{ hostvars[item].pubkey.stdout }} {{ item }}"
when
:
item != "localhost" and inventory_hostname != "localhost" and hostvars[item].pubkey is defined
path='/home/{{ username }}/.ssh/fresh_auth_keys_tunnel_{{ item }}'
with_items
:
'
{{
groups.all
}}'
when
:
item != "localhost" and inventory_hostname != "localhost" and hostvars[item].pubkey is defined
tags
:
'
Keys'
This diff is collapsed.
Click to expand it.
tasks/main.yml
+
3
−
3
View file @
deb53cae
...
@@ -8,21 +8,21 @@
...
@@ -8,21 +8,21 @@
-
block
:
-
block
:
-
name
:
"
Reset
all
hosts"
-
name
:
"
Reset
all
hosts"
include
:
reset.yml
include
_tasks
:
reset.yml
with_items
:
'
{{
groups.all
}}'
with_items
:
'
{{
groups.all
}}'
loop_control
:
loop_control
:
loop_var
:
hostname
loop_var
:
hostname
when
:
hostname != "localhost" and inventory_hostname != "localhost"
when
:
hostname != "localhost" and inventory_hostname != "localhost"
-
name
:
"
Admin
keys"
-
name
:
"
Admin
keys"
include
:
admin_keys.yml
include
_tasks
:
admin_keys.yml
loop_control
:
loop_control
:
loop_var
:
username
loop_var
:
username
with_items
:
'
{{
admins
}}'
with_items
:
'
{{
admins
}}'
tags
:
'
Keys'
tags
:
'
Keys'
-
name
:
"
User
keys"
-
name
:
"
User
keys"
include
:
user_keys.yml
include
_tasks
:
user_keys.yml
with_flattened
:
with_flattened
:
-
'
{{
admins
}}'
-
'
{{
admins
}}'
-
'
{{
jailusers
}}'
-
'
{{
jailusers
}}'
...
...
This diff is collapsed.
Click to expand it.
tasks/user_keys.yml
+
42
−
38
View file @
deb53cae
---
---
# file: roles/commonkeys/tasks/user_keys.yml
# file: roles/commonkeys/tasks/user_keys.yml
-
name
:
"
Keys
|
Remove
the
fresh
auth
file
in
case
it
does
already
exist"
-
block
:
file
:
path=/home/{{ username }}/.ssh/auth_keys_fresh
-
name
:
"
Keys
|
Remove
the
fresh
auth
file
in
case
it
does
already
exist"
state=absent
file
:
path=/home/{{ username }}/.ssh/auth_keys_fresh
-
name
:
"
Keys
|
Install
Public
Keys
For
Desktop-To-Server
Communication
in
a
fresh
file"
state=absent
authorized_key
:
user={{ username }}
-
name
:
"
Keys
|
Install
Public
Keys
For
Desktop-To-Server
Communication
in
a
fresh
file"
key="{{ lookup('file', inventory_dir + '/files/keys/' + username + '.d2s.pub') }}"
authorized_key
:
path=/home/{{ username }}/.ssh/fresh_auth_keys_{{ username }}
user={{ username }}
key_options={{ users[username]['ssh_key_options']|default(omit) }}
key="{{ lookup('file', inventory_dir + '/files/keys/' + username + '.d2s.pub') }}"
path=/home/{{ username }}/.ssh/fresh_auth_keys_{{ username }}
-
name
:
"
Keys
|
Merge
all
public
keys"
key_options={{ users[username]['ssh_key_options']|default(omit) }}
shell
:
cat /home/{{ username }}/.ssh/fresh_auth_keys* > /home/{{ username }}/.ssh/auth_keys_fresh
-
name
:
"
Keys
|
Merge
all
public
keys"
-
name
:
"
Keys
|
Remove
temp
files"
shell
:
cat /home/{{ username }}/.ssh/fresh_auth_keys* > /home/{{ username }}/.ssh/auth_keys_fresh
shell
:
rm /home/{{ username }}/.ssh/fresh_auth_keys_*
-
name
:
"
Keys
|
Remove
temp
files"
-
name
:
"
Keys
|
Set
ownership
of
authorized
key
file"
shell
:
rm /home/{{ username }}/.ssh/fresh_auth_keys_*
file
:
path="/home/{{ username }}/.ssh/auth_keys_fresh"
-
name
:
"
Keys
|
Set
ownership
of
authorized
key
file"
owner="{{ username }}"
file
:
group="root"
path="/home/{{ username }}/.ssh/auth_keys_fresh"
owner="{{ username }}"
-
name
:
"
Keys
|
Set
permission
for
authorized
key
file"
group="root"
file
:
path="/home/{{ username }}/.ssh/auth_keys_fresh"
-
name
:
"
Keys
|
Set
permission
for
authorized
key
file"
mode='600'
file
:
path="/home/{{ username }}/.ssh/auth_keys_fresh"
-
name
:
"
Keys
|
Make
sure
the
authorized_keys
file
exists"
mode='600'
file
:
name=/home/{{ username }}/.ssh/authorized_keys
-
name
:
"
Keys
|
Make
sure
the
authorized_keys
file
exists"
state=touch
file
:
name=/home/{{ username }}/.ssh/authorized_keys
-
name
:
"
Keys
|
Move
the
fresh
auth
file
to
replace
the
old
one"
state=touch
shell
:
rm /home/{{ username }}/.ssh/authorized_keys && mv /home/{{ username }}/.ssh/auth_keys_fresh /home/{{ username }}/.ssh/authorized_keys
args
:
-
name
:
"
Keys
|
Move
the
fresh
auth
file
to
replace
the
old
one"
executable
:
/bin/bash
shell
:
rm /home/{{ username }}/.ssh/authorized_keys && mv /home/{{ username }}/.ssh/auth_keys_fresh /home/{{ username }}/.ssh/authorized_keys
args
:
executable
:
/bin/bash
tags
:
'
Keys'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment