Избегайте объявления если regex операторы в то время как использование Экспортируемые Ресурсы в Марионетке

Постарайтесь не добавлять хост вручную

class::define {  [
    'host1.domain',
    'host2.domain'
  ]:
    attribute  => 'hello',
    attribute2 => 'world'
}

class::define {  [
    'host3.domaintwo',
    'host4.domaintwo'
  ]:
    attribute  => 'apple',
    attribute2 => 'orange'
}

при помощи экспортируемых ресурсов:

if $fqdn =~ /^.*\.domain$/ {
  @@class::define { $fqdn:
    attribute  => 'hello',
    attribute2 => 'world',
    tag => 'test'
  }
}

if $fqdn =~ /^.*\.domaintwo$/ {
  @@class::define { $fqdn:
    attribute  => 'apple',
    attribute2 => 'orange',
    tag => 'test2'
  }
}

Class::define <<| tag == 'test' and tag == 'test2' |>> 

работы как ожидалось.

Вопрос

Мог если операторы быть опущенным для получения того же результата?

2
задан 18 February 2015 в 23:59
1 ответ

Rendendu incondizionate l'esportazioni, pruvucerete una collisione, perchè u manifestu dichjara avà a risorsa esportata

Class::Define[$fqdn]

duie volte (cù attributi diversi).

Pudete evità questu permettendu di passà u FQDN cum'è valore d'attributu, invece d'aspittà ch'ellu sia u titulu di risorsa.

@@class::other_define {
    "hello-$fqdn":
        fqdn => $fqdn,
        attribute  => 'hello',
        attribute2 => 'world',
        tag => 'test';
    "fruit-$fqdn":
        fqdn => $fqdn,
        attribute  => 'apple',
        attribute2 => 'orange',
        tag => 'test2';
}

Assicuratevi solu di aduprà sempre u fqdn in tituli di risorse, in modo chì l'esportazioni

Da parte, ùn sò micca sicuru perchè sceglite tag distinti, è perchè importà solu risorse chì anu tramindui tag funziona "cum'è previstu". In fatti, m'aspettu chì ùn importessi nunda.

2
ответ дан 3 December 2019 в 11:38

Теги

Похожие вопросы