newer pg module
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / lib / puppet / type / postgresql_conn_validator.rb
1 Puppet::Type.newtype(:postgresql_conn_validator) do
2
3   @doc = "Verify that a connection can be successfully established between a node
4           and the PostgreSQL server.  Its primary use is as a precondition to
5           prevent configuration changes from being applied if the PostgreSQL
6           server cannot be reached, but it could potentially be used for other
7           purposes such as monitoring."
8
9   ensurable do
10     defaultvalues
11     defaultto :present
12   end
13
14   newparam(:name, :namevar => true) do
15     desc 'An arbitrary name used as the identity of the resource.'
16   end
17
18   newparam(:db_name) do
19     desc "The name of the database you are trying to validate a connection with."
20   end
21
22   newparam(:db_username) do
23     desc "A user that has access to the target PostgreSQL database."
24   end
25
26   newparam(:db_password) do
27     desc "The password required to access the target PostgreSQL database."
28   end
29
30   newparam(:host) do
31     desc 'The DNS name or IP address of the server where PostgreSQL should be running.'
32   end
33
34   newparam(:port) do
35     desc 'The port that the PostgreSQL server should be listening on.'
36
37     validate do |value|
38       Integer(value)
39     end
40     munge do |value|
41       Integer(value)
42     end
43   end
44
45   newparam(:connect_settings) do
46     desc 'Hash of environment variables for connection to a db.'
47   end
48
49   newparam(:sleep) do
50     desc "The length of sleep time between connection tries."
51
52     validate do |value|
53       Integer(value)
54     end
55     munge do |value|
56       Integer(value)
57     end
58
59     defaultto 2
60   end
61
62   newparam(:tries) do
63     desc "The number of tries to validate the connection to the target PostgreSQL database."
64
65     validate do |value|
66       Integer(value)
67     end
68     munge do |value|
69       Integer(value)
70     end
71
72     defaultto 10
73   end
74
75   newparam(:psql_path) do
76     desc "Path to the psql command."
77   end
78
79   newparam(:run_as) do
80     desc "System user that will run the psql command."
81   end
82
83   newparam(:command) do
84     desc "Command to run against target database."
85
86     defaultto "SELECT 1"
87   end
88 end