问题原文
原帖链接 · 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:
- Install PHP.
- With a PHP script, generate a random password and store it as a variable in the bash script.
- 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
