|
| 1 | +class profiles::uitpas::website::elasticsearch ( |
| 2 | + String $balies_config_source, |
| 3 | + String $promotions_config_source |
| 4 | +) inherits ::profiles { |
| 5 | + |
| 6 | + include ::profiles::elasticsearch |
| 7 | + |
| 8 | + $basedir = '/opt/elasticsearch-uitpas-mappings' |
| 9 | + |
| 10 | + file { $basedir: |
| 11 | + ensure => 'directory', |
| 12 | + } |
| 13 | + |
| 14 | + file { 'uitpas-elasticsearch-balies-mapping': |
| 15 | + ensure => 'file', |
| 16 | + path => "${basedir}/mapping_balies.json", |
| 17 | + source => $balies_config_source, |
| 18 | + require => File[$basedir] |
| 19 | + } |
| 20 | + |
| 21 | + exec { 'create elasticsearch balies mapping': |
| 22 | + command => "/usr/bin/curl -XPUT 'localhost:9200/balies?pretty' -H 'Content-Type: application/json' -d @${basedir}/mapping_balies.json", |
| 23 | + logoutput => true, |
| 24 | + refreshonly => true, |
| 25 | + subscribe => File['uitpas-elasticsearch-balies-mapping'], |
| 26 | + unless => '/usr/bin/curl -s localhost:9200/balies/_mappings | /usr/bin/jq -e .balies' |
| 27 | + } |
| 28 | + |
| 29 | + exec { 'update elasticsearch balies mapping': |
| 30 | + command => "/usr/bin/curl -XPATCH 'localhost:9200/balies?pretty' -H 'Content-Type: application/json' -d @${basedir}/mapping_balies.json", |
| 31 | + logoutput => true, |
| 32 | + refreshonly => true, |
| 33 | + subscribe => File['uitpas-elasticsearch-balies-mapping'], |
| 34 | + onlyif => '/usr/bin/curl -s localhost:9200/balies/_mappings | /usr/bin/jq -e .balies' |
| 35 | + } |
| 36 | + |
| 37 | + file { 'uitpas-elasticsearch-promotions-mapping': |
| 38 | + ensure => 'file', |
| 39 | + path => "${basedir}/mapping_promotions.json", |
| 40 | + source => $promotions_config_source, |
| 41 | + require => File[$basedir] |
| 42 | + } |
| 43 | + |
| 44 | + exec { 'create elasticsearch promotions mapping': |
| 45 | + command => "/usr/bin/curl -XPUT 'localhost:9200/promotions?pretty' -H 'Content-Type: application/json' -d @${basedir}/mapping_promotions.json", |
| 46 | + logoutput => true, |
| 47 | + refreshonly => true, |
| 48 | + subscribe => File['uitpas-elasticsearch-promotions-mapping'], |
| 49 | + unless => '/usr/bin/curl -s localhost:9200/promotions/_mappings | /usr/bin/jq -e .promotions' |
| 50 | + } |
| 51 | + |
| 52 | + exec { 'update elasticsearch promotions mapping': |
| 53 | + command => "/usr/bin/curl -XPATCH 'localhost:9200/promotions?pretty' -H 'Content-Type: application/json' -d @${basedir}/mapping_promotions.json", |
| 54 | + logoutput => true, |
| 55 | + refreshonly => true, |
| 56 | + subscribe => File['uitpas-elasticsearch-promotions-mapping'], |
| 57 | + onlyif => '/usr/bin/curl -s localhost:9200/promotions/_mappings | /usr/bin/jq -e .promotions' |
| 58 | + } |
| 59 | +} |
0 commit comments