Class: Opsk::GenerateChef

Inherits:
Thor::Group
  • Object
show all
Includes:
Thorable, Thor::Actions
Defined in:
lib/opskeleton/generate_chef.rb

Instance Method Summary collapse

Methods included from Thorable

included

Instance Method Details

#create_chef_base ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/opskeleton/generate_chef.rb', line 39

def create_chef_base
  empty_directory("#{path}/static-cookbooks/")
  copy_file('templates/chef/Cheffile', "#{path}/Cheffile")
  empty_directory("#{path}/roles/")
  template('templates/chef/roles.erb', "#{path}/roles/#{name}.rb")
  template('templates/chef/dna.json.erb', "#{path}/dna.json")
  copy_file('templates/chef/run.sh', "#{path}/run.sh")
  copy_file('templates/chef/solo.rb', "#{path}/solo.rb")
  copy_file('templates/boot.sh', "#{path}/boot.sh")
  chmod("#{path}/run.sh", 0755)
  chmod("#{path}/boot.sh", 0755)
end

#create_gemfile ⇒ Object



21
22
23
# File 'lib/opskeleton/generate_chef.rb', line 21

def create_gemfile
  copy_file('templates/chef/gemfile', "#{path}/Gemfile")
end

#create_rakefile ⇒ Object



25
26
27
# File 'lib/opskeleton/generate_chef.rb', line 25

def create_rakefile
  copy_file('templates/Rakefile', "#{path}/Rakefile")
end

#create_rvmrc ⇒ Object



33
34
35
36
37
# File 'lib/opskeleton/generate_chef.rb', line 33

def create_rvmrc
  remove_file("#{path}/.rvmrc")
  template('templates/ruby-gemset.erb', "#{path}/.ruby-gemset")
  template('templates/ruby-version.erb', "#{path}/.ruby-version")
end

#create_vagrant_file ⇒ Object



16
17
18
19
# File 'lib/opskeleton/generate_chef.rb', line 16

def create_vagrant_file
  empty_directory(path)
  template('templates/chef/vagrant.erb', "#{path}/Vagrantfile")
end

#create_version ⇒ Object



29
30
31
# File 'lib/opskeleton/generate_chef.rb', line 29

def create_version
  template('templates/opsk.yml', "#{path}/opsk.yml")
end

#git ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/opskeleton/generate_chef.rb', line 65

def git
  if(!File.exists?("#{path}/.git"))
    copy_file('templates/gitignore', "#{path}/.gitignore")
    inside(path) do
 run('git init .')
 run('git add -A')
 run("git commit -m 'initial sandbox import'")
    end
  end
end

#path ⇒ Object



12
13
14
# File 'lib/opskeleton/generate_chef.rb', line 12

def path 
  "#{name}-sandbox"
end

#readme ⇒ Object



52
53
54
55
# File 'lib/opskeleton/generate_chef.rb', line 52

def readme
  template('templates/README.erb', "#{path}/README.md")
  copy_file('templates/LICENSE-2.0.txt',"#{path}/LICENSE-2.0.txt")
end

#server_spec ⇒ Object



61
62
63
# File 'lib/opskeleton/generate_chef.rb', line 61

def server_spec
  directory('templates/parent/spec', "#{path}/spec")
end

#travis ⇒ Object



57
58
59
# File 'lib/opskeleton/generate_chef.rb', line 57

def travis
  template('templates/parent/travis.erb', "#{path}/.travis.yml")
end