1 class sysconfig::handle ( |
1 class sysconfig::handle ( |
2 $hdl_host = hiera('sysconfig::params::hdl_host', $sysconfig::params::hdl_host), |
2 $hdl_host = hiera('sysconfig::params::hdl_host', $sysconfig::params::hdl_host), |
3 $hdl_user = hiera('sysconfig::params::hdl_user', $sysconfig::params::hdl_user), |
3 $hdl_user = hiera('sysconfig::params::hdl_user', $sysconfig::params::hdl_user), |
4 $hdl_srv_port = hiera('sysconfig::params::hdl_srv_port', $sysconfig::params::hdl_srv_port), |
4 $hdl_srv_port = hiera('sysconfig::params::hdl_srv_port', $sysconfig::params::hdl_srv_port), |
5 $hdl_web_port = hiera('sysconfig::params::hdl_web_port', $sysconfig::params::hdl_web_port), |
5 $hdl_web_port = hiera('sysconfig::params::hdl_web_port', $sysconfig::params::hdl_web_port), |
6 $hdl_key_pswd = hiera('sysconfig::params::hdl_key_pswd', $sysconfig::params::hdl_key_pswd), |
6 $hdl_key_pswd = hiera('sysconfig::params::hdl_key_pswd', $sysconfig::params::hdl_key_pswd), |
7 $hdl_prefix = hiera('sysconfig::params::hdl_prefix', $sysconfig::params::hdl_prefix), |
7 $hdl_prefix = hiera('sysconfig::params::hdl_prefix', $sysconfig::params::hdl_prefix), |
8 $hdl_db_name = hiera('sysconfig::params::hdl_db_name', $sysconfig::params::hdl_db_name), |
8 $hdl_prefix_admin = hiera('sysconfig::params::hdl_prefix_admin', $sysconfig::params::hdl_prefix_admin), |
9 $db_user = hiera('sysconfig::params::db_user', $sysconfig::params::db_user), |
9 $hdl_db_name = hiera('sysconfig::params::hdl_db_name', $sysconfig::params::hdl_db_name), |
10 $db_pw = hiera('sysconfig::params::db_pw', $sysconfig::params::db_pw), |
10 $db_user = hiera('sysconfig::params::db_user', $sysconfig::params::db_user), |
11 $db_host = hiera('sysconfig::params::db_host', $sysconfig::params::db_host) |
11 $db_pw = hiera('sysconfig::params::db_pw', $sysconfig::params::db_pw), |
|
12 $db_host = hiera('sysconfig::params::db_host', $sysconfig::params::db_host) |
12 ) inherits sysconfig::params { |
13 ) inherits sysconfig::params { |
13 |
14 |
14 # iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 1080 |
15 # iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 1080 |
15 |
16 |
16 notify {'handle': name => "\$hdl_host : ${hdl_host}, \$hdl_srv_port : ${hdl_srv_port}, \$hdl_web_port : ${hdl_web_port}", withpath => true } |
17 notify {'handle': name => "\$hdl_host : ${hdl_host}, \$hdl_srv_port : ${hdl_srv_port}, \$hdl_web_port : ${hdl_web_port}", withpath => true } |
17 |
18 |
18 $handle_dirs = [ |
19 $handle_dirs = [ |
19 "/opt/handle", |
20 "/opt/handle", |
20 "/opt/handle/sbin", |
21 "/opt/handle/sbin" |
21 "/tmp/handle" |
|
22 ] |
22 ] |
23 |
23 |
24 group { "$hdl_user": |
24 group { "$hdl_user": |
25 ensure => present, |
25 ensure => present, |
26 }-> |
26 }-> |
60 file { '/opt/handle/lib/mysql-connector-java-5.1.38-bin.jar': |
65 file { '/opt/handle/lib/mysql-connector-java-5.1.38-bin.jar': |
61 ensure => file, |
66 ensure => file, |
62 source => "puppet:///modules/sysconfig/handle/mysql-connector-java-5.1.38-bin.jar", |
67 source => "puppet:///modules/sysconfig/handle/mysql-connector-java-5.1.38-bin.jar", |
63 mode => "0644" |
68 mode => "0644" |
64 }-> |
69 }-> |
|
70 file { "/tmp/handle/handle_init_script.exp": |
|
71 ensure => file, |
|
72 content => template("sysconfig/handle/handle_script.exp.erb"), |
|
73 owner => "$hdl_user", |
|
74 group => "$hdl_user", |
|
75 mode => "0750" |
|
76 }-> |
|
77 exec { "init-handle": |
|
78 command => "/tmp/handle/handle_init_script.exp", |
|
79 cwd => "/opt/handle/bin", |
|
80 provider => 'shell', |
|
81 creates => "/var/lib/handle/sitebndl.zip", |
|
82 user => $hdl_user, |
|
83 notify => Exec['rm-tmp-handle'], |
|
84 require => [Package['java-install'], Package['expect']] |
|
85 }-> |
|
86 file { "/var/lib/handle/config.dct": |
|
87 ensure => file, |
|
88 owner => "$hdl_user", |
|
89 group => "$hdl_user", |
|
90 content => template("sysconfig/handle/handle_config.dct.erb"), |
|
91 replace => true |
|
92 } |
|
93 |
|
94 # create handle admin handle keys |
|
95 file { "/tmp/handle/handle_script_corpus_admin_keys.exp": |
|
96 ensure => file, |
|
97 source => "puppet:///modules/sysconfig/handle/handle_script_corpus_admin_keys.exp", |
|
98 owner => "$hdl_user", |
|
99 group => "$hdl_user", |
|
100 mode => "0750" |
|
101 }-> |
|
102 exec { "init-handle-corpus-admin-keys": |
|
103 command => "/tmp/handle/handle_script_corpus_admin_keys.exp", |
|
104 cwd => "/opt/handle/bin", |
|
105 provider => 'shell', |
|
106 creates => "/var/lib/handle/corpusadmpriv.bin", |
|
107 user => $hdl_user, |
|
108 notify => Exec['rm-tmp-handle-corpus-admin-key'], |
|
109 require => [Archive["handle-8.1"], Package['java-install'], Package['expect']] |
|
110 } |
|
111 |
|
112 file { '/tmp/handle/handle_data.sql.sh': |
|
113 ensure => file, |
|
114 content => template("sysconfig/handle/handle_data.sql.sh.erb"), |
|
115 owner => "$hdl_user", |
|
116 group => "$hdl_user", |
|
117 mode => "0750" |
|
118 } |
|
119 |
|
120 exec { "init_handle_db_data": |
|
121 command => "/tmp/handle/handle_data.sql.sh", |
|
122 creates => "/tmp/handle/handle_data.sql", |
|
123 user => $hdl_user, |
|
124 require => [File['/tmp/handle/handle_data.sql.sh'], Exec['init-handle-corpus-admin-keys']] |
|
125 } |
|
126 |
65 file { '/tmp/handle/handle_db.sql': |
127 file { '/tmp/handle/handle_db.sql': |
66 ensure => file, |
128 ensure => file, |
67 source => "puppet:///modules/sysconfig/handle/handle_db.sql", |
129 source => "puppet:///modules/sysconfig/handle/handle_db.sql", |
68 owner => "$hdl_user", |
130 owner => "$hdl_user", |
69 group => "$hdl_user", |
131 group => "$hdl_user", |
70 mode => "0750" |
132 mode => "0750" |
71 }-> |
133 } |
|
134 |
72 mysql::db { "handle_db": |
135 mysql::db { "handle_db": |
73 dbname => $hdl_db_name, |
136 dbname => $hdl_db_name, |
74 user => $db_user, |
137 user => $db_user, |
75 password => $db_pw, |
138 password => $db_pw, |
76 host => $db_host, |
139 host => $db_host, |
77 sql => '/tmp/handle/handle_db.sql', |
140 sql => ['/tmp/handle/handle_db.sql', '/tmp/handle/handle_data.sql'], |
78 charset => 'utf8', |
141 charset => 'utf8', |
79 collate => 'utf8_general_ci', |
142 collate => 'utf8_general_ci', |
80 notify => Exec['rm-tmp-handle-db'], |
143 notify => [Exec['rm-tmp-handle-db'], Exec['rm-tmp-handle-data']], |
81 require => Service["mariadb"], |
144 require => [Service["mariadb"], File['/tmp/handle/handle_db.sql'], Exec['init_handle_db_data']], |
82 }-> |
145 } |
83 file { "/tmp/handle/handle_init_script.exp": |
146 |
84 ensure => file, |
|
85 content => template("sysconfig/handle/handle_script.exp.erb"), |
|
86 owner => "$hdl_user", |
|
87 group => "$hdl_user", |
|
88 mode => "0750" |
|
89 }-> |
|
90 exec { "init-handle": |
|
91 command => "/tmp/handle/handle_init_script.exp", |
|
92 cwd => "/opt/handle/bin", |
|
93 provider => 'shell', |
|
94 creates => "/var/lib/handle/sitebndl.zip", |
|
95 user => $hdl_user, |
|
96 notify => Exec['rm-tmp-handle'], |
|
97 require => [Package['java-install'], Package['expect']] |
|
98 }-> |
|
99 file { "/var/lib/handle/config.dct": |
|
100 ensure => file, |
|
101 owner => "$hdl_user", |
|
102 group => "$hdl_user", |
|
103 content => template("sysconfig/handle/handle_config.dct.erb"), |
|
104 replace => true |
|
105 }-> |
|
106 exec { "handle-first-start": |
147 exec { "handle-first-start": |
107 command => "/usr/bin/echo \"${HANDLE_KEY_PSWD}\" | /opt/handle/bin/hdl-server /var/lib/handle &", |
148 command => "/usr/bin/echo \"${HANDLE_KEY_PSWD}\" | /opt/handle/bin/hdl-server /var/lib/handle &", |
108 provider => 'shell', |
149 provider => 'shell', |
109 creates => "/var/lib/handle/.handle_initialized", |
150 creates => "/var/lib/handle/.handle_initialized", |
110 user => $hdl_user, |
151 user => $hdl_user, |
111 require => File['/etc/sysconfig/handle'] |
152 require => [File['/etc/sysconfig/handle'], File['/var/lib/handle/config.dct'], Mysql::Db['handle_db']] |
112 }-> |
153 }-> |
113 exec { "handle-first-stop": |
154 exec { "handle-first-stop": |
114 command => "/usr/bin/sleep 10 && rm -f /var/lib/handle/delete_this_to_stop_server && touch /var/lib/handle/.handle_initialized", |
155 command => "/usr/bin/sleep 10 && rm -f /var/lib/handle/delete_this_to_stop_server && touch /var/lib/handle/.handle_initialized", |
115 provider => 'shell', |
156 provider => 'shell', |
116 creates => "/var/lib/handle/.handle_initialized", |
157 creates => "/var/lib/handle/.handle_initialized", |
117 user => $hdl_user, |
158 user => $hdl_user |
118 require => File['/etc/sysconfig/handle'] |
|
119 }-> |
159 }-> |
120 file_line { "handle-detached-prefix": |
160 file_line { "handle-detached-prefix": |
121 path => "/var/lib/handle/config.dct", |
161 path => "/var/lib/handle/config.dct", |
122 match => "\s*\"300:0.NA/$hdl_prefix\"", |
162 match => "\s*\"300:0.NA/$hdl_prefix\"", |
123 line => " \"300:$hdl_prefix/ADMIN\"", |
163 line => " \"300:$hdl_prefix/$hdl_prefix_admin\"", |
124 multiple => true, |
164 multiple => true, |
125 } |
165 } |
126 |
|
127 # file { "/tmp/handle/handle_answers.txt": |
|
128 # ensure => file, |
|
129 # content => template("sysconfig/handle/handle_answers.tmp.erb"), |
|
130 # }#-> |
|
131 # exec { "init-handle": |
|
132 # command => "/opt/handle/bin/hdl-setup-server /var/lib/handle < /tmp/handle/handle_answers.txt", |
|
133 # cwd => "/opt/handle/bin", |
|
134 # provider => 'shell', |
|
135 # creates => "/var/lib/handle/sitebndl.zip", |
|
136 # user => $hdl_user, |
|
137 # notify => Exec['rm-tmp-handle'], |
|
138 # require => Package['java-install'] |
|
139 # }-> |
|
140 # file { "/var/lib/handle/config.dct": |
|
141 # ensure => file, |
|
142 # owner => "$hdl_user", |
|
143 # group => "$hdl_user", |
|
144 # content => template("sysconfig/handle/handle_config.dct.erb"), |
|
145 # replace => true |
|
146 # }-> |
|
147 # exec { "open-handle-web-port": |
|
148 # command => "firewall-cmd --permanent --add-port=8000/tcp", |
|
149 # path => [ '/bin', '/usr/bin', '/usr/local/bin' ] |
|
150 # }-> |
|
151 # exec { "open-handle-srv-port": |
|
152 # command => "firewall-cmd --permanent --add-port=2641/tcp", |
|
153 # path => [ '/bin', '/usr/bin', '/usr/local/bin' ] |
|
154 # }-> |
|
155 # exec { "open-handle-port-reload": |
|
156 # command => "firewall-cmd --reload", |
|
157 # path => [ '/bin', '/usr/bin', '/usr/local/bin' ] |
|
158 # }-> |
|
159 # exec { "handle-first-start": |
|
160 # command => "/usr/bin/echo \"${HANDLE_KEY_PSWD}\" | /opt/handle/bin/hdl-server /var/lib/handle &", |
|
161 # provider => 'shell', |
|
162 # creates => "/var/lib/handle/.handle_initialized", |
|
163 # user => $hdl_user, |
|
164 # require => File['/etc/sysconfig/handle'] |
|
165 # }-> |
|
166 # exec { "handle-first-stop": |
|
167 # command => "/usr/bin/sleep 10 && rm -f /var/lib/handle/delete_this_to_stop_server && touch /var/lib/handle/.handle_initialized", |
|
168 # provider => 'shell', |
|
169 # creates => "/var/lib/handle/.handle_initialized", |
|
170 # user => $hdl_user, |
|
171 # require => File['/etc/sysconfig/handle'] |
|
172 # }#-> |
|
173 # file_line { "handle-detached-prefix": |
|
174 # path => "/var/lib/handle/config.dct", |
|
175 # match => "\s*\"300:0.NA/$hdl_prefix\"", |
|
176 # line => " \"300:$hdl_prefix/ADMIN\"", |
|
177 # multiple => true, |
|
178 # } |
|
179 |
166 |
180 |
167 |
181 file { "/etc/sysconfig/handle": |
168 file { "/etc/sysconfig/handle": |
182 ensure => file, |
169 ensure => file, |
183 owner => "root", |
170 owner => "root", |