Skip to content

Commit

Permalink
Refs #34239 - [rex_ssh] Install mosquitto with 'pull-mqtt' mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wbclark committed Feb 9, 2022
1 parent aebbec7 commit 7435214
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 28 deletions.
60 changes: 32 additions & 28 deletions manifests/plugin/remote_execution/ssh.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,44 @@
listen_on => $listen_on,
}

if $ssh_kerberos_auth {
$kerberos_pkg = "${foreman_proxy::params::ruby_package_prefix}net-ssh-krb"
package { $kerberos_pkg:
ensure => present,
if $mode =~ /ssh/ {
if $ssh_kerberos_auth {
$kerberos_pkg = "${foreman_proxy::params::ruby_package_prefix}net-ssh-krb"
package { $kerberos_pkg:
ensure => present,
}
}
}

if $generate_keys {
file { $ssh_identity_dir:
ensure => directory,
owner => $foreman_proxy::user,
group => $foreman_proxy::user,
mode => '0700',
}
-> exec { 'generate_ssh_key':
command => "${ssh_keygen} -f ${ssh_identity_path} -N '' -m pem",
user => $foreman_proxy::user,
cwd => $ssh_identity_dir,
creates => $ssh_identity_path,
}
if $install_key {
# Ensure the .ssh directory exists with the right permissions
file { '/root/.ssh':
if $generate_keys {
file { $ssh_identity_dir:
ensure => directory,
owner => 'root',
group => 'root',
owner => $foreman_proxy::user,
group => $foreman_proxy::user,
mode => '0700',
}
-> exec { 'install_ssh_key':
path => '/usr/bin:/usr/sbin:/bin',
command => "cat ${ssh_identity_path}.pub >> /root/.ssh/authorized_keys",
unless => "grep -f ${ssh_identity_path}.pub /root/.ssh/authorized_keys",
require => Exec['generate_ssh_key'],
-> exec { 'generate_ssh_key':
command => "${ssh_keygen} -f ${ssh_identity_path} -N '' -m pem",
user => $foreman_proxy::user,
cwd => $ssh_identity_dir,
creates => $ssh_identity_path,
}
if $install_key {
# Ensure the .ssh directory exists with the right permissions
file { '/root/.ssh':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0700',
}
-> exec { 'install_ssh_key':
path => '/usr/bin:/usr/sbin:/bin',
command => "cat ${ssh_identity_path}.pub >> /root/.ssh/authorized_keys",
unless => "grep -f ${ssh_identity_path}.pub /root/.ssh/authorized_keys",
require => Exec['generate_ssh_key'],
}
}
}
} elsif $mode == 'pull-mqtt' {
include mosquitto
}
}
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"name": "puppet/extlib",
"version_requirement": ">= 3.0.0 < 7.0.0"
},
{
"name": "puppet/mosquitto",
"version_requirement": ">= 1.0.1 < 2.0.0"
},
{
"name": "richardc/datacat",
"version_requirement": ">= 0.6.0 < 1.0.0"
Expand Down
4 changes: 4 additions & 0 deletions templates/plugin/remote_execution_ssh.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@

# Whether to run remote execution jobs asynchronously
:mode: <%= scope.lookupvar("::foreman_proxy::plugin::remote_execution::ssh::mode") %>
<% if scope.lookupvar("::foreman_proxy::plugin::remote_execution::ssh::mode") == 'pull-mqtt' -%>
:mqtt_broker: localhost
:mqtt_port: 1883
<% end -%>

0 comments on commit 7435214

Please sign in to comment.