Add SSH public key to nodepool-builder

Since we use DIB elements to create our zuul user, we also need to
have our SSH public key on disk. Other wise, diskimage builds will
fail.

Change-Id: I6879d095941fe76d151d3bd9e590b1f691c146e2
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2016-11-29 11:10:42 -05:00
parent 799dbee521
commit c2e9f66d73
2 changed files with 36 additions and 19 deletions

View File

@ -16,6 +16,7 @@
#
class nodepool::builder(
$statsd_host = undef,
$nodepool_ssh_public_key = undef,
$image_log_document_root = '/var/log/nodepool/image',
$builder_logging_conf_template = 'nodepool/nodepool-builder.logging.conf.erb',
$environment = {},
@ -25,6 +26,27 @@ class nodepool::builder(
include ::diskimage_builder
if ! defined(File['/home/nodepool/.ssh']) {
file { '/home/nodepool/.ssh':
ensure => directory,
mode => '0500',
owner => 'nodepool',
group => 'nodepool',
require => User['nodepool'],
}
}
if ($nodepool_ssh_public_key != undef) {
file { '/home/nodepool/.ssh/id_rsa.pub':
ensure => present,
content => $nodepool_ssh_public_key,
mode => '0644',
owner => 'nodepool',
group => 'nodepool',
require => File['/home/nodepool/.ssh'],
}
}
file { '/etc/init.d/nodepool-builder':
ensure => present,
mode => '0555',

View File

@ -208,14 +208,6 @@ class nodepool (
require => User['nodepool'],
}
file { '/home/nodepool/.ssh':
ensure => directory,
mode => '0500',
owner => 'nodepool',
group => 'nodepool',
require => User['nodepool'],
}
file { '/home/nodepool/.ssh/id_rsa':
ensure => present,
content => $nodepool_ssh_private_key,
@ -225,17 +217,6 @@ class nodepool (
require => File['/home/nodepool/.ssh'],
}
if ($nodepool_ssh_public_key != undef) {
file { '/home/nodepool/.ssh/id_rsa.pub':
ensure => present,
content => $nodepool_ssh_public_key,
mode => '0644',
owner => 'nodepool',
group => 'nodepool',
require => File['/home/nodepool/.ssh'],
}
}
file { '/home/nodepool/.ssh/config':
ensure => present,
source => 'puppet:///modules/nodepool/ssh.config',
@ -450,11 +431,25 @@ class nodepool (
if ($install_nodepool_builder) {
class { '::nodepool::builder':
nodepool_ssh_public_key => $nodepool_ssh_public_key,
statsd_host => $statsd_host,
environment => $environment,
builder_logging_conf_template => $builder_logging_conf_template,
build_workers => $build_workers,
upload_workers => $upload_workers,
}
} else {
# For now, conditionally include this, since this code also lives in
# nodepool-builder. One things have settled down with zuulv3 effort, we
# should refactor this into a common.pp file.
if ! defined(File['/home/nodepool/.ssh']) {
file { '/home/nodepool/.ssh':
ensure => directory,
mode => '0500',
owner => 'nodepool',
group => 'nodepool',
require => User['nodepool'],
}
}
}
}