Class: Catfish::CLI::Init
- Inherits:
-
Object
- Object
- Catfish::CLI::Init
- Defined in:
- lib/catfish/cli/init.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#thor ⇒ Object
readonly
Returns the value of attribute thor.
Instance Method Summary collapse
-
#initialize(options, thor) ⇒ Init
constructor
A new instance of Init.
- #run ⇒ Object
Constructor Details
#initialize(options, thor) ⇒ Init
Returns a new instance of Init.
8 9 10 11 |
# File 'lib/catfish/cli/init.rb', line 8 def initialize(, thor) @options = @thor = thor end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/catfish/cli/init.rb', line 6 def @options end |
#thor ⇒ Object (readonly)
Returns the value of attribute thor.
6 7 8 |
# File 'lib/catfish/cli/init.rb', line 6 def thor @thor end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/catfish/cli/init.rb', line 13 def run p 'Initializing Catfish repository' provisioners = [:provisioners] || [] plugins = [:plugins] || [] # Shorthand aliases [:communicator] = 'winrm' if [:windows] provisioners << 'shell' if [:shell] provisioners << 'puppet' if [:puppet] plugins << 'vagrant-librarian-puppet' if ['puppet-librarian-puppet'] opts = { local: [:local], local_box: ['local-box'], local_box_url: ['local-box-url'], managed: [:managed], provisioners: provisioners || [], shell_paths: ['shell-paths'] || ['{{PATH_TO_YOUR_SCRIPT}}'], puppet_hiera: ['puppet-hiera'], puppet_librarian_puppet: ['puppet-librarian-puppet'], communicator: [:communicator] || 'ssh', winrm_username: ['winrm-username'] || '{{YOUR_WINRM_USERNAME}}', winrm_password: ['winrm-password'] || '{{YOUR_WINRM_PASSWORD}}', ssh_username: ['ssh-username'] || '{{YOUR_SSH_USERNAME}}', ssh_private_key_path: ['ssh-private-key-path'] || '{{PATH_TO_YOUR_SSH_PRIVATE_KEY}}', managed_servers: ['managed-servers'] || [], 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 ['puppet-librarian-puppet'] if ['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 puts 'Repository initialized. Remember to:' puts ' - Check your Vagrantfile and replace any placeholders' puts ' - Edit your Catfish file and list target servers' end |