简体   繁体   English

当资源被声明为抽象资源类型时,木偶清单给出错误

[英]puppet manifest giving error when resources are declared as abstract resource types

I read in puppet that resources can also be declared using Resource[] syntax in manifest. 我在木偶中读到,也可以在清单中使用Resource []语法声明资源。 I wrote below manifest but it is giving error 我在下面的清单中写了,但给出了错误

Error: Could not parse for environment production: Syntax error at 'NO'; expected '}' at /etc/puppet/manifests/no.pp:3 on node pk-docker-01.cs1cloud.internal
Error: Could not parse for environment production: Syntax error at 'NO'; expected '}' at /etc/puppet/manifests/no.pp:3 on node pk-docker-01.cs1cloud.internal


file { '/var/NO/tmp' : ensure => directory,
}
Resource[User] {"NO":

    ensure => present ,
    password => 'admin@123',
}

group { no :
    ensure => present ,
}

Thanks 谢谢

The documentation you referenced is for Puppet 4.2. 您参考的文档适用于Puppet 4.2。 You can find the Puppet 3.8 reference here . 您可以在此处找到Puppet 3.8参考。

The type of declaration you are using is not supported in 3.8. 3.8不支持您使用的声明类型。 Either way, you should use the standard file{ 'dfsf': } resource declaration since it is compatible with more versions of puppet. 无论哪种方式,都应使用标准file{ 'dfsf': }资源声明,因为它与更多版本的puppet兼容。

I checked the Puppet 3.8 Documentation for resources and don't see abstract resources but that doesn't mean the feature doesn't exist. 我检查了Puppet 3.8文档中的资源,没有看到抽象资源,但这并不意味着该功能不存在。 That being said I also found the following information and example on the Data Resource Type page. 话虽如此,我还在“ 数据资源类型”页面上找到了以下信息和示例。 It is possible in 3.8 that the resource types need to be quoted strings as in the following example: 在3.8中,资源类型可能需要用引号引起来,如以下示例所示:

# A resource declaration using a resource data type:
File { "/etc/ntp.conf":
  mode  => "0644",
  owner => "root",
  group => "root",
}

# Equivalent to the above:
Resource["file"] { "/etc/ntp.conf":
  mode  => "0644",
  owner => "root",
  group => "root",
}

# A resource default:
File {
  mode  => "0644",
  owner => "root",
  group => "root",
}

So you could try the following with your code and see if it fixes the issue: 因此,您可以对代码尝试以下操作,看看它是否可以解决问题:

file { '/var/NO/tmp' : ensure => directory,
}
Resource["user"] {"NO":

    ensure => present ,
    password => 'admin@123',
}

group { no :
    ensure => present ,
}

My best advice though is to be particularly careful when viewing Puppet documentation. 不过,我最好的建议是在查看Puppet文档时要特别小心。 Ensure you are always looking at the version you are running when planning changes to your production environment and not just trying to learn about upcoming features, etc. 在计划对生产环境进行更改时,请确保始终查看正在运行的版本,而不仅仅是尝试了解即将发布的功能等。

I hope this helps! 我希望这有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM