简体   繁体   English

我可以在'puppet apply'运行时指定puppet的根执行目录吗?

[英]Can I specify puppet's root execution directory at 'puppet apply' runtime?

Suppose I'm working in AWS, and have an EBS volume attached to an instance. 假设我在AWS中工作,并且有一个附加到实例的EBS卷。 That volume is a copy of a root volume, insofar as it was created by snapshotting the root volume of another instance. 该卷是根卷的副本,只要它是通过快照另一个实例的根卷而创建的。

I'd like to run puppet against my EBS volume, but not hardcode its mounted path into my puppet manifests. 我想针对我的EBS卷运行人偶,但不将其装入的路径硬编码到我的人偶清单中。 Suppose it were mounted at /tmp/new-root-vol . 假设将其安装在/tmp/new-root-vol Is there any way to run puppet apply against that path without specifying it in the manifest itself? 有什么方法可以在没有在清单本身中指定的情况下针对该路径运行puppet apply?

To put it another way, how could I get this manifest snippet to create /tmp/new-root-vol/testfile without knowing the /tmp/new-root-vol namespace until runtime? 换句话说,如何在运行时不知道/tmp/new-root-vol命名空间的情况下,获得清单清单来创建/tmp/new-root-vol/testfile

file {'testfile':
  path    => '/testfile',
  content => 'Hello, volume'
}

One possibility might be chroot . 一种可能是chroot This feature request suggests it might work, as long as the puppet executable were accessible from the new root. 功能请求表明,只要可以从新的根目录访问人偶可执行文件,它就可以工作。

I don't know of any way you can do that. 我不知道您能做到这一点。 However you can create a variable in your site.pp (or include another manifest like constants.pp) and use a variable: 但是,您可以在site.pp中创建一个变量(或包括另一个清单,例如constants.pp)并使用一个变量:

site.pp site.pp

$root_dir = '/'
node default {
  include your_manifests
}

You file 您归档

file {'testfile':
  path    => "${root_dir}testfile",
  content => 'Hello, volume'
}

You could even change the root directory per node too. 您甚至可以更改每个节点的根目录。

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

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