Skip to content

Commit 7661aae

Browse files
committed
Introduce new get_psql_info task
Reuses library from facter that can report the major version of PSQL installed
1 parent f32d1c5 commit 7661aae

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tasks/get_psql_version.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"description": "Run on a PE PSQL node to return the major version of the PSQL server currently installed",
3+
"parameters": { },
4+
"input_method": "stdin"
5+
}

tasks/get_psql_version.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/opt/puppetlabs/puppet/bin/ruby
2+
# frozen_string_literal: true
3+
4+
require '/opt/puppetlabs/puppet/cache/lib/pe_install/pe_postgresql_info.rb'
5+
6+
# GetPEAdmConfig task class
7+
class GetPSQLInfo
8+
def initialize(params); end
9+
10+
def execute!
11+
psql_info = PEPostgresqlInfo.new
12+
data = { 'version' => psql_info.installed_server_version }
13+
puts data.to_json
14+
end
15+
end
16+
17+
# Run the task unless an environment flag has been set, signaling not to. The
18+
# environment flag is used to disable auto-execution and enable Ruby unit
19+
# testing of this task.
20+
unless ENV['RSPEC_UNIT_TEST_MODE']
21+
Puppet.initialize_settings
22+
task = GetPSQLInfo.new(JSON.parse(STDIN.read))
23+
task.execute!
24+
end

0 commit comments

Comments
 (0)