Class: Postgres

Inherits:
Recipe show all
Defined in:
lib/dust/recipes/postgres.rb

Instance Method Summary collapse

Methods inherited from Recipe

#prepare

Instance Method Details

#deployObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dust/recipes/postgres.rb', line 3

def deploy
  # version: 9.1
  # package:  postgresql-9.1
  # profile: [ dedicated|standard, zabbix, pacemaker ]
  # service_name: "service name for init scripts"

  if @node.uses_apt?
    unless @config['version'] or @config['package']
      return @node.messages.add('please specify version or package name in your config file, e.g. "version: 9.1"').failed
    end
  end

  return unless install_postgres

  # default cluster on debian-like systems is 'main'
  @config['cluster'] ||= 'main' if @node.uses_apt?


  set_default_directories
  deploy_config
  deploy_recovery
  deploy_certificates if @config['server.crt'] and @config['server.key']
  set_permissions

  # configure pacemaker profile
  if Array(@config['profile']).include?('pacemaker')
    deploy_pacemaker_script if @node.package_installed?('pacemaker')
  end

  # configure zabbix profile
  if Array(@config['profile']).include?('zabbix')
    configure_for_zabbix if zabbix_installed?
  end

  # enable service to start at boot-time
  @node.autostart_service(@config['service_name'])

  # reload/restart postgres if command line option is given
  @node.restart_service(@config['service_name']) if options.restart?
  @node.reload_service(@config['service_name']) if options.reload?
end

#statusObject



46
47
48
49
50
# File 'lib/dust/recipes/postgres.rb', line 46

def status
  return unless @node.package_installed?([ 'postgresql-server', "postgresql-#{@config['version']}" ])
  set_default_directories
  @node.print_service_status(@config['service_name'])
end