Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow ssh between saluser@tel-lt1.tu and saluser@tel-hw1.tu #652

Merged
merged 9 commits into from
Sep 14, 2022
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ RSpec/ImplicitSubject:
Enabled: false
Style/CommentedKeyword:
Enabled: false
Naming/FileName:
Enabled: false
6 changes: 6 additions & 0 deletions hieradata/node/tel-hw1.tu.lsst.org.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ network::mroutes_hash:
routes:
"140.252.147.16/28": "140.252.147.129"
"140.252.147.48/28": "140.252.147.129"

profile::core::k5login::k5login:
"/home/saluser/.k5login":
ensure: "present"
principals:
- "saluser/tel-lt1.tu.lsst.org@LSST.CLOUD"
7 changes: 7 additions & 0 deletions hieradata/node/tel-lt1.tu.lsst.org.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
profile::core::common::manage_resolv_conf: false
profile::core::k5login::k5login:
"/home/saluser/.k5login":
ensure: "present"
principals:
- "saluser/tel-hw1.tu.lsst.org@LSST.CLOUD"
2 changes: 1 addition & 1 deletion site/profile/manifests/ccs/krb5_token.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class profile::ccs::krb5_token (
String $user,
Integer $uid,
String $keytab_base64,
Sensitive[String[1]] $keytab_base64,
) {
profile::util::keytab { $user:
uid => $uid,
Expand Down
11 changes: 10 additions & 1 deletion site/profile/manifests/core/common.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
# @param manage_irqbalance
# If `true`, manage irqbalance
#
# @param manage_resolv_conf
# If `true`, manage resolv.conf
#
class profile::core::common (
Boolean $deploy_icinga_agent = false,
Boolean $manage_puppet_agent = true,
Expand All @@ -61,6 +64,7 @@
Boolean $manage_scl = true,
Boolean $manage_repos = true,
Boolean $manage_irqbalance = true,
Boolean $manage_resolv_conf = true,
) {
include accounts
include augeas
Expand All @@ -74,11 +78,11 @@
include profile::core::ipa
include profile::core::k5login
include profile::core::kernel
include profile::core::keytab
include profile::core::nm_dispatch
include profile::core::selinux
include profile::core::systemd
include profile::core::yum
include resolv_conf
include rsyslog
include rsyslog::config
include selinux
Expand Down Expand Up @@ -159,6 +163,11 @@
include scl
}
}

if $manage_resolv_conf {
include resolv_conf
}

class { 'lldpd':
manage_repo => true,
}
Expand Down
4 changes: 2 additions & 2 deletions site/profile/manifests/core/ipa_pwd_reset.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

class profile::core::ipa_pwd_reset (
String $keytab_base64,
Sensitive[String[1]] $keytab_base64,
String $secret_key,
String $ldap_user,
String $ldap_pwd,
Expand Down Expand Up @@ -103,7 +103,7 @@
# Create Keytab
file { "${keytab_path}/${ldap_user}.keytab":
ensure => file,
content => base64('decode', $keytab_base64),
content => base64('decode', $keytab_base64.unwrap),
mode => '0600',
owner => $ldap_user,
group => $ldap_user,
Expand Down
17 changes: 17 additions & 0 deletions site/profile/manifests/core/keytab.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @summary
# Generates profile::util::keytab resources
#
# @param keytab
# Hash of keytab resources to create
#
class profile::core::keytab (
Optional[Hash[String[1], Hash[String[1], NotUndef]]] $keytab = undef,
) {
if $keytab {
$keytab.each | String $name, Hash $conf | {
profile::util::keytab { $name:
* => $conf,
}
}
}
}
6 changes: 3 additions & 3 deletions site/profile/manifests/core/rke.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# Version of rke utility to install
#
class profile::core::rke (
Boolean $enable_dhcp = false,
Optional[String] $keytab_base64 = undef,
String $version = '1.3.3',
Boolean $enable_dhcp = false,
Optional[Sensitive[String[1]]] $keytab_base64 = undef,
String $version = '1.3.3',
) {
$user = 'rke'
$uid = 75500
Expand Down
15 changes: 8 additions & 7 deletions site/profile/manifests/util/keytab.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
define profile::util::keytab (
Integer $uid,
String $keytab_base64,
Sensitive[String[1]] $keytab_base64,
) {
$home_path = "/home/${name}"
$keytab_path = "${home_path}/.keytab"
Expand All @@ -24,15 +24,16 @@
mode => '0700',
})
file { $keytab_path:
ensure => file,
owner => $name,
group => $name,
mode => '0400',
content => base64('decode', $keytab_base64),
ensure => file,
owner => $name,
group => $name,
mode => '0400',
show_diff => false, # do not print keytab in logs
content => base64('decode', $keytab_base64.unwrap),
}

cron { 'k5start_root':
command => "/usr/bin/k5start -f ${keytab_path} -U -o ${uid} -k /tmp/krb5cc_${uid} -H 60 > /dev/null 2>&1",
command => "/usr/bin/k5start -f ${keytab_path} -U -o ${uid} -k /tmp/krb5cc_${uid} -H 60 -F > /dev/null 2>&1",
user => 'root',
minute => '*/1',
require => File[$keytab_path],
Expand Down
46 changes: 36 additions & 10 deletions spec/classes/core/common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,44 @@
context "on #{os}" do
let(:facts) { facts }

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('hosts') }
it { is_expected.to contain_class('network') }
it { is_expected.to contain_class('profile::core::nm_dispatch') }
it { is_expected.to contain_package('ca-certificates').with_ensure('latest') }

it do
is_expected.to contain_service('NetworkManager').with(ensure: 'running', enable: true)
context 'with no params' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('hosts') }
it { is_expected.to contain_class('network') }
it { is_expected.to contain_class('resolv_conf') }
it { is_expected.to contain_class('profile::core::keytab') }
it { is_expected.to contain_class('profile::core::nm_dispatch') }
it { is_expected.to contain_package('ca-certificates').with_ensure('latest') }

it do
is_expected.to contain_service('NetworkManager').with(ensure: 'running', enable: true)
end

it do
is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-').with_ensure('absent')
end
end

it do
is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-').with_ensure('absent')
context 'with resolv_conf param' do
context 'when false' do
let(:params) do
{
manage_resolv_conf: false,
}
end

it { is_expected.not_to contain_class('resolv_conf') }
end

context 'when true' do
let(:params) do
{
manage_resolv_conf: true,
}
end

it { is_expected.to contain_class('resolv_conf') }
end
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/core/ipa_pwd_reset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
context 'with no params' do
let(:params) do
{
keytab_base64: 'foo',
secret_key: 'bar',
ldap_user: 'baz',
keytab_base64: sensitive('foo'),
ldap_pwd: 'quix',
ldap_user: 'baz',
secret_key: 'bar',
}
end

Expand Down
40 changes: 40 additions & 0 deletions spec/classes/core/keytab_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'profile::core::keytab' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end

context 'with no parameters' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to have_profile__util__keytab_resource_count(0) }
end

context 'with keytab param' do
let(:params) do
{
keytab: {
foo: {
uid: 1234,
keytab_base64: sensitive('Zm9v'),
},
},
}
end

it { is_expected.to have_profile__util__keytab_resource_count(1) }

it do
is_expected.to contain_profile__util__keytab('foo').with(
uid: 1234,
keytab_base64: sensitive('Zm9v'),
)
end
end
end
end
end
4 changes: 2 additions & 2 deletions spec/classes/core/rke_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
context 'when 42' do
let(:params) do
{
keytab_base64: '42',
keytab_base64: sensitive('42'),
}
end

Expand All @@ -76,7 +76,7 @@
it do
is_expected.to contain_profile__util__keytab('rke').with(
uid: 75_500,
keytab_base64: '42',
keytab_base64: sensitive('42'),
)
end
end
Expand Down
5 changes: 3 additions & 2 deletions spec/defines/util/keytab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
context "on #{os}" do
let(:facts) { facts }
let(:title) { 'foo' }
let(:params) { { 'uid' => 123, 'keytab_base64' => 'YmFy' } }
let(:params) { { 'uid' => 123, 'keytab_base64' => sensitive('YmFy') } }

it { is_expected.to compile.with_all_deps }

Expand All @@ -26,13 +26,14 @@
owner: 'foo',
group: 'foo',
mode: '0400',
show_diff: false,
content: 'bar',
)
end

