Skip to content

Commit 3430e52

Browse files
committed
Create method to convert to master the slave node
1 parent a5bf5e2 commit 3430e52

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

resources/libraries/helper.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ def postgres_role
2828
nil
2929
end
3030

31+
def convert_to_master
32+
commands = [
33+
'touch /tmp/postgresql.trigger',
34+
'sed -i "/^primary_conninfo/d; /^promote_trigger_file/d" /var/lib/pgsql/data/postgresql.conf'
35+
]
36+
37+
commands.each do |cmd|
38+
full_cmd = "rbcli node execute all -- '#{cmd}'"
39+
system(full_cmd)
40+
end
41+
end
42+
3143
def update_hosts_for_master(new_master_ip)
3244
hosts_file = '/etc/hosts'
3345
service_name = 'master.postgresql.service'
@@ -38,7 +50,7 @@ def update_hosts_for_master(new_master_ip)
3850
hosts_content << "#{new_entry}\n"
3951
::File.open(hosts_file, 'w') { |file| file.puts hosts_content }
4052
rescue => e
41-
Chef::Log.error("Error actualizando /etc/hosts: #{e.message}")
53+
Chef::Log.error("Error updating /etc/hosts: #{e.message}")
4254
end
4355
end
4456

resources/resources/config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
attribute :postgresql_port, kind_of: Integer, default: 5432
99
attribute :cdomain, kind_of: String, default: 'redborder.cluster'
1010
attribute :ipaddress, kind_of: String, default: '127.0.0.1'
11+
attribute :virtual_ips, kind_of: Hash, default: {}

0 commit comments

Comments
 (0)