大网数据广告活动
服务器运维问答

How do you use a variable in a Puppet Manifest?

· 52CE 我爱测

I am using the WSUS Module with Puppet Master on Centos 7.2. My Puppet Agent servers are running Windows Server 2012. I want to use a manifest with a variable. However, when the Puppet Agent server has the puppet agent run, it di…

问题原文

原帖链接 · Kiran · CC BY-SA 3.0

I am using the WSUS Module with Puppet Master on Centos 7.2. My Puppet Agent servers are running Windows Server 2012.

I want to use a manifest with a variable. However, when the Puppet Agent server has the puppet agent run, it displays "error 400, syntax error." I have tried re-writing the manifest and every variation I could think of. I keep getting some error.

Here is one example of a manifest:

class excellent {
    class { 'wsus_client':
       $cool = 'Saturday'
    server_url => 'http://acme.com',
    auto_update_option  => 'Scheduled'
    scheduled_install_day => $cool,
    scheduled_install_hour => 1,
}
}

I've tried assigning the variable in braces {}. I tried to use $LOAD_PATH, --custom-dir and FACTERLIB. But I could not figure out how to use any of these three.

I want to change the variable in one place and use it within the scope of its parent class. What should I do?

已采纳解答

原帖链接 · Aaron Copley · CC BY-SA 3.0

Have you tried it this way?

class excellent {
  $cool = 'Saturday'

  class { 'wsus_client':
    server_url => 'http://acme.com',
    auto_update_option  => 'Scheduled'
    scheduled_install_day => $cool,
    scheduled_install_hour => 1,
  }
}

Or, this way

class excellent (
  $cool = 'Saturday'
){
  class { 'wsus_client':
    server_url => 'http://acme.com',
    auto_update_option  => 'Scheduled'
    scheduled_install_day => $cool,
    scheduled_install_hour => 1,
  }
}

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-09-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。