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

#artifact, #artifact_path, #check_root, included, #machines, #meta, #name, #type_of

Instance Method Details

#create_chef_baseObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/opskeleton/generate_chef.rb', line 45

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/chef/boot.sh', "#{path}/boot.sh")
  chmod("#{path}/run.sh", 0755)
  chmod("#{path}/boot.sh", 0755)
end

#create_environmentObject



40
41
42
43
# File 'lib/opskeleton/generate_chef.rb', line 40

def create_environment
  empty_directory("#{path}/environments")
  copy_file('templates/chef/environments/dev.rb', "#{path}/environments/dev.rb")
end

#create_gemfileObject



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

def create_gemfile
  template('templates/chef/Gemfile.erb', "#{path}/Gemfile")
end

#create_rakefileObject



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

def create_rakefile
  template('templates/chef/Rakefile.erb', "#{path}/Rakefile")
end

#create_rvmrcObject



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

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_fileObject



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

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

#create_versionObject



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

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

#gitObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/opskeleton/generate_chef.rb', line 73

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

#pathObject



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

def path 
  "#{name}-sandbox"
end

#readmeObject



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

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

#server_specObject



67
68
69
70
71
# File 'lib/opskeleton/generate_chef.rb', line 67

def server_spec
  empty_directory("#{path}/spec")
  template('templates/parent/spec/spec_helper.erb', "#{path}/spec/spec_helper.rb")
  directory('templates/parent/spec/default', "#{path}/spec/default")
end

#travisObject



63
64
65
# File 'lib/opskeleton/generate_chef.rb', line 63

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