Class: Prepd::Workspace
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #create_workspace ⇒ Object
- #directory_cannot_exist ⇒ Object
- #initialize_workspace ⇒ Object
- #requested_dir ⇒ Object
Methods inherited from Base
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/prepd/models/workspace.rb', line 3 def name @name end |
Instance Method Details
#create_workspace ⇒ Object
19 20 21 22 23 24 |
# File 'lib/prepd/models/workspace.rb', line 19 def create_workspace Dir.chdir(Prepd.config.working_dir) do FileUtils.rm_rf(name) if Prepd.config.force FileUtils.mkdir_p(name) end end |
#directory_cannot_exist ⇒ Object
10 11 12 13 |
# File 'lib/prepd/models/workspace.rb', line 10 def directory_cannot_exist return if Prepd.config.force errors.add(:directory_exists, requested_dir) if Dir.exists?(requested_dir) end |
#initialize_workspace ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/prepd/models/workspace.rb', line 26 def initialize_workspace Dir.chdir(requested_dir) do File.open('prepd-workspace.yml', 'w') { |f| f.write("---\nname: #{name}\n") } Prepd.register_workspace(Dir.pwd) FileUtils.cp_r("#{Prepd.files_dir}/workspace/.", '.') Dir.chdir('developer') do File.open('vars.yml', 'w') do |f| f.puts("---\ngit_user:") f.puts(" name: #{`git config --get user.name`.chomp}") f.puts(" email: #{`git config --get user.email`.chomp}") end Prepd.write_password_file('vault-password.txt') FileUtils.touch('vault.yml') system('ansible-vault encrypt vault.yml') end # NOTE: remove after testing # Dir.chdir('machines') do # FileUtils.mkdir('packer_cache') # Dir.chdir('packer_cache') do # FileUtils.cp('/tmp/50e697ab8edda5b0ac5ba2482c07003d2ff037315c7910af66efd3c28d23ed51.iso', '.') # end # end end end |