lib/catfish/cli/init.rb in catfish-0.0.4 vs lib/catfish/cli/init.rb in catfish-0.0.5

- old
+ new

@@ -1,5 +1,7 @@ +require 'pp' + module Catfish class CLI class Init attr_reader :options, :thor @@ -9,33 +11,53 @@ end def run p 'Initializing Catfish repository' - templates = { - 'Catfishfile.tt' => 'Catfishfile', - 'Vagrantfile.tt' => 'Vagrantfile' - } + provisioners = options[:provisioners] || [] + plugins = options[:plugins] || [] + # Shorthand aliases + options[:communicator] = 'winrm' if options[:windows] + provisioners << 'shell' if options[:shell] + provisioners << 'puppet' if options[:puppet] + plugins << 'vagrant-librarian-puppet' if options['puppet-librarian-puppet'] + opts = { - provisioners: options[:provisioners] || [], + provisioners: provisioners || [], shell_paths: options['shell-paths'] || ['{{PATH_TO_YOUR_SCRIPT}}'], + puppet_hiera: options['puppet-hiera'], + puppet_librarian_puppet: options['puppet-librarian-puppet'], communicator: options[:communicator] || 'ssh', winrm_username: options['winrm-username'] || '{{YOUR_WINRM_USERNAME}}', winrm_password: options['winrm-password'] || '{{YOUR_WINRM_PASSWORD}}', ssh_username: options['ssh-username'] || '{{YOUR_SSH_USERNAME}}', ssh_private_key_path: options['ssh-private-key-path'] || '{{PATH_TO_YOUR_SSH_PRIVATE_KEY}}', servers: options['servers'] || [], - plugins: options['plugins'] || [] + plugins: plugins || [] } + templates = { + 'Catfishfile.tt' => 'Catfishfile', + 'Vagrantfile.tt' => 'Vagrantfile' + } + + if provisioners.include? 'puppet' + templates.merge!('puppet/manifests/default.pp.tt' => 'manifests/default.pp') + templates.merge!('puppet/Puppetfile.tt' => 'Puppetfile') if options['puppet-librarian-puppet'] + + if options['puppet-hiera'] + templates.merge!('puppet/hiera.yaml.tt' => 'hiera.yaml') + templates.merge!('puppet/hiera/common.yaml.tt' => 'hiera/common.yaml') + end + end + templates.each do |src, dst| thor.template(src, dst, opts) end - p 'Repository initialized. Remember to:' - p ' - Check your Vagrantfile and replace any placeholders' - p ' - Edit your Catfish file and list target servers' - p ' - Run catfish resolve' + puts 'Repository initialized. Remember to:' + puts ' - Check your Vagrantfile and replace any placeholders' + puts ' - Edit your Catfish file and list target servers' end end end end