2015-12-02 64 views
0

所以看起来我不能再使用Puppets --templatedir作为我的流浪者设置中的一个参数。看起来在木偶4+被废弃,但也只是似乎并不想在3.8.2templatedir不再是我的傀儡/流浪者设置的有效参数吗?

合作,考虑到这一事实,这是在贬低,是没有通过一个地图模板我Vagrantfile一个适当的方式?以下应该在一年左右前工作,但不再有效,并且我正在修复和改进它。

# -*- mode: ruby -*- 
# vi: set ft=ruby : 
require 'rubygems' 
require 'git' 


## Base modules 
modules = [ 
    'haproxy', 
    'hiera', 
    'stdlib' 
] 


modules.each do | m | 
    puts "Testing module: #{m}" 

    repo = "git://github.com/ehime/puppet-#{m}.git" 
    dir = "puppet/modules/#{m}" 

    if File.exist?(dir) 
    if File.exist?(dir + "/.git") 
     puts "Loading puppet module #{m} from #{dir}\n" 
     Git.open(dir).pull 
    else 
     puts "Module #{m} does not have a GIT repository, bypassing" 
    end 
    else 
    puts "Fetch puppet module #{m} from #{repo}\n" 
    Git.clone(repo, dir) 
    end 
end 



Vagrant::Config.run do | config | 

    config.vm.box  = 'puppetlabs/centos-7.0-64-puppet' ## name 
    config.vm.box_url = 'puppetlabs/centos-7.0-64-puppet' ## can be a hardened ami etc if needed 


    config.vm.share_folder('templates', '/tmp/vagrant-puppet/templates', 'puppet/templates') 
    config.vm.share_folder('modules', '/etc/puppet/modules',   'puppet/modules') 


    config.vm.define :master do | master | 
    master.vm.host_name = 'master.io' 

    master.vm.provision :puppet, :options => [ '--templatedir /tmp/vagrant-puppet/templates' ] do | puppet | 

     puppet.hiera_config_path = "generic/hiera.yaml" 

     puppet.manifests_path  = "puppet/manifests" 
     puppet.manifest_file  = 'master.pp' 

     puppet.module_path  = "puppet/modules" 

     puppet.facter = { 
     "vagrant" => "1", 
     "server" => "master.io", 
     } 

    end 

    master.vm.provision :shell, :inline => 'yum clean all; yum makecache; yum update' ## generic cleanupuppet... 

    end 

    # Puppet client, configured from Puppet master 
    # Puppet needs to run twice 
    # First run needs to install build and its dependencies, so the plugins work next invocations 
    config.vm.define :client, :options => [ '--templatedir /tmp/vagrant-puppet/templates' ] do | client | 

    client.vm.host_name = 'client.io' 

    client.vm.provision :puppet do | puppet | 

     puppet.manifests_path  = "puppet/manifests" 
     puppet.manifest_file  = 'client.pp' 

    end 
    end 
end 

上述错误了与

==> master: Running provisioner: puppet... 
==> master: Running Puppet with master.pp... 
==> master: Error: Could not parse application options: invalid option: --templatedir 
The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what 

出了错。

回答

0

创建一个模块 - my_templates并将模板添加到模块的模板文件夹中。然后你可以使用模板函数(​​)尽管模板函数也可以从文件的绝对位置加载模板,但是最好创建一个模块然后添加模板。