Class: Inspec::Resources::Postgres
- Inherits:
-
Object
- Object
- Inspec::Resources::Postgres
- Defined in:
- lib/resources/postgres.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
readonly
Returns the value of attribute cluster.
-
#conf_dir ⇒ Object
readonly
Returns the value of attribute conf_dir.
-
#conf_path ⇒ Object
readonly
Returns the value of attribute conf_path.
-
#data_dir ⇒ Object
readonly
Returns the value of attribute data_dir.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize ⇒ Postgres
constructor
A new instance of Postgres.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Postgres
Returns a new instance of Postgres.
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 44 45 |
# File 'lib/resources/postgres.rb', line 13 def initialize os = inspec.os if os.debian? # # https://wiki.debian.org/PostgreSql # # Debian allows multiple versions of postgresql to be # installed as well as multiple "clusters" to be configured. # @version = version_from_psql || version_from_dir('/etc/postgresql') @cluster = cluster_from_dir("/etc/postgresql/#{@version}") @conf_dir = "/etc/postgresql/#{@version}/#{@cluster}" @data_dir = "/var/lib/postgresql/#{@version}/#{@cluster}" else @version = version_from_psql if @version.nil? if inspec.directory('/var/lib/pgsql/data').exist? warn 'Unable to determine PostgreSQL version: psql did not return a version number and unversioned data directories were found.' nil else @version = version_from_dir('/var/lib/pgsql/') end end @data_dir = locate_data_dir_location_by_version(@version) end @service = 'postgresql' @service += "-#{@version}" if @version.to_f >= 9.4 @conf_dir ||= @data_dir verify_dirs @conf_path = File.join @conf_dir, 'postgresql.conf' end |
Instance Attribute Details
#cluster ⇒ Object (readonly)
Returns the value of attribute cluster.
12 13 14 |
# File 'lib/resources/postgres.rb', line 12 def cluster @cluster end |
#conf_dir ⇒ Object (readonly)
Returns the value of attribute conf_dir.
12 13 14 |
# File 'lib/resources/postgres.rb', line 12 def conf_dir @conf_dir end |
#conf_path ⇒ Object (readonly)
Returns the value of attribute conf_path.
12 13 14 |
# File 'lib/resources/postgres.rb', line 12 def conf_path @conf_path end |
#data_dir ⇒ Object (readonly)
Returns the value of attribute data_dir.
12 13 14 |
# File 'lib/resources/postgres.rb', line 12 def data_dir @data_dir end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
12 13 14 |
# File 'lib/resources/postgres.rb', line 12 def service @service end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/resources/postgres.rb', line 12 def version @version end |
Instance Method Details
#to_s ⇒ Object
47 48 49 |
# File 'lib/resources/postgres.rb', line 47 def to_s 'PostgreSQL' end |