Проблема
Я разделил манифест Puppet на два манифеста, каждый в другой среде, и манифест во второй среде, похоже, не может ссылаться на какие-либо модули. Я почти уверен, что это происходит, потому что я делаю что-то не так, но я не могу понять, что.
ubuntu@vagranttest:~$ puppet --version
4.9.2
Резюме
Я учусь использовать Puppet. У меня есть три пользовательских модуля, которые я написал, и все они работают отлично. Я хотел разделить свой процесс на два этапа:
- Один манифест Puppet, который создает образ со всеми установленными зависимостями.
- Второй, который устанавливает мои проекты, используя ранее созданный образ в качестве основы. Этот шаг зависит от
voxpupuli/nginx
.
Таким образом, всякий раз, когда я добавляю новые проекты для запуска в этом поле, мне не нужно снова устанавливать все зависимости.
Я переместил свой пользовательский модуль, который ссылается на voxpupuli/nginx
, в отдельную среду Puppet, и теперь кажется, что он потерял все знания о том, что такое модуль nginx.
Перед рефакторингом
/puupet-env/dev/manifests/site.pp
:
$repoPath = "/var/repos"
$sitePath = "/var/www"
class { 'userconfig': }
class {'dependencies':
require => Class['userconfig'],
repoPath => $repoPath,
sitePath => $sitePath,
}
class { 'sitebuilder':
repoPath => $repoPath,
sitePath => $sitePath,
}
После рефакторинга
/puupet-env/base/manifests/site.pp
:
$repoPath = "/var/repos"
$sitePath = "/var/www"
class { 'userconfig': }
class {'dependencies':
require => Class['userconfig'],
repoPath => $repoPath,
sitePath => $sitePath,
}
/puupet-env/deploy/manifests/site.pp
:
$repoPath = "/var/repos"
$sitePath = "/var/www"
class { 'sitebuilder':
repoPath => $repoPath,
sitePath => $sitePath,
}
Запуск кукольных манифестов
С Packer у меня есть одна конфигурация упаковщика, которая создает новый образ с /puupet-env/base/manifests/site.pp
, и вторая конфигурация, которая строится поверх этого образа с /puupet-env/deploy/manifests/site.pp
.
С Vagrant я только что сделал это в своем Vagrantfile:
config.vm.define "dev", primary:true do |dev|
config.vm.provision "shell", path: "provision.sh"
config.vm.provision "puppet" do |puppet|
puppet.environment_path = "puppet-env"
puppet.environment = "base"
puppet.module_path = "modules"
end
config.vm.provision "puppet" do |puppet|
puppet.environment_path = "puppet-env"
puppet.environment = "deploy"
puppet.module_path = "modules"
end
Сообщение об ошибке
Я получаю то же сообщение об ошибке, если запускаю это на Vagrant или на коробке Digital Ocean с Packer.
==> dev: Warning: Unknown variable: '::nginx::config::spdy'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:219:35
==> dev: Warning: Unknown variable: '::nginx::config::http2'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:220:35
==> dev: Warning: Unknown variable: '::nginx::config::proxy_read_timeout'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:223:35
==> dev: Warning: Unknown variable: '::nginx::config::proxy_connect_timeout'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:224:35
==> dev: Warning: Unknown variable: '::nginx::config::proxy_set_header'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:225:35
==> dev: Warning: Unknown variable: '::nginx::config::proxy_hide_header'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:226:35
==> dev: Warning: Unknown variable: '::nginx::config::conf_dir'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:236:38
==> dev: Warning: Unknown variable: 'nginx::config::conf_dir'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:239:38
==> dev: Warning: Unknown variable: '::nginx::config::global_owner'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:283:35
==> dev: Warning: Unknown variable: '::nginx::config::global_group'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:284:35
==> dev: Warning: Unknown variable: '::nginx::config::global_mode'. at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:285:35
==> dev: Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, "" is not an Array.
It looks to be a String at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/nginx/manifests/resource/vhost.pp:387:3 at /tmp/vagrant-puppet/modules-1cc77f85ff62eba00eccf0589f6e3b98/sitebuilder/manifests/builder.pp:18 on node vagranttest
Может ли кто-нибудь сказать мне, что я делаю неправильно? Я чувствую, что это происходит, потому что я чего-то не понимаю в Puppet.
строитель.pp
define sitebuilder::builder (
$domain,
$port,
$sitePath,
$repoPath,
$remoteUrl,
$location = false,
$command = "npm start",
) {
if $location {
# Create location.
nginx::resource::location{ $domain:
proxy => "http://localhost:$port/",
vhost => $location
}
}
else {
# Create vhost file.
nginx::resource::vhost { $domain:
listen_port => 80,
proxy => "http://localhost:$port/" ,
}
}
# Set up git to receive a push.
githook::githook { $title:
repoPath => $repoPath,
repoName => $title,
sitePath => $sitePath,
command => $command,
remoteUrl => $remoteUrl
}
# Create .env file.
file { "/var/www/$title/.env":
owner => 'helm108',
ensure => present,
content => template('sitebuilder/env.erb'),
require => Githook::Githook[$title],
}
# Create manual pull file.
file_line { "Append update_repos.sh for $title":
path => '/update_repos.sh',
line => "cd $repoPath/$title && git fetch origin && git --work-tree=${sitePath}/${title} --git-dir=${repoPath}/${title} checkout -f master",
}
}