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

Puppet generating variables inside script

· 52CE 我爱测

I'm migrating a set of bash scripts that deploy a server to Puppet. Almost all of the functionality has been moved into Puppet, but I can't see how to migrate one bit of the bash script that does the following: Install PHP. With …

问题原文

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

I'm migrating a set of bash scripts that deploy a server to Puppet. Almost all of the functionality has been moved into Puppet, but I can't see how to migrate one bit of the bash script that does the following:

  1. Install PHP.
  2. With a PHP script, generate a random password and store it as a variable in the bash script.
  3. Use that variable elsewhere in the bash script to set the MySQL root password.

How can I set a puppet variable dynamically like this?

btw I'm using Puppet in a standalone version using puppet apply as I don't have a separate server to act as the puppet master. Also, in case anyone is wondering why it's done like this, it's so that the MySQL root password doesn't exist anywhere except on the box where it's used and isn't written to any (readable) files.

已采纳解答

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

It looks like this is not feasible to do with Puppet running in standalone version.

All the variables inside classes are calculated when the scripts are read by Puppet, and so there is no way to make a dependency chain to:

  • Install PHP.
  • Call a PHP script to generate a value.
  • Use the value.

In that order.

Theoretically it may be possible to use [run stages][1] to control this dependency, but these are not usable if your classes are includeed into the project, and so aren't recommended to be used ever.

As I have use a bootstrap script to install Puppet, I may as well just install PHP through the bootstrap script, rather than having Puppet manage it.

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

资料来源与适用范围

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

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

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