Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
commonauth
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
commonauth
Commits
d12c6ee0
Commit
d12c6ee0
authored
9 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
Tests and bug fixes
parent
8c6b55bb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tasks/commonauth.yml
+28
-26
28 additions, 26 deletions
tasks/commonauth.yml
tasks/distribute_certs.yml
+29
-26
29 additions, 26 deletions
tasks/distribute_certs.yml
templates/ssh_config
+4
-4
4 additions, 4 deletions
templates/ssh_config
with
61 additions
and
56 deletions
tasks/commonauth.yml
+
28
−
26
View file @
d12c6ee0
---
# file: roles/commonauth/tasks/commonauth.yml
-
name
:
'
Common
|
Create
The
/etc/hosts
File
'
template
:
src=etc_hosts
dest=/
etc
/
hosts
owner=root
group
=root
mode=0644
when
:
scope == 'all'
-
name
:
"
Common
|
Create
The
/etc/hosts
File
"
template
:
src=
etc
_
hosts
dest=/etc/hosts
owner
=root
group=root
mode=0644
-
name
:
'
User
|
Create
All
Required
Users'
user
:
name={{item}}
group=root
groups=root,sudo,www-data
home=/home/{{item}}
generate_ssh_key=yes
ssh_key_bits=2048
password={{initial_password}}
update_password=on_create
-
name
:
"
User
|
Create
All
Required
Users"
user
:
name={{ item }}
group=root
groups=root,sudo,www-data
home=/home/{{ item }}
generate_ssh_key=yes
ssh_key_bits=2048
password={{ initial_password }}
update_password=on_create
with_items
:
admins
-
name
:
'
User
|
Copy
SSH
Config
For
Server-To-Server
Communication
For
Admins'
template
:
src=ssh_config
dest=/home/{{item}}/.ssh/config
owner={{item}}
group=root
mode=644
-
name
:
"
User
|
Copy
SSH
Config
For
Server-To-Server
Communication
For
Admins"
template
:
src=ssh_config
dest=/home/{{ item }}/.ssh/config
owner={{ item }}
group=root
mode=644
with_items
:
admins
-
include
:
distribute_certs.yml
when
:
distribute_certs
-
name
:
'
User
|
Install
Public
Key
For
Extra
Users'
authorized_key
:
user={{item.username}}
key="{{lookup('file', inventory_dir + '/files/certs/' + item.certname + '.d2s.pub')}}"
-
name
:
"
User
|
Install
Public
Key
For
Extra
Users"
authorized_key
:
user={{ item.username }}
key="{{ lookup('file', inventory_dir + '/files/keys/' + item.certname + '.d2s.pub') }}"
with_items
:
auth_certs
This diff is collapsed.
Click to expand it.
tasks/distribute_certs.yml
+
29
−
26
View file @
d12c6ee0
...
...
@@ -3,50 +3,53 @@
---
# file: roles/commonauth/tasks/distribute_certs.yml
-
name
:
'
Certs
|
Remove
the
fresh
auth
file
in
case
it
does
already
exist
'
-
name
:
"
Certs
|
Remove
the
fresh
auth
file
in
case
it
does
already
exist
"
file
:
path=/home/{{item}}/.ssh/auth_keys_fresh
path=/home/{{
item
}}/.ssh/auth_keys_fresh
state=absent
with_items
:
admins
-
name
:
'
Certs
|
Install
Public
Keys
For
Desktop-To-Server
Communication
in
a
fresh
file'
authorized_key
:
user={{item}}
key="{{lookup('file', inventory_dir + '/files/certs/' + item + '.d2s.pub')}}"
path="/home/{{item}}/.ssh/fresh_auth_keys_{{item}}"
-
name
:
"
Certs
|
Install
Public
Keys
For
Desktop-To-Server
Communication
in
a
fresh
file"
authorized_key
:
user={{ item }}
key={{ lookup('file', inventory_dir + '/files/keys/' + item + '.d2s.pub') }}
path=/home/{{ item }}/.ssh/fresh_auth_keys_{{ item }}
with_items
:
admins
-
name
:
'
Certs
|
Read
public
key
of
tunnel
user
'
command
:
more /home/{{tunnel_user_name}}/.ssh/id_rsa.pub
-
name
:
"
Certs
|
Read
public
key
of
tunnel
user
"
command
:
more /home/{{
tunnel_user_name
}}/.ssh/id_rsa.pub
register
:
pubkey
-
name
:
'
Certs
|
Distribute
public
key
of
tunnel
user'
authorized_key
:
user={{tunnel_user_name}}
key="{{pubkey.stdout}} {{inventory_hostname}}"
path="/home/{{tunnel_user_name}}/.ssh/fresh_auth_keys_tunnel_{{inventory_hostname}}"
delegate_to
:
'
{{item}}'
-
name
:
"
Certs
|
Distribute
public
key
of
tunnel
user"
authorized_key
:
user={{ tunnel_user_name }}
key={{ pubkey.stdout }} {{ inventory_hostname }}
path=/home/{{ tunnel_user_name }}/.ssh/fresh_auth_keys_tunnel_{{ inventory_hostname }}
delegate_to
:
'
{{
item
}}'
with_items
:
groups.all
-
name
:
'
Certs
|
Merge
all
public
keys
'
shell
:
cat /home/{{item}}/.ssh/fresh_auth_keys* > /home/{{item}}/.ssh/auth_keys_fresh
-
name
:
"
Certs
|
Merge
all
public
keys
"
shell
:
cat /home/{{
item
}}/.ssh/fresh_auth_keys* > /home/{{
item
}}/.ssh/auth_keys_fresh
with_items
:
admins
-
name
:
'
Certs
|
Remove
temp
files
'
shell
:
rm /home/{{item}}/.ssh/fresh_auth_keys_*
-
name
:
"
Certs
|
Remove
temp
files
"
shell
:
rm /home/{{
item
}}/.ssh/fresh_auth_keys_*
with_items
:
admins
-
name
:
'
Certs
|
Set
ownership
of
authorized
key
file
'
shell
:
chown {{item}}:root /home/{{item}}/.ssh/auth_keys_fresh
-
name
:
"
Certs
|
Set
ownership
of
authorized
key
file
"
shell
:
chown {{
item
}}:root /home/{{
item
}}/.ssh/auth_keys_fresh
with_items
:
admins
-
name
:
'
Certs
|
Set
permission
for
authorized
key
file
'
shell
:
chmod 600 /home/{{item}}/.ssh/auth_keys_fresh
-
name
:
"
Certs
|
Set
permission
for
authorized
key
file
"
shell
:
chmod 600 /home/{{
item
}}/.ssh/auth_keys_fresh
with_items
:
admins
-
name
:
'
Certs
|
Make
sure
the
authorized_keys
file
exists'
file
:
name='/home/{{item}}/.ssh/authorized_keys'
state=touch
-
name
:
"
Certs
|
Make
sure
the
authorized_keys
file
exists"
file
:
name=/home/{{ item }}/.ssh/authorized_keys
state=touch
with_items
:
admins
-
name
:
'
Certs
|
Move
the
fresh
auth
file
to
replace
the
old
one
'
shell
:
rm /home/{{item}}/.ssh/authorized_keys && mv /home/{{item}}/.ssh/auth_keys_fresh /home/{{item}}/.ssh/authorized_keys
-
name
:
"
Certs
|
Move
the
fresh
auth
file
to
replace
the
old
one
"
shell
:
rm /home/{{
item
}}/.ssh/authorized_keys && mv /home/{{
item
}}/.ssh/auth_keys_fresh /home/{{
item
}}/.ssh/authorized_keys
with_items
:
admins
This diff is collapsed.
Click to expand it.
templates/ssh_config
+
4
−
4
View file @
d12c6ee0
...
...
@@ -4,10 +4,10 @@ StrictHostKeyChecking no
ForwardAgent
yes
{%
for
host in commonauth_extras %
}
{%
if
host
[
certfile
]
is defined %
}
{%
for
name in host
['
names
']
%
}
Host
{{
name
}}
IdentityFile
~/.ssh/
{{
host
[
certfile
]
}}
{%
if
host
.
certfile is defined %
}
{%
for
name in host
.
names %
}
Host
{{
name
}}
IdentityFile
~/.ssh/
{{
host
.
certfile
}}
{%
endfor
%
}
{%
endif
%
}
...
...
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