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.
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 44 45 46 47 48 |
# File 'lib/resources/postgres.rb', line 11 def initialize if inspec.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 if !@version.nil? && !@conf_dir.empty? @conf_path = File.join @conf_dir, 'postgresql.conf' else @conf_path = nil return skip_resource 'Seems like PostgreSQL is not installed on your system' end end |
Instance Attribute Details
#cluster ⇒ Object (readonly)
Returns the value of attribute cluster.
10 11 12 |
# File 'lib/resources/postgres.rb', line 10 def cluster @cluster end |
#conf_dir ⇒ Object (readonly)
Returns the value of attribute conf_dir.
10 11 12 |
# File 'lib/resources/postgres.rb', line 10 def conf_dir @conf_dir end |
#conf_path ⇒ Object (readonly)
Returns the value of attribute conf_path.
10 11 12 |
# File 'lib/resources/postgres.rb', line 10 def conf_path @conf_path end |
#data_dir ⇒ Object (readonly)
Returns the value of attribute data_dir.
10 11 12 |
# File 'lib/resources/postgres.rb', line 10 def data_dir @data_dir end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
10 11 12 |
# File 'lib/resources/postgres.rb', line 10 def service @service end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/resources/postgres.rb', line 10 def version @version end |
Instance Method Details
#to_s ⇒ Object
50 51 52 |
# File 'lib/resources/postgres.rb', line 50 def to_s 'PostgreSQL' end |