Я следил за видеоуроком на https://www.youtube.com/watch?v=Lm6wsc8FjC8 , чтобы получить базовый пример использования марионетки для развертывания sshd_config на разных хостах .
Это мой "модуль":
ssh_config/
|-- files
| |-- sshd_config.Debian
| `-- sshd_config.Ubuntu
`-- manifests
`-- init.pp
cat manifest / init.pp
показывает мой манифест:
class ssh_config {
package {
'openssh-server':
ensure => latest,
}
file {
'/etc/ssh/sshd_config':
ensure => 'present',
owner => 'root',
group => 'root',
mode => '0644',
source => 'puppet:///modules/ssh_config/sshd_config.${operatingsystem}',
require => Package['openssh-server'],
notify => Service['ssh']
}
service {
'ssh':
ensure => 'running',
enable => 'true',
require => Package['openssh-server'],
}
}
Я включил его в свой /etc/puppet/manifest/site.pp
:
node default {
include ssh_config
}
Если я запускаю puppet agent -t
, я получаю следующую ошибку:
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppet
Info: Applying configuration version '1451986609'
Error: /Stage[main]/Ssh_config/File[/etc/ssh/sshd_config]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/ssh_config/sshd_config.${operatingsystem}
Notice: /Stage[main]/Ssh_config/Service[ssh]: Dependency File[/etc/ssh/sshd_config] has failures: true
Warning: /Stage[main]/Ssh_config/Service[ssh]: Skipping because of failed dependencies
Notice: Finished catalog run in 0.13 seconds
Factor показывает результат для facter operatingsystem
Puppet-Master: Ubuntu
Puppet-Agent: Ubuntu
Что я делаю не так?
Это просто вопрос кавычек.
'This string will not expand $operatingsystem'
"This string *will* expand $operatingsystem"
Используйте двойные кавычки, если вы хотите, чтобы расширение переменных происходило в ваших строках.