Hi,
I wrote a code to identify application type. gving me issue.
Anyone help me
1 require 'rexml/document'
2 require 'facter'
3
4 Facter.add(:application_type) do
5
6 confine :hostname => 'hostname'
7
8 setcode do
9 application_installed = Facter::Core::Execution.exec('hostname -f')
10 # Get the 5th char using slice method to identify Oracle
11 if (application_installed.slice(4,1) =~ /e|f|x|o|w/) then
12 # Get the 6th & 7th char using slice method to identify between Ap plication/Database
13 if(application_installed.slice(5,2)=="db") then
14 puts "Database"
15 end
16 elsif(application_installed.slice(5,2)=="ap") then
17 puts "Oracle"
18 end
19 # Get the 5th char using slice method to identify Infor matica
20 elsif(application_installed.slice(4,1) =~ /a|m|q/) then
21 # Get the 6th & 7th char using slice method to identify between Ap plication/Database
23 if(application_installed.slice(5,2)=="db") then
24 puts "Database"
25 end
26 end
27 elsif(application_installed.slice(5,2)=="ap") then
28 puts "Informatica "
29 end
30 # Get the 5th char using slice method to identify IBM
31 elsif(application_installed.slice(4,1) =~ /r|y|i/) then
32 # Get the 6th & 7th char using slice method to identify between Ap plication/Database
33
34 if(application_installed.slice(5,2)=="db") then
35 puts "Database"
36 end
37 end
38 elsif(application_installed.slice(5,2)=="ap") then
39 puts "IBM"
40 end
41
42 elsif(application_installed.slice(4,3)=="sap") then
puts "Subversion"
44 end
45 elsif(application_installed.slice(4,3)=="ldb") then
46 puts "Database"
47 end
48 else
49 puts "puppet"
50
51 end
52 end
53 end
54 end
55 end
56 end
I am having an issue:
Warning: Could not load fact file /var/opt/lib/pe-puppet/lib/facter/application_type.rb: application_type.rb:20: syntax error, unexpected keyword_elsif, expecting keyword_end
elsif(application_installed.slice(4,1) =~ /a|m|q/) then
^
application_type.rb:20: syntax error, unexpected keyword_then, expecting keyword_end
application_type.rb:27: syntax error, unexpected keyword_elsif, expecting keyword_end
elsif(application_installed.slice(5,2)=="ap") then
^
application_type.rb:27: syntax error, unexpected keyword_then, expecting keyword_end
application_type.rb:31: syntax error, unexpected keyword_elsif, expecting $end
elsif(application_installed.slice(4,1) =~ /r|y|i/) then
^