puppet文件函数不加载内容

时间:2015-05-13 15:48:35

标签: amazon-web-services amazon-s3 puppet

我试图以下列方式使用puppet文件函数(不是类型)

class iop_users {

include 's3file::curl'
include 'stdlib'

$secretpath=file('/etc/secret','dev/null')

notify { 'show secretpath':
  message =>"secretpath is $secretpath"
}

s3file { '/opt/utab.yaml':
  source => "mybucket/$secretpath/utab.yaml",
  ensure => 'latest',
}

exec { 'fix perms':
  command => '/bin/chmod 600 /opt/utab.yaml',
  require => S3file['/opt/utab.yaml']
}


if ( $::virtual == 'xenhvm' and defined(S3file['/opt/utab.yaml']) ) {
  $uhash=loadyaml('/opt/utab.yaml')
  create_resources(iop_users::usercreate, $uhash)
}

}

如果我运行这个,那么这里是一些典型的输出。清单失败,因为用于查找路径的初始“秘密”未加载

https_proxy=https://puppet:3128 puppet agent -t 
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for ip-10-40-1-68.eu-west-1.compute.internal
Info: Applying configuration version '1431531382'
Notice: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]/returns:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Notice: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]/returns:                                  Dload  Upload   Total   Spent    Left  Speed
Notice: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Notice: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]/returns: curl: (56) Received HTTP code 404 from proxy after CONNECT
Error: curl -L -o /opt/utab.yaml https://s3-eu-west.amazonaws.com/mybucket//utab.yaml returned 56 instead of one of [0]
Error: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]/returns: change from notrun to 0 failed: curl -L -o /opt/utab.yaml https://s3-eu-west.amazonaws.com/mybucket//utab.yaml returned 56 instead of one of [0]
Notice: /Stage[main]/Iop_users/Exec[fix perms]: Dependency Exec[fetch /opt/utab.yaml] has failures: true
Warning: /Stage[main]/Iop_users/Exec[fix perms]: Skipping because of failed dependencies
Notice: secretpath is 
Notice: /Stage[main]/Iop_users/Notify[show secretpath]/message: defined 'message' as 'secretpath is '
Notice: Finished catalog run in 1.28 seconds

然而,在上述木偶代理运行失败的同一主机上,如果我使用“apply”在清单的上下文之外尝试它,它可以正常工作

puppet apply -e '$z=file("/etc/secret") notify { "z": message => $z}'
Notice: Compiled catalog for ip-x.x.x.x.eu-west-1.compute.internal in environment production in 0.02 seconds
Notice: wombat

Notice: /Stage[main]/Main/Notify[z]/message: defined 'message' as 'wombat
'
Notice: Finished catalog run in 0.03 seconds

我做错了什么?我能做出更好的替代方法吗?

1 个答案:

答案 0 :(得分:1)

像往常一样,我对木偶的运作方式感到困惑

显然,功能总是在主人身上执行

因此以这种方式加载的任何文件都必须在主

我添加" / etc / secret"向puppetmaster提交文件