人偶语法错误
Puppet syntax error
尝试puppet parser validate
以下init.pp
时收到以下错误Error: Could not parse for environment production: Syntax error at 'conf'; expected '}' at haproxy/manifests/init.pp:4
我查看了我的 class ,似乎我所有的逗号和冒号都是有序的,所以我不确定是什么导致了这个问题。至于我的 Vagrantfile
class haproxy {
class { 'haproxy::install':
$conf = '/etc/sysconfig/network'
$seed = '11.111.111' ## IP Seed
$interfaces = { ## Generate IPConfigs based on Generic IP Variable
'eth0' => "${seed}.140",
'eth0:0' => "${seed}.141",
'eth0:1' => "${seed}.142",
}
ini_setting { 'networking':
ensure => present,
section => '',
setting => 'NETWORKING',
value => 'yes',
path => $conf,
} ->
ini_setting { 'hostname':
ensure => present,
section => '',
setting => 'HOSTNAME',
value => $::fqdn,
path => $conf,
} ->
ini_setting { 'gateway':
ensure => present,
section => '',
setting => 'GATEWAY',
value => "${seed}.1",
path => $conf,
} ->
## Clone to ifcfg-eth0:0 and ifcfg-eth0:1
file { '/etc/sysconfig/network-scripts/ifcfg-eth0':
ensure => present,
source => '/etc/sysconfig/network-scripts/ifcfg-eth0:{0,1}',
}
## Puppet Lambda's
## REF: http://goo.gl/qFj611
## TRY:
## REQ: the puppet apply --parser=future flag
each($interfaces) |$device, $ipaddress| {
file { 'interfaces':
ensure => link,
target => "/etc/sysconfig/network-scripts/ifcfg-${device}",
content => template('interfaces.erb'),
}
}
}
}
Vagrantfile 如果有人关心的话
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = 'Oracle-6.6_Puppet-slave'
config.vm.box_url = 'boxes/Oracle-6.6_Puppet-slave.box'
config.vm.provision :puppet do |puppet|
puppet.options = '--parser future' ## Future parser required for iteration
puppet.options = '--hiera_config /vagrant/generic/hiera.yaml' ## Silence...
puppet.manifests_path = 'manifests'
puppet.manifest_file = 'default.pp'
puppet.module_path = 'modules'
end
end
这是修复,从
class haproxy {
class { 'haproxy::install':
$conf = '/etc/sysconfig/network'
$seed = '11.111.111' ## IP Seed
$interfaces = { ## Generate IPConfigs based on Generic IP Variable
'eth0' => "${seed}.140",
'eth0:0' => "${seed}.141",
'eth0:1' => "${seed}.142",
}
至
class haproxy::install {
$conf = '/etc/sysconfig/network'
$seed = '11.111.111' ## IP Seed
$interfaces = { ## Generate IPConfigs based on Generic IP Variable
'eth0' => "${seed}.140",
'eth0:0' => "${seed}.141",
'eth0:1' => "${seed}.142",
}
尝试puppet parser validate
以下init.pp
Error: Could not parse for environment production: Syntax error at 'conf'; expected '}' at haproxy/manifests/init.pp:4
我查看了我的 class ,似乎我所有的逗号和冒号都是有序的,所以我不确定是什么导致了这个问题。至于我的 Vagrantfile
class haproxy {
class { 'haproxy::install':
$conf = '/etc/sysconfig/network'
$seed = '11.111.111' ## IP Seed
$interfaces = { ## Generate IPConfigs based on Generic IP Variable
'eth0' => "${seed}.140",
'eth0:0' => "${seed}.141",
'eth0:1' => "${seed}.142",
}
ini_setting { 'networking':
ensure => present,
section => '',
setting => 'NETWORKING',
value => 'yes',
path => $conf,
} ->
ini_setting { 'hostname':
ensure => present,
section => '',
setting => 'HOSTNAME',
value => $::fqdn,
path => $conf,
} ->
ini_setting { 'gateway':
ensure => present,
section => '',
setting => 'GATEWAY',
value => "${seed}.1",
path => $conf,
} ->
## Clone to ifcfg-eth0:0 and ifcfg-eth0:1
file { '/etc/sysconfig/network-scripts/ifcfg-eth0':
ensure => present,
source => '/etc/sysconfig/network-scripts/ifcfg-eth0:{0,1}',
}
## Puppet Lambda's
## REF: http://goo.gl/qFj611
## TRY:
## REQ: the puppet apply --parser=future flag
each($interfaces) |$device, $ipaddress| {
file { 'interfaces':
ensure => link,
target => "/etc/sysconfig/network-scripts/ifcfg-${device}",
content => template('interfaces.erb'),
}
}
}
}
Vagrantfile 如果有人关心的话
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = 'Oracle-6.6_Puppet-slave'
config.vm.box_url = 'boxes/Oracle-6.6_Puppet-slave.box'
config.vm.provision :puppet do |puppet|
puppet.options = '--parser future' ## Future parser required for iteration
puppet.options = '--hiera_config /vagrant/generic/hiera.yaml' ## Silence...
puppet.manifests_path = 'manifests'
puppet.manifest_file = 'default.pp'
puppet.module_path = 'modules'
end
end
这是修复,从
class haproxy {
class { 'haproxy::install':
$conf = '/etc/sysconfig/network'
$seed = '11.111.111' ## IP Seed
$interfaces = { ## Generate IPConfigs based on Generic IP Variable
'eth0' => "${seed}.140",
'eth0:0' => "${seed}.141",
'eth0:1' => "${seed}.142",
}
至
class haproxy::install {
$conf = '/etc/sysconfig/network'
$seed = '11.111.111' ## IP Seed
$interfaces = { ## Generate IPConfigs based on Generic IP Variable
'eth0' => "${seed}.140",
'eth0:0' => "${seed}.141",
'eth0:1' => "${seed}.142",
}