Skip to content

Commit e664e36

Browse files
committed
Update Fedora initdb commands
Signed-off-by: Dan Webb <[email protected]>
1 parent 259bc83 commit e664e36

File tree

8 files changed

+25
-20
lines changed

8 files changed

+25
-20
lines changed

documentation/postgresql_ident.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ postgresql_access 'local_foo_user' do
6060
database 'all'
6161
user 'foo'
6262
address '127.0.0.1/32'
63-
auth_method 'md5'
63+
auth_method 'scram-sha-256'
6464
end
6565
```
6666

libraries/helpers.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def default_yum_gpg_key_uri
152152
if platform_family?('rhel') && node['platform_version'].to_i == 7
153153
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL7'
154154
elsif platform_family?('fedora')
155-
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-KEY-fedora'
155+
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-Fedora'
156156
else
157157
'https://download.postgresql.org/pub/repos/yum/keys/PGDG-RPM-GPG-KEY-RHEL'
158158
end
@@ -173,6 +173,10 @@ def rhel_init_db_command(new_resource)
173173
cmd << " -D '#{data_dir}'"
174174
end
175175

176+
def fedora_init_db_command
177+
'usr/bin/postgresql-setup --initdb'
178+
end
179+
176180
# Given the base URL build the complete URL string for a yum repo
177181
def yum_repo_url(base_url)
178182
"#{base_url}/#{new_resource.version}/#{yum_repo_platform_family_string}/#{yum_repo_platform_string}"

resources/install.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ def install_method_repo?
9898
def do_repository_action(repo_action)
9999
case node['platform_family']
100100
when 'rhel', 'fedora', 'amazon'
101+
# Disable the PostgreSQL module if we're on RHEL 8 not on fedora
101102
dnf_module 'postgresql' do
102103
action :disable
103-
end if dnf_module_platform?
104+
end if dnf_module_platform? && !platform_family?('fedora')
104105

105106
remote_file '/etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY' do
106107
source new_resource.yum_gpg_key_uri
@@ -272,7 +273,7 @@ def do_server_package_action(package_action)
272273

273274
converge_by('Init PostgreSQL') do
274275
execute 'init_db' do
275-
command rhel_init_db_command(new_resource)
276+
command platform_family?('fedora') ? fedora_init_db_command : rhel_init_db_command(new_resource)
276277
user new_resource.initdb_user
277278
end
278279
end

test/cookbooks/test/recipes/access.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
database 'all'
1010
user 'postgres'
1111
address '127.0.0.1/32'
12-
auth_method 'md5'
12+
auth_method 'scram-sha-256'
1313
end
1414

1515
postgresql_service 'postgresql' do
@@ -45,7 +45,7 @@
4545
type 'host'
4646
database 'all'
4747
user 'sous_chef'
48-
auth_method 'md5'
48+
auth_method 'scram-sha-256'
4949
address '127.0.0.1/32'
5050
position 5
5151

@@ -74,7 +74,7 @@
7474
type 'host'
7575
database 'all'
7676
user 'hostname_user'
77-
auth_method 'md5'
77+
auth_method 'scram-sha-256'
7878
address 'host.domain'
7979

8080
notifies :restart, 'postgresql_service[postgresql]', :delayed
@@ -84,7 +84,7 @@
8484
type 'host'
8585
database 'all'
8686
user 'hostname.user'
87-
auth_method 'md5'
87+
auth_method 'scram-sha-256'
8888
address 'host.domain'
8989

9090
notifies :restart, 'postgresql_service[postgresql]', :delayed
@@ -94,7 +94,7 @@
9494
type 'host'
9595
database 'my_database'
9696
user 'hostname.user'
97-
auth_method 'md5'
97+
auth_method 'scram-sha-256'
9898
address 'host.domain'
9999

100100
notifies :restart, 'postgresql_service[postgresql]', :delayed
@@ -104,7 +104,7 @@
104104
type 'host'
105105
database 'my_database'
106106
user 'hostname.user'
107-
auth_method 'md5'
107+
auth_method 'scram-sha-256'
108108
address 'a.very.long.host.domain.that.exceeds.the.max.of.24.characters'
109109

110110
notifies :restart, 'postgresql_service[postgresql]', :delayed
@@ -135,5 +135,5 @@
135135
database 'foo,bar'
136136
user 'john,doe'
137137
address '127.0.0.1/32'
138-
auth_method 'md5'
138+
auth_method 'scram-sha-256'
139139
end

test/cookbooks/test/recipes/ident.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
database 'all'
5151
user 'postgres'
5252
address '127.0.0.1/32'
53-
auth_method 'md5'
53+
auth_method 'scram-sha-256'
5454

5555
notifies :reload, 'postgresql_service[postgresql]', :delayed
5656
end

test/cookbooks/test/recipes/server_install_os.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
database 'all'
4242
user 'postgres'
4343
address '127.0.0.1/32'
44-
auth_method 'md5'
44+
auth_method 'scram-sha-256'
4545
end
4646

4747
postgresql_user 'postgres' do
@@ -77,7 +77,7 @@
7777
type 'host'
7878
database 'all'
7979
user 'sous_chef'
80-
auth_method 'md5'
80+
auth_method 'scram-sha-256'
8181
address '127.0.0.1/32'
8282

8383
notifies :restart, 'postgresql_service[postgresql]', :delayed

test/integration/access/controls/base_access.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
describe postgres_hba_conf.where { type == 'host' && user == 'postgres' } do
66
its('database') { should cmp 'all' }
77
its('user') { should cmp 'postgres' }
8-
its('auth_method') { should cmp 'md5' }
8+
its('auth_method') { should cmp 'scram-sha-256' }
99
its('address') { should cmp '127.0.0.1/32' }
1010
end
1111

@@ -23,7 +23,7 @@
2323
describe postgres_hba_conf.where { user == 'sous_chef' } do
2424
its('database') { should cmp 'all' }
2525
its('type') { should cmp 'host' }
26-
its('auth_method') { should cmp 'md5' }
26+
its('auth_method') { should cmp 'scram-sha-256' }
2727
its('address') { should cmp '127.0.0.1/32' }
2828
end
2929

@@ -41,7 +41,7 @@
4141
describe postgres_hba_conf.where { user == 'hostname_user' } do
4242
its('database') { should cmp 'all' }
4343
its('type') { should cmp 'host' }
44-
its('auth_method') { should cmp 'md5' }
44+
its('auth_method') { should cmp 'scram-sha-256' }
4545
its('address') { should cmp 'host.domain' }
4646
end
4747
end
@@ -53,7 +53,7 @@
5353
describe postgres_hba_conf.where { address == 'a.very.long.host.domain.that.exceeds.the.max.of.24.characters' } do
5454
its('database') { should cmp 'my_database' }
5555
its('type') { should cmp 'host' }
56-
its('auth_method') { should cmp 'md5' }
56+
its('auth_method') { should cmp 'scram-sha-256' }
5757
its('address') { should cmp 'a.very.long.host.domain.that.exceeds.the.max.of.24.characters' }
5858
end
5959
end

test/integration/server_install_os/controls/access.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
describe postgres_hba_conf.where { type == 'host' && user == 'postgres' } do
66
its('database') { should cmp 'all' }
77
its('user') { should cmp 'postgres' }
8-
its('auth_method') { should cmp 'md5' }
8+
its('auth_method') { should cmp 'scram-sha-256' }
99
its('address') { should cmp '127.0.0.1/32' }
1010
end
1111

@@ -23,7 +23,7 @@
2323
describe postgres_hba_conf.where { user == 'sous_chef' } do
2424
its('database') { should cmp 'all' }
2525
its('type') { should cmp 'host' }
26-
its('auth_method') { should cmp 'md5' }
26+
its('auth_method') { should cmp 'scram-sha-256' }
2727
its('address') { should cmp '127.0.0.1/32' }
2828
end
2929

0 commit comments

Comments
 (0)