Class: Workup::Application
- Inherits:
-
Thor
- Object
- Thor
- Workup::Application
- Defined in:
- lib/workup/application.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
Instance Method Summary collapse
- #chef_client ⇒ Object
- #chef_zero ⇒ Object
- #default ⇒ Object
-
#initialize(*args) ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize(*args) ⇒ Application
Returns a new instance of Application.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/workup/application.rb', line 32 def initialize(*args) @log ||= begin log = ::Logging.logger['workup'] log.add_appenders('stdout') log.level = :debug log end Workup::Helpers.check_user! super(*args) end |
Instance Attribute Details
#log ⇒ Object (readonly)
Returns the value of attribute log.
30 31 32 |
# File 'lib/workup/application.rb', line 30 def log @log end |
Instance Method Details
#chef_client ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/workup/application.rb', line 89 def chef_client raise 'Workup directory does not exist' unless File.exist?([:workup_dir]) clientrb_path = File.join([:workup_dir], 'client.rb') client_cmd = ['chef-client', '--no-fork', '--config', clientrb_path] client_cmd << '-A' if Gem.win_platform? client_cmd << '--why-run' if [:dry_run] execute(*client_cmd, live_stdout: STDOUT, live_stderr: STDERR) end |
#chef_zero ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/workup/application.rb', line 72 def chef_zero raise 'Workup directory does not exist' unless File.exist?([:workup_dir]) policy_path = File.join([:workup_dir], 'Policyfile.rb') lock_path = File.join([:workup_dir], 'Policyfile.lock.json') chefzero_path = File.join([:workup_dir], 'chef-zero') log.info 'Updating lock file... ' execute('chef', (File.exist?(lock_path) ? 'update' : 'install'), policy_path, env: { GIT_SSL_NO_VERIFY: ['verify_ssl'] ? '0' : '1' }, cwd: [:workup_dir]) log.info 'Creating chef-zero directory... ' execute('chef', 'export', '--force', policy_path, chefzero_path, env: { GIT_SSL_NO_VERIFY: ['verify_ssl'] ? '0' : '1' }) end |
#default ⇒ Object
65 66 67 68 69 |
# File 'lib/workup/application.rb', line 65 def default log.info "Starting workup\n" chef_zero chef_client end |