-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #507 from mlibrary/bastion-prototype
Add bastion role and bolt profile
- Loading branch information
Showing
13 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::bolt { | ||
include nebula::profile::managed_known_hosts | ||
include nebula::profile::github_pull_account | ||
include nebula::virtual::users | ||
package { 'puppet-bolt': } | ||
|
||
$users = lookup('nebula::profile::authorized_keys::ssh_keys').keys | ||
$all_users = lookup('nebula::virtual::users::all_users') | ||
|
||
$users.each |$user| { | ||
$data = $all_users[$user] | ||
|
||
User <| title == $user |> { | ||
home => "/home/${user}", | ||
gid => 100, | ||
require => File["/home/${user}"], | ||
} | ||
|
||
file { "/home/${user}": | ||
ensure => 'directory', | ||
owner => $data['uid'], | ||
group => 100, | ||
mode => '0755', | ||
} | ||
} | ||
|
||
file { "/opt/bolt": | ||
ensure => "directory", | ||
owner => "git", | ||
group => 100, | ||
mode => "0755", | ||
} | ||
|
||
vcsrepo { "/opt/bolt": | ||
provider => "git", | ||
ensure => "latest", | ||
source => "ssh://[email protected]/mlibrary/bolt.git", | ||
user => "git", | ||
require => [ | ||
Class["nebula::profile::github_pull_account"], | ||
File["/opt/bolt"], | ||
Package["git"], | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::github_pull_account ( | ||
String $git_username = "git", | ||
Integer $git_gid = 100, | ||
String $git_homedir = "/var/lib/autogit", | ||
) { | ||
package { "git": } | ||
|
||
user { $git_username: | ||
ensure => "present", | ||
home => $git_homedir, | ||
gid => $git_gid, | ||
managehome => true, | ||
} | ||
|
||
file { "${git_homedir}/.ssh": | ||
ensure => "directory", | ||
owner => $git_username, | ||
group => $git_gid, | ||
mode => "0700", | ||
require => User[$git_username], | ||
} | ||
|
||
# Once this exists, you have to add the id_ecdsa.pub to any private | ||
# github repos you want to pull. | ||
exec { "create ${git_homedir}/.ssh/id_ecdsa": | ||
creates => "${git_homedir}/.ssh/id_ecdsa", | ||
user => $git_username, | ||
command => "/usr/bin/ssh-keygen -t ecdsa -N '' -C '${::hostname}' -f ${git_homedir}/.ssh/id_ecdsa", | ||
require => File["${git_homedir}/.ssh"], | ||
} | ||
|
||
exec { "create /var/local/github_ssh_keys": | ||
creates => "/var/local/github_ssh_keys", | ||
command => "/usr/bin/ssh-keyscan github.com > /var/local/github_ssh_keys", | ||
} | ||
|
||
include nebula::profile::managed_known_hosts | ||
|
||
# Without this, the git user will not be able to pull from private | ||
# repos using ssh. | ||
concat_fragment { "github ssh keys": | ||
target => "/etc/ssh/ssh_known_hosts", | ||
source => "/var/local/github_ssh_keys", | ||
require => Exec["create /var/local/github_ssh_keys"], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::profile::managed_known_hosts { | ||
concat { '/etc/ssh/ssh_known_hosts': } | ||
|
||
# See nebula::profile::known_host_public_keys | ||
Concat_fragment <<| tag == 'known_host_public_keys' |>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) 2022 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
|
||
class nebula::role::bastion { | ||
include nebula::role::minimum | ||
|
||
include nebula::profile::bolt | ||
include nebula::profile::root_ssh_private_keys | ||
|
||
# These three are effectively the requirements for getting user login | ||
# with kerberos and duo. | ||
include nebula::profile::duo | ||
include nebula::profile::krb5 | ||
include nebula::profile::networking | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2022, 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::bolt' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_package('puppet-bolt') } | ||
it { is_expected.to contain_file('/opt/bolt').with_ensure('directory') } | ||
it { is_expected.to contain_vcsrepo('/opt/bolt').with_ensure('latest') } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::github_pull_account' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_user('git').with_home('/var/lib/autogit') } | ||
it { is_expected.to contain_user('git').with_gid(100) } | ||
it { is_expected.to contain_user('git').with_managehome(true) } | ||
it { is_expected.to contain_file('/var/lib/autogit/.ssh').with_ensure('directory') } | ||
it { is_expected.to contain_file('/var/lib/autogit/.ssh').with_mode('0700') } | ||
it { is_expected.to contain_exec('create /var/lib/autogit/.ssh/id_ecdsa') } | ||
it { is_expected.to contain_exec('create /var/local/github_ssh_keys') } | ||
it { is_expected.to contain_concat_fragment('github ssh keys').with_target('/etc/ssh/ssh_known_hosts') } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024 The Regents of the University of Michigan. | ||
# All Rights Reserved. Licensed according to the terms of the Revised | ||
# BSD License. See LICENSE.txt for details. | ||
require 'spec_helper' | ||
|
||
describe 'nebula::profile::managed_known_hosts' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_concat('/etc/ssh/ssh_known_hosts') } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters