Skip to content

Commit 7435214

Browse files
committed
Refs #34239 - [rex_ssh] Install mosquitto with 'pull-mqtt' mode
1 parent aebbec7 commit 7435214

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

manifests/plugin/remote_execution/ssh.pp

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,44 @@
5454
listen_on => $listen_on,
5555
}
5656

57-
if $ssh_kerberos_auth {
58-
$kerberos_pkg = "${foreman_proxy::params::ruby_package_prefix}net-ssh-krb"
59-
package { $kerberos_pkg:
60-
ensure => present,
57+
if $mode =~ /ssh/ {
58+
if $ssh_kerberos_auth {
59+
$kerberos_pkg = "${foreman_proxy::params::ruby_package_prefix}net-ssh-krb"
60+
package { $kerberos_pkg:
61+
ensure => present,
62+
}
6163
}
62-
}
6364

64-
if $generate_keys {
65-
file { $ssh_identity_dir:
66-
ensure => directory,
67-
owner => $foreman_proxy::user,
68-
group => $foreman_proxy::user,
69-
mode => '0700',
70-
}
71-
-> exec { 'generate_ssh_key':
72-
command => "${ssh_keygen} -f ${ssh_identity_path} -N '' -m pem",
73-
user => $foreman_proxy::user,
74-
cwd => $ssh_identity_dir,
75-
creates => $ssh_identity_path,
76-
}
77-
if $install_key {
78-
# Ensure the .ssh directory exists with the right permissions
79-
file { '/root/.ssh':
65+
if $generate_keys {
66+
file { $ssh_identity_dir:
8067
ensure => directory,
81-
owner => 'root',
82-
group => 'root',
68+
owner => $foreman_proxy::user,
69+
group => $foreman_proxy::user,
8370
mode => '0700',
8471
}
85-
-> exec { 'install_ssh_key':
86-
path => '/usr/bin:/usr/sbin:/bin',
87-
command => "cat ${ssh_identity_path}.pub >> /root/.ssh/authorized_keys",
88-
unless => "grep -f ${ssh_identity_path}.pub /root/.ssh/authorized_keys",
89-
require => Exec['generate_ssh_key'],
72+
-> exec { 'generate_ssh_key':
73+
command => "${ssh_keygen} -f ${ssh_identity_path} -N '' -m pem",
74+
user => $foreman_proxy::user,
75+
cwd => $ssh_identity_dir,
76+
creates => $ssh_identity_path,
77+
}
78+
if $install_key {
79+
# Ensure the .ssh directory exists with the right permissions
80+
file { '/root/.ssh':
81+
ensure => directory,
82+
owner => 'root',
83+
group => 'root',
84+
mode => '0700',
85+
}
86+
-> exec { 'install_ssh_key':
87+
path => '/usr/bin:/usr/sbin:/bin',
88+
command => "cat ${ssh_identity_path}.pub >> /root/.ssh/authorized_keys",
89+
unless => "grep -f ${ssh_identity_path}.pub /root/.ssh/authorized_keys",
90+
require => Exec['generate_ssh_key'],
91+
}
9092
}
9193
}
94+
} elsif $mode == 'pull-mqtt' {
95+
include mosquitto
9296
}
9397
}

metadata.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
"name": "puppet/extlib",
4343
"version_requirement": ">= 3.0.0 < 7.0.0"
4444
},
45+
{
46+
"name": "puppet/mosquitto",
47+
"version_requirement": ">= 1.0.1 < 2.0.0"
48+
},
4549
{
4650
"name": "richardc/datacat",
4751
"version_requirement": ">= 0.6.0 < 1.0.0"

templates/plugin/remote_execution_ssh.yml.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77

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

0 commit comments

Comments
 (0)