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

Add rex cockpit integration support #748

Closed
wants to merge 4 commits into from

Conversation

iNecas
Copy link
Member

@iNecas iNecas commented Aug 18, 2019

This adds --foreman-plugin-remote-execution-cockpit boolean option to
add support for cockpit installation.

It enables foreman-cockpit.service (comming from
rubygem-foreman_remote_execution-cockpit package), that provides the
backend service for the cockpit tunel, and configures the settings
and authentication for the whole setup to work.

Requires:

When testing, SELinux needs to be disabled for now, as there are rules missing
for the foreman-cockpit service to work in enforcing mode.

This adds --foreman-plugin-remote-execution-cockpit boolean option to
add support for cockpit installation.

It enables foreman-cockpit.service (comming from
rubygem-foreman_remote_execution-cockpit package), that provides the
backend service for the cockpit tunel, and configures the settings
and authentication for the whole setup to work.
# $cockpit:: Install cockpit support
#
class foreman::plugin::remote_execution (
Boolean $cockpit = $::foreman::plugin::remote_execution::params::cockpit,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok not to inherit if it's a trivial parameter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

}
}

package { $cockpit_package:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can replace this with foreman::plugin { 'remote_execution-cockpit': } and drop the whole package name determination.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

service { 'foreman-cockpit':
ensure => running,
enable => true,
hasstatus => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This defaults to true since puppet 2.7 and can be dropped:

Suggested change
hasstatus => true,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Suggested change
hasrestart => true,

ssl_content => template('foreman/cockpit-apache-ssl.conf.erb'),
}

foreman_config_entry { 'remote_execution_cockpit_url':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be configured? Isn't this the default and can we rely on that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default config is null and it actually determines whether the cockpit integration is enabled or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since /webcon is repeated a few times, perhaps this should be a variable? Doesn't have to be a class parameter but it's a good way to show that they're the same thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

### File managed with puppet ###

<Location /webcon>
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use LoadModule this way. In the class you should include apache::mod::proxy_wstunnel.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


<Location /webcon>
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with include apache::mod::proxy_http

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

templates/remote_execution_cockpit.conf.erb Outdated Show resolved Hide resolved
templates/remote_execution_cockpit_session.yml.erb Outdated Show resolved Hide resolved
Co-Authored-By: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
Co-Authored-By: Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
@iNecas
Copy link
Member Author

iNecas commented Sep 2, 2019

Ready for review again

@@ -0,0 +1,11 @@
### File managed with puppet ###

<Location /<%= scope.lookupvar("cockpit_subpath") %>>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the local scope so this is sufficient:

Suggested change
<Location /<%= scope.lookupvar("cockpit_subpath") %>>
<Location /<%= @cockpit_subpath %>>


RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /<%= scope.lookupvar("cockpit_subpath") %>/(.*) ws://127.0.0.1:9999/<%= scope.lookupvar("cockpit_subpath") %>/$1 [P]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RewriteRule /<%= scope.lookupvar("cockpit_subpath") %>/(.*) ws://127.0.0.1:9999/<%= scope.lookupvar("cockpit_subpath") %>/$1 [P]
RewriteRule /<%= @cockpit_subpath %>/(.*) ws://127.0.0.1:9999/<%= @cockpit_subpath %>/$1 [P]

RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /<%= scope.lookupvar("cockpit_subpath") %>/(.*) ws://127.0.0.1:9999/<%= scope.lookupvar("cockpit_subpath") %>/$1 [P]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /<%= scope.lookupvar("cockpit_subpath") %>/(.*) http://127.0.0.1:9999/<%= scope.lookupvar("cockpit_subpath") %>/$1 [P]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RewriteRule /<%= scope.lookupvar("cockpit_subpath") %>/(.*) http://127.0.0.1:9999/<%= scope.lookupvar("cockpit_subpath") %>/$1 [P]
RewriteRule /<%= @cockpit_subpath %>/(.*) http://127.0.0.1:9999/<%= @cockpit_subpath %>/$1 [P]

@@ -0,0 +1,14 @@
[WebService]
LoginTitle = Foreman Cockpit
UrlRoot = /<%= scope.lookupvar("cockpit_subpath") %>/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UrlRoot = /<%= scope.lookupvar("cockpit_subpath") %>/
UrlRoot = /<%= @cockpit_subpath %>/

include ::foreman::plugin::tasks
include apache::mod::proxy_wstunnel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this into the if $cockpit block?

$cockpit_subpath = 'webcon'

if $cockpit {
if $::osfamily != 'RedHat' {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit on the fence about this. Is there a reason why it can't work on Debian?

enable => true,
}

file { '/etc/foreman/cockpit/cockpit.conf':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the package creates /etc/foreman/cockpit then it also needs a require on Foreman::Plugin['remote_execution-cockpit']. Otherwise you need to ensure the directory exists.

@iNecas
Copy link
Member Author

iNecas commented Sep 23, 2019

Unfortunately, my focus has already shifted quite far from this PR, therefore I would suggest someone else to pick this up to finish the comments. @ekohl with you Puppet experience, it seems like it might be quite low hanging fruit for you to shape it the way you need? Otherwise, reaching to @ares to try to find another set of hands for this one. It could be good also for actually sharing some knowledge about this functionality.

@tstrych
Copy link

tstrych commented Sep 24, 2019

Not sure if this helps, but I was able with @adamruzicka help to install theforeman/foreman-packaging#3816 and patch it with this PR and cockpit seems to work correctly.

Hopefully this will be merged soon, as this is last step from developer side of work, for now.

@@ -0,0 +1,4 @@
:foreman_url: <%= scope.lookupvar("foreman::foreman_url") %>
:ssl_ca_file: <%= scope.lookupvar("foreman::client_ssl_ca") %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm picking this up, but why are these needed? From reading the docs this appears to be to connect back to Foreman. It's not guarantees these certs actually work for that. When connecting to Foreman itself you should use the server CA.

Since you're moving away from Foreman, should I pick this up with @adamruzicka?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack on that, it should probably be the server ca

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking over this.

@ekohl
Copy link
Member

ekohl commented Sep 24, 2019

Replaced by #760

@ekohl ekohl closed this Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants