diff --git a/documentation/postgresql_ident.md b/documentation/postgresql_ident.md index 06ff1daf..dcb2f016 100644 --- a/documentation/postgresql_ident.md +++ b/documentation/postgresql_ident.md @@ -60,7 +60,7 @@ postgresql_access 'local_foo_user' do database 'all' user 'foo' address '127.0.0.1/32' - auth_method 'md5' + auth_method 'scram-sha-256' end ``` diff --git a/libraries/helpers.rb b/libraries/helpers.rb index 7bc7abb9..b9e6a93e 100644 --- a/libraries/helpers.rb +++ b/libraries/helpers.rb @@ -152,7 +152,7 @@ def default_yum_gpg_key_uri if platform_family?('rhel') && node['platform_version'].to_i == 7 'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL7' elsif platform_family?('fedora') - 'https://download.postgresql.org/pub/repos/yum/keys/PGDG-KEY-fedora' + 'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-Fedora' else 'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL' end @@ -173,6 +173,10 @@ def rhel_init_db_command(new_resource) cmd << " -D '#{data_dir}'" end + def fedora_init_db_command + 'usr/bin/postgresql-setup --initdb' + end + # Given the base URL build the complete URL string for a yum repo def yum_repo_url(base_url) "#{base_url}/#{new_resource.version}/#{yum_repo_platform_family_string}/#{yum_repo_platform_string}" diff --git a/resources/install.rb b/resources/install.rb index b59a50d6..ad1f0fd3 100644 --- a/resources/install.rb +++ b/resources/install.rb @@ -98,9 +98,10 @@ def install_method_repo? def do_repository_action(repo_action) case node['platform_family'] when 'rhel', 'fedora', 'amazon' + # Disable the PostgreSQL module if we're on RHEL 8 not on fedora dnf_module 'postgresql' do action :disable - end if dnf_module_platform? + end if dnf_module_platform? && !platform_family?('fedora') remote_file '/etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY' do source new_resource.yum_gpg_key_uri @@ -272,7 +273,7 @@ def do_server_package_action(package_action) converge_by('Init PostgreSQL') do execute 'init_db' do - command rhel_init_db_command(new_resource) + command platform_family?('fedora') ? fedora_init_db_command : rhel_init_db_command(new_resource) user new_resource.initdb_user end end diff --git a/test/cookbooks/test/recipes/access.rb b/test/cookbooks/test/recipes/access.rb index a6853eb6..c88ceba0 100644 --- a/test/cookbooks/test/recipes/access.rb +++ b/test/cookbooks/test/recipes/access.rb @@ -9,7 +9,7 @@ database 'all' user 'postgres' address '127.0.0.1/32' - auth_method 'md5' + auth_method 'scram-sha-256' end postgresql_service 'postgresql' do @@ -45,7 +45,7 @@ type 'host' database 'all' user 'sous_chef' - auth_method 'md5' + auth_method 'scram-sha-256' address '127.0.0.1/32' position 5 @@ -74,7 +74,7 @@ type 'host' database 'all' user 'hostname_user' - auth_method 'md5' + auth_method 'scram-sha-256' address 'host.domain' notifies :restart, 'postgresql_service[postgresql]', :delayed @@ -84,7 +84,7 @@ type 'host' database 'all' user 'hostname.user' - auth_method 'md5' + auth_method 'scram-sha-256' address 'host.domain' notifies :restart, 'postgresql_service[postgresql]', :delayed @@ -94,7 +94,7 @@ type 'host' database 'my_database' user 'hostname.user' - auth_method 'md5' + auth_method 'scram-sha-256' address 'host.domain' notifies :restart, 'postgresql_service[postgresql]', :delayed @@ -104,7 +104,7 @@ type 'host' database 'my_database' user 'hostname.user' - auth_method 'md5' + auth_method 'scram-sha-256' address 'a.very.long.host.domain.that.exceeds.the.max.of.24.characters' notifies :restart, 'postgresql_service[postgresql]', :delayed @@ -135,5 +135,5 @@ database 'foo,bar' user 'john,doe' address '127.0.0.1/32' - auth_method 'md5' + auth_method 'scram-sha-256' end diff --git a/test/cookbooks/test/recipes/ident.rb b/test/cookbooks/test/recipes/ident.rb index 588d17da..8626e53c 100644 --- a/test/cookbooks/test/recipes/ident.rb +++ b/test/cookbooks/test/recipes/ident.rb @@ -50,7 +50,7 @@ database 'all' user 'postgres' address '127.0.0.1/32' - auth_method 'md5' + auth_method 'scram-sha-256' notifies :reload, 'postgresql_service[postgresql]', :delayed end diff --git a/test/cookbooks/test/recipes/server_install_os.rb b/test/cookbooks/test/recipes/server_install_os.rb index 6a137069..414b4b5b 100644 --- a/test/cookbooks/test/recipes/server_install_os.rb +++ b/test/cookbooks/test/recipes/server_install_os.rb @@ -41,7 +41,7 @@ database 'all' user 'postgres' address '127.0.0.1/32' - auth_method 'md5' + auth_method 'scram-sha-256' end postgresql_user 'postgres' do @@ -77,7 +77,7 @@ type 'host' database 'all' user 'sous_chef' - auth_method 'md5' + auth_method 'scram-sha-256' address '127.0.0.1/32' notifies :restart, 'postgresql_service[postgresql]', :delayed