Skip to content

Commit

Permalink
Fixes #17296 - Add setting access_unattended_without_build
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock authored and dLobatog committed Nov 25, 2016
1 parent d39ced2 commit 2652dea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/unattended_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def find_host_by_ip_or_mac
end

def allowed_to_install?
(@host.build || @spoof) ? true : head(:method_not_allowed)
(@host.build || @spoof || Setting[:access_unattended_without_build]) ? true : head(:method_not_allowed)
end

# Cleans Certificate and enable autosign. This is run as a before_action for provisioning templates.
Expand Down
1 change: 1 addition & 0 deletions app/models/setting/provisioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def self.load_defaults
self.set('root_pass', N_("Default encrypted root password on provisioned hosts"), nil, N_('Root password')),
self.set('unattended_url', N_("URL hosts will retrieve templates from during build (normally http as many installers don't support https)"), unattended_url, N_('Unattended URL')),
self.set('safemode_render', N_("Enable safe mode config templates rendering (recommended)"), true, N_('Safemode rendering')),
self.set('access_unattended_without_build', N_("Allow access to unattended URLs without build mode being used"), false, N_('Access unattended without build')),
self.set('manage_puppetca', N_("Foreman will automate certificate signing upon provision of new host"), true, N_('Manage PuppetCA')),
self.set('ignore_puppet_facts_for_provisioning', N_("Stop updating IP address and MAC values from Puppet facts (affects all interfaces)"), false, N_('Ignore Puppet facts for provisioning')),
self.set('ignored_interface_identifiers', N_("Ignore interfaces that match these values during facts importing, you can use * wildcard to match names with indexes e.g. macvtap*"), ['lo', 'usb*', 'vnet*', 'macvtap*', '_vdsmdummy_', 'veth*'], N_('Ignore interfaces with matching identifier')),
Expand Down
10 changes: 10 additions & 0 deletions test/controllers/unattended_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ class UnattendedControllerTest < ActionController::TestCase
assert_response :method_not_allowed
end

test "should provide unattened files to hosts which are not in built state when access_unattended_without_build=true" do
@request.env["HTTP_X_RHN_PROVISIONING_MAC_0"] = "eth0 #{@rh_host.mac}"
@request.env['REMOTE_ADDR'] = '10.0.1.2'
Setting[:access_unattended_without_build] = true
get :built
assert_response :created
get :host_template, {:kind => 'provision'}
assert_response :success
end

test "should not provide unattended files to hosts which we don't know about" do
get :host_template, {:kind => 'provision'}
assert_response :not_found
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,8 @@ attributes63:
default: nil
description: 'Encrypted password'
encrypted: true
attributes64:
name: access_unattended_without_build
category: Setting::Provisioning
default: "false"
description: 'Allow access to unattended URLs without build mode being used'

0 comments on commit 2652dea

Please sign in to comment.