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, included, #machines, #meta, #name, #type_of

Instance Method Details

#create_chef_baseObject



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

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



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

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

#create_gemfileObject



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

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

#create_rakefileObject



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

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

#create_rvmrcObject



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_fileObject



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_versionObject



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

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

#gitObject



70
71
72
73
74
75
76
77
78
79
# File 'lib/opskeleton/generate_chef.rb', line 70

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



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

def path 
	"#{name}-sandbox"
end

#readmeObject



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

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

#server_specObject



66
67
68
# File 'lib/opskeleton/generate_chef.rb', line 66

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

#travisObject



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

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