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
8347b105
Commit
8347b105
authored
5 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
ansible-playbooks/general#85 Linting
parent
30afcd00
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tasks/admin_keys.yml
+6
-5
6 additions, 5 deletions
tasks/admin_keys.yml
tasks/main.yml
+2
-2
2 additions, 2 deletions
tasks/main.yml
tasks/reset.yml
+6
-6
6 additions, 6 deletions
tasks/reset.yml
tasks/user_keys.yml
+24
-23
24 additions, 23 deletions
tasks/user_keys.yml
with
38 additions
and
36 deletions
tasks/admin_keys.yml
+
6
−
5
View file @
8347b105
...
...
@@ -3,16 +3,17 @@
-
block
:
-
name
:
"
Read
public
key
of
admin
user
"
command
:
'
cat
/home/{{
username
}}/.ssh/id_rsa.pub
'
-
name
:
Read public key of admin user
command
:
cat /home/{{ username }}/.ssh/id_rsa.pub
register
:
pubkey
-
name
:
"
Distribute
public
key
of
admin
user
"
-
name
:
Distribute public key of admin user
authorized_key
:
user
:
'
{{
username
}}'
key
:
'
{{
hostvars[item].pubkey.stdout
}}
{{
item
}}'
path
:
'
/home/{{
username
}}/.ssh/fresh_auth_keys_tunnel_{{
item
}}
'
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'
tags
:
-
Keys
This diff is collapsed.
Click to expand it.
tasks/main.yml
+
2
−
2
View file @
8347b105
...
...
@@ -27,8 +27,8 @@
-
name
:
User keys
include_tasks
:
user_keys.yml
with_flattened
:
-
'
{{
admins
}}
'
-
'
{{
jailusers
}}
'
-
{{
admins
}}
-
{{
jailusers
}}
loop_control
:
loop_var
:
username
tags
:
...
...
This diff is collapsed.
Click to expand it.
tasks/reset.yml
+
6
−
6
View file @
8347b105
---
# file: roles/commonkeys/tasks/reset.yml
-
name
:
"
Remove
previous
hostname
from
known_hosts
"
-
name
:
Remove previous hostname from known_hosts
known_hosts
:
name
:
'
{{
hostname
}}'
state
:
'
absent
'
state
:
absent
become
:
no
-
name
:
"
Remove
previous
ip
from
known_hosts
"
-
name
:
Remove previous ip from known_hosts
known_hosts
:
name
:
"
{{
hostvars[hostname]['static_ipv4']|default(hostvars[hostname]['ansible_default_ipv4']['address'])
}}"
state
:
'
absent
'
state
:
absent
become
:
no
-
name
:
"
Include
all
hosts
into
/etc/hosts
"
-
name
:
Include all hosts into /etc/hosts
lineinfile
:
dest
:
'
/etc/hosts
'
dest
:
/etc/hosts
regexp
:
"
^{{
hostvars[hostname]['static_ipv4']|default(hostvars[hostname]['ansible_default_ipv4']['address'])
}}
"
line
:
"
{{
hostvars[hostname]['static_ipv4']|default(hostvars[hostname]['ansible_default_ipv4']['address'])
}}
{{
hostname
}}"
This diff is collapsed.
Click to expand it.
tasks/user_keys.yml
+
24
−
23
View file @
8347b105
...
...
@@ -3,47 +3,48 @@
-
block
:
-
name
:
"
Keys
|
Remove
the
fresh
auth
file
in
case
it
does
already
exist
"
-
name
:
Keys | Remove the fresh auth file in case it does already exist
file
:
path
:
'
/home/{{
username
}}/.ssh/auth_keys_fresh
'
state
:
'
absent
'
path
:
/home/{{ username }}/.ssh/auth_keys_fresh
state
:
absent
-
name
:
"
Keys
|
Install
Public
Keys
For
Desktop-To-Server
Communication
in
a
fresh
file
"
-
name
:
Keys | Install Public Keys For Desktop-To-Server Communication in a fresh file
authorized_key
:
user
:
'
{{
username
}}'
key
:
"
{{
lookup('file',
inventory_dir
+
'/files/keys/'
+
username
+
'.d2s.pub')
}}"
path
:
'
/home/{{
username
}}/.ssh/fresh_auth_keys_{{
username
}}
'
path
:
/home/{{ username }}/.ssh/fresh_auth_keys_{{ username }}
key_options
:
"
{{
users[username]['ssh_key_options']|default(omit)
}}"
-
name
:
"
Keys
|
Merge
all
public
keys
"
shell
:
'
cat
/home/{{
username
}}/.ssh/fresh_auth_keys*
>
/home/{{
username
}}/.ssh/auth_keys_fresh
'
-
name
:
Keys | Merge all public keys
shell
:
cat /home/{{ username }}/.ssh/fresh_auth_keys* > /home/{{ username }}/.ssh/auth_keys_fresh
-
name
:
"
Keys
|
Remove
temp
files
"
-
name
:
Keys | Remove temp files
file
:
path
:
'
{{
item
}}'
state
:
'
absent
'
state
:
absent
with_fileglob
:
-
'
/home/{{
username
}}/.ssh/fresh_auth_keys_*
'
-
/home/{{ username }}/.ssh/fresh_auth_keys_*
-
name
:
"
Keys
|
Set
ownership
of
authorized
key
file
"
-
name
:
Keys | Set ownership of authorized key file
file
:
path
:
'
/home/{{
username
}}/.ssh/auth_keys_fresh
'
path
:
/home/{{ username }}/.ssh/auth_keys_fresh
owner
:
'
{{
username
}}'
group
:
'
root
'
group
:
root
-
name
:
"
Keys
|
Set
permission
for
authorized
key
file
"
-
name
:
Keys | Set permission for authorized key file
file
:
path
:
'
/home/{{
username
}}/.ssh/auth_keys_fresh
'
mode
:
'
600
'
path
:
/home/{{ username }}/.ssh/auth_keys_fresh
mode
:
600
-
name
:
"
Keys
|
Make
sure
the
authorized_keys
file
exists
"
-
name
:
Keys | Make sure the authorized_keys file exists
file
:
name
:
'
/home/{{
username
}}/.ssh/authorized_keys
'
state
:
'
touch
'
name
:
/home/{{ username }}/.ssh/authorized_keys
state
:
touch
-
name
:
"
Keys
|
Move
the
fresh
auth
file
to
replace
the
old
one
"
shell
:
'
rm
/home/{{
username
}}/.ssh/authorized_keys
&&
mv
/home/{{
username
}}/.ssh/auth_keys_fresh
/home/{{
username
}}/.ssh/authorized_keys
'
-
name
:
Keys | Move the fresh auth file to replace the old one
shell
:
rm /home/{{ username }}/.ssh/authorized_keys && mv /home/{{ username }}/.ssh/auth_keys_fresh /home/{{ username }}/.ssh/authorized_keys
args
:
executable
:
'
/bin/bash
'
executable
:
/bin/bash
tags
:
'
Keys'
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