it do
is_expected.to contain_cron('k5start_root').with(
command: '/usr/bin/k5start -f /home/foo/.keytab -U -o 123 -k /tmp/krb5cc_123 -H 60 > /dev/null 2>&1',
command: '/usr/bin/k5start -f /home/foo/.keytab -U -o 123 -k /tmp/krb5cc_123 -H 60 -F > /dev/null 2>&1',
)
end

Expand Down
4 changes: 3 additions & 1 deletion spec/fixtures/hieradata/common.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
lookup_options:
'^profile::.+::keytab_base64$':
convert_to: "Sensitive"
ccs_database::database: "comcamdbprod"
ccs_database::password: "foo"
easy_ipa::admin_password: "foofoofoofoo" # ipa master only
easy_ipa::directory_services_password: "foofoofoofoo" # ipa master only
easy_ipa::domain_join_password: "foofoofoofoo" # 8 char min
foreman_proxy::plugin::dns::route53::aws_access_key: "foo"
foreman_proxy::plugin::dns::route53::aws_secret_key: "foo"
profile::archive::forwarder::keytab_base64: "foo"
profile::ccs::krb5_token::keytab_base64: "foo"
profile::ccs::krb5_token::uid: "foo"
profile::ccs::krb5_token::user: "foo"
Expand Down
31 changes: 31 additions & 0 deletions spec/hosts/nodes/tel-hw1.tu.lsst.org_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'tel-hw1.tu.lsst.org', :site do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(
fqdn: 'tel-hw1.tu.lsst.org',
)
end

let(:node_params) do
{
role: 'generic',
site: 'tu',
}
end

it { is_expected.to compile.with_all_deps }

it do
is_expected.to contain_k5login('/home/saluser/.k5login').with(
ensure: 'present',
principals: ['saluser/tel-lt1.tu.lsst.org@LSST.CLOUD'],
)
end
end # on os
end # on_supported_os
end # role
32 changes: 32 additions & 0 deletions spec/hosts/nodes/tel-lt1.tu.lsst.org_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'tel-lt1.tu.lsst.org', :site do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(
fqdn: 'tel-lt1.tu.lsst.org',
)
end

let(:node_params) do
{
role: 'generic',
site: 'tu',
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.not_to contain_class('resolv_conf') }

it do
is_expected.to contain_k5login('/home/saluser/.k5login').with(
ensure: 'present',
principals: ['saluser/tel-hw1.tu.lsst.org@LSST.CLOUD'],
)
end
end # on os
end # on_supported_os
end # role