diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7df8e3ae..598d0e3a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -94,6 +94,7 @@ jobs: run: | set -x sudo apt-get remove mysql-server --purge + sudo apt-get update sudo apt-get install apparmor-profiles sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld - uses: actions/checkout@v2 diff --git a/.sync.yml b/.sync.yml index d00bb3e1..e584d946 100644 --- a/.sync.yml +++ b/.sync.yml @@ -65,3 +65,5 @@ spec/acceptance/nodesets/ubuntu-1804.yml: spec/acceptance/nodesets/ubuntu-2004.yml: packages: - iproute2 +spec/acceptance/nodesets/ubuntu-2204.yml: + delete: true diff --git a/lib/puppet/provider/keycloak_conn_validator/puppet_https.rb b/lib/puppet/provider/keycloak_conn_validator/puppet_https.rb index 288812db..9e9680ff 100644 --- a/lib/puppet/provider/keycloak_conn_validator/puppet_https.rb +++ b/lib/puppet/provider/keycloak_conn_validator/puppet_https.rb @@ -59,7 +59,7 @@ def create # If `#create` is called, that means that `#exists?` returned false, which # means that the connection could not be established... so we need to # cause a failure here. - raise Puppet::Error, "Unable to connect to keycloak server! (#{@validator.keycloak_server}:#{@validator.keycloak_port})" + raise Puppet::Error, "Unable to connect to keycloak server! (#{@validator.keycloak_server}:#{@validator.keycloak_port}#{@validator.path})" end # Returns the existing validator, if one exists otherwise creates a new object diff --git a/lib/puppet/util/keycloak_validator.rb b/lib/puppet/util/keycloak_validator.rb index d4e1981c..a21dee50 100644 --- a/lib/puppet/util/keycloak_validator.rb +++ b/lib/puppet/util/keycloak_validator.rb @@ -4,7 +4,7 @@ # Validator class, for testing that Keycloak is alive class Puppet::Util::KeycloakValidator - attr_reader :keycloak_server, :keycloak_port, :use_ssl, :test_path + attr_reader :keycloak_server, :keycloak_port, :use_ssl, :test_path, :relative_path, :path def initialize(keycloak_server, keycloak_port, use_ssl = false, test_path = '/realms/master/.well-known/openid-configuration', relative_path = '/') @keycloak_server = keycloak_server @@ -12,6 +12,11 @@ def initialize(keycloak_server, keycloak_port, use_ssl = false, test_path = '/re @use_ssl = use_ssl @test_path = test_path @relative_path = relative_path + @path = if @relative_path == '/' + @test_path + else + "#{@relative_path}#{@test_path}" + end end # Utility method; attempts to make an http/https connection to the keycloak server. @@ -23,21 +28,20 @@ def attempt_connection # All that we care about is that we are able to connect successfully via # http(s), so here we're simpling hitting a somewhat arbitrary low-impact URL # on the keycloak server. - path = "#{@relative_path}#{@test_path.sub(%r{^/}, '')}" http = Net::HTTP.new(@keycloak_server, @keycloak_port) http.use_ssl = @use_ssl http.verify_mode = OpenSSL::SSL::VERIFY_NONE - request = Net::HTTP::Get.new(path) + request = Net::HTTP::Get.new(@path) request.add_field('Accept', 'application/json') response = http.request(request) unless response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPUnauthorized) - Puppet.notice "Unable to connect to keycloak server (http#{use_ssl ? 's' : ''}://#{keycloak_server}:#{keycloak_port}): [#{response.code}] #{response.msg}" + Puppet.notice "Unable to connect to keycloak server (http#{use_ssl ? 's' : ''}://#{keycloak_server}:#{keycloak_port}#{path}): [#{response.code}] #{response.msg}" return false end true rescue Exception => e # rubocop:disable Lint/RescueException - Puppet.notice "Unable to connect to keycloak server (http#{use_ssl ? 's' : ''}://#{keycloak_server}:#{keycloak_port}): #{e.message}" + Puppet.notice "Unable to connect to keycloak server (http#{use_ssl ? 's' : ''}://#{keycloak_server}:#{keycloak_port}#{path}): #{e.message}" false end end diff --git a/metadata.json b/metadata.json index 11421707..6243181b 100644 --- a/metadata.json +++ b/metadata.json @@ -89,5 +89,5 @@ ], "pdk-version": "2.1.0", "template-url": "https://github.com/treydock/pdk-templates.git#master", - "template-ref": "heads/master-0-g978d356" + "template-ref": "heads/master-0-g4965280" } diff --git a/spec/acceptance/1_class_spec.rb b/spec/acceptance/1_class_spec.rb index 5b6a5104..15d8bd3c 100644 --- a/spec/acceptance/1_class_spec.rb +++ b/spec/acceptance/1_class_spec.rb @@ -69,8 +69,9 @@ class { 'keycloak': it 'runs successfully' do pp = <<-PUPPET_PP class { 'keycloak': - java_opts => '-Xmx512m -Xms64m', - configs => { + http_relative_path => '/auth', + java_opts => '-Xmx512m -Xms64m', + configs => { 'metrics-enabled' => true, }, }