|
275 | 275 | }
|
276 | 276 |
|
277 | 277 | if $manage_selinux {
|
278 |
| - selboolean { 'httpd_can_network_relay': |
279 |
| - persistent => true, |
280 |
| - value => 'on', |
| 278 | + # Include puppet/selinux |
| 279 | + include selinux |
| 280 | + # Set SELinux booleans required for httpd proper functioning |
| 281 | + # https://linux.die.net/man/8/httpd_selinux |
| 282 | + selinux::boolean { |
| 283 | + default: |
| 284 | + ensure => 'on', |
| 285 | + persistent => true, |
| 286 | + ; |
| 287 | + # allow httpd scripts to connect to network: Puppetboard connects |
| 288 | + # to PuppetDB |
| 289 | + 'httpd_can_network_connect': |
| 290 | + ; |
| 291 | + # allow httpd script to connect to database servers: PuppetDB relies |
| 292 | + # on PostgreSQL |
| 293 | + 'httpd_can_network_connect_db': |
| 294 | + ; |
| 295 | + # allow httpd to be used as a forward/reverse proxy |
| 296 | + 'httpd_can_network_relay': |
| 297 | + ; |
| 298 | + # enable cgi support |
| 299 | + 'httpd_enable_cgi': |
| 300 | + ; |
281 | 301 | }
|
282 |
| - selboolean { 'httpd_can_network_connect': |
283 |
| - persistent => true, |
284 |
| - value => 'on', |
| 302 | + # Set context for wsgi and settings |
| 303 | + selinux::fcontext { |
| 304 | + default: |
| 305 | + ensure => present, |
| 306 | + notify => Selinux::Exec_restorecon["${basedir}/puppetboard"], |
| 307 | + ; |
| 308 | + "${basedir}/puppetboard/wsgi.py": |
| 309 | + seltype => 'httpd_sys_script_exec_t', |
| 310 | + ; |
| 311 | + $settings_file : |
| 312 | + require => File[$settings_file], |
| 313 | + seltype => 'httpd_sys_content_t', |
| 314 | + ; |
285 | 315 | }
|
286 |
| - selboolean { 'httpd_can_network_connect_db': |
287 |
| - persistent => true, |
288 |
| - value => 'on', |
| 316 | + # Apply changes above |
| 317 | + selinux::exec_restorecon { "${basedir}/puppetboard": |
| 318 | + notify => Service['httpd'], |
| 319 | + } |
| 320 | + |
| 321 | + if $manage_virtualenv { |
| 322 | + # Set context for venv files |
| 323 | + selinux::fcontext { |
| 324 | + default: |
| 325 | + ensure => present, |
| 326 | + require => Python::Pip['puppetboard'], |
| 327 | + notify => Selinux::Exec_restorecon[$virtualenv_dir], |
| 328 | + ; |
| 329 | + "${virtualenv_dir} static files": |
| 330 | + seltype => 'httpd_sys_content_t', |
| 331 | + pathspec => "${virtualenv_dir}(/.*\\.(cfg|css|html|ico|js|pem|png|svg|ttf|txt|woff|woff2|xml))?", |
| 332 | + ; |
| 333 | + "${virtualenv_dir} METADATA": |
| 334 | + seltype => 'httpd_sys_content_t', |
| 335 | + pathspec => "${virtualenv_dir}(/.*/METADATA)?", |
| 336 | + ; |
| 337 | + "${virtualenv_dir} executables": |
| 338 | + seltype => 'httpd_sys_script_exec_t', |
| 339 | + pathspec => "${virtualenv_dir}(/.*\\.(pth|py|pyc|pyi|so))?", |
| 340 | + ; |
| 341 | + } |
| 342 | + # Apply changes above |
| 343 | + selinux::exec_restorecon { $virtualenv_dir : |
| 344 | + notify => Service['httpd'], |
| 345 | + } |
289 | 346 | }
|
290 | 347 | }
|
291 | 348 | }
|
0 commit comments