bebox 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/Gemfile.lock +11 -1
- data/README.md +1 -0
- data/bebox.gemspec +2 -0
- data/lib/bebox/node.rb +1 -1
- data/lib/bebox/provision.rb +0 -32
- data/lib/bebox/vagrant_helper.rb +6 -4
- data/lib/bebox/version.rb +1 -1
- data/lib/bebox/wizards/environment_wizard.rb +4 -2
- data/lib/bebox/wizards/node_wizard.rb +9 -4
- data/lib/bebox/wizards/profile_wizard.rb +4 -2
- data/lib/bebox/wizards/project_wizard.rb +4 -3
- data/lib/bebox/wizards/provision_wizard.rb +6 -2
- data/lib/bebox/wizards/role_wizard.rb +14 -9
- data/lib/bebox/wizards/wizards_helper.rb +1 -0
- data/spec/environment_spec.rb +35 -18
- data/spec/factories/environment.rb +0 -12
- data/spec/factories/node.rb +0 -6
- data/spec/factories/project.rb +1 -7
- data/spec/fixtures/dot_bebox.test.erb +1 -1
- data/spec/node0.server1.test/prepare_phase_spec.rb +1 -1
- data/spec/node0.server1.test/provision_step_0_spec.rb +1 -1
- data/spec/node0.server1.test/provision_step_1_spec.rb +1 -1
- data/spec/node0.server1.test/provision_step_2_spec.rb +1 -1
- data/spec/node0.server1.test/provision_step_3_spec.rb +1 -1
- data/spec/node_role_spec.rb +7 -1
- data/spec/node_spec.rb +55 -17
- data/spec/ordered_phases_spec.rb +7 -3
- data/spec/pre_prepare_spec.rb +12 -9
- data/spec/pre_provision_steps_spec.rb +1 -1
- data/spec/profile_spec.rb +21 -8
- data/spec/project_spec.rb +54 -48
- data/spec/role_profiles_spec.rb +1 -1
- data/spec/role_spec.rb +40 -7
- data/spec/spec_helper.rb +20 -2
- data/spec/wizards/environment_wizard_spec.rb +33 -0
- data/spec/wizards/node_wizard_spec.rb +110 -0
- data/spec/wizards/profile_wizard_spec.rb +45 -0
- data/spec/wizards/project_wizard_spec.rb +90 -0
- data/spec/wizards/provision_wizard_spec.rb +45 -0
- data/spec/wizards/role_wizard_spec.rb +97 -0
- metadata +37 -4
- data/spec/node_wizard_spec.rb +0 -22
- data/spec/project_wizard_spec.rb +0 -51
@@ -4,17 +4,5 @@ FactoryGirl.define do
|
|
4
4
|
project_root "#{Dir.pwd}/tmp/bebox-pname"
|
5
5
|
|
6
6
|
initialize_with { new(name, project_root) }
|
7
|
-
|
8
|
-
trait :created do
|
9
|
-
after(:build) do |environment|
|
10
|
-
environment.create
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
trait :removed do
|
15
|
-
after(:build) do |environment|
|
16
|
-
environment.remove
|
17
|
-
end
|
18
|
-
end
|
19
7
|
end
|
20
8
|
end
|
data/spec/factories/node.rb
CHANGED
data/spec/factories/project.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :project, :class => Bebox::Project do
|
3
3
|
name "bebox-pname"
|
4
|
-
vagrant_box_base "ubuntu-server-12042-x64-vbox4210-nocm.box"
|
4
|
+
vagrant_box_base "#{Dir.pwd}/ubuntu-server-12042-x64-vbox4210-nocm.box"
|
5
5
|
parent_path "#{Dir.pwd}/tmp"
|
6
6
|
vagrant_box_provider 'virtualbox'
|
7
7
|
default_environments ['vagrant', 'staging', 'production']
|
8
8
|
|
9
9
|
initialize_with { new(name, vagrant_box_base, parent_path, vagrant_box_provider, default_environments) }
|
10
|
-
|
11
|
-
trait :created do
|
12
|
-
after(:build) do |project|
|
13
|
-
project.create
|
14
|
-
end
|
15
|
-
end
|
16
10
|
end
|
17
11
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require_relative '../factories/provision.rb'
|
3
3
|
require_relative '../vagrant_spec_helper.rb'
|
4
4
|
|
5
|
-
describe 'Test
|
5
|
+
describe 'Test 16: Apply provision for fundamental step-0' do
|
6
6
|
|
7
7
|
let(:provision) { build(:provision) }
|
8
8
|
let(:fundamental_profiles) {['base/fundamental/ruby', 'base/fundamental/sudo', 'base/fundamental/users']}
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require_relative '../factories/provision.rb'
|
3
3
|
require_relative '../puppet_spec_helper.rb'
|
4
4
|
|
5
|
-
describe 'Test
|
5
|
+
describe 'Test 17: Apply provision for users layer step-1' do
|
6
6
|
|
7
7
|
let(:provision) { build(:provision, step: 'step-1') }
|
8
8
|
let(:users_profiles) {['base/users/ssh', 'base/users/users']}
|
@@ -4,7 +4,7 @@ require_relative '../factories/role.rb'
|
|
4
4
|
require_relative '../factories/profile.rb'
|
5
5
|
require_relative '../puppet_spec_helper.rb'
|
6
6
|
|
7
|
-
describe 'Test
|
7
|
+
describe 'Test 18: Apply provision for service layer step-2' do
|
8
8
|
|
9
9
|
let(:provision) { build(:provision, step: 'step-2') }
|
10
10
|
let(:role) { build(:role) }
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require_relative '../factories/provision.rb'
|
3
3
|
require_relative '../puppet_spec_helper.rb'
|
4
4
|
|
5
|
-
describe 'Test
|
5
|
+
describe 'Test 19: Apply provision for security layer step-3' do
|
6
6
|
|
7
7
|
let(:provision) { build(:provision, step: 'step-3') }
|
8
8
|
let(:security_profiles) {['base/security/fail2ban', 'base/security/iptables', 'base/security/ssh', 'base/security/sysctl']}
|
data/spec/node_role_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative '../spec/factories/role.rb'
|
|
3
3
|
require_relative '../spec/factories/node.rb'
|
4
4
|
require_relative '../spec/factories/provision.rb'
|
5
5
|
|
6
|
-
describe 'Test
|
6
|
+
describe 'Test 14: Associate node and role' do
|
7
7
|
|
8
8
|
let(:role) { build(:role) }
|
9
9
|
let(:nodes) { [build(:node)] }
|
@@ -16,5 +16,11 @@ describe 'Test 10: Associate node and role' do
|
|
16
16
|
output_file = File.read("#{node.project_root}/puppet/steps/2-services/manifests/site.pp").strip
|
17
17
|
expect(output_file).to eq(expected_content)
|
18
18
|
end
|
19
|
+
|
20
|
+
it 'gets the role from a node' do
|
21
|
+
node = nodes.first
|
22
|
+
expected_role = Bebox::Provision.role_from_node(node.project_root, 'step-2', node.hostname)
|
23
|
+
expect(expected_role).to include(role.name)
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
data/spec/node_spec.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require_relative '../spec/factories/node.rb'
|
3
3
|
|
4
|
-
describe 'Test
|
4
|
+
describe 'Test 08: Bebox::Node' do
|
5
5
|
|
6
6
|
describe 'Nodes management' do
|
7
7
|
|
8
8
|
subject { build(:node) }
|
9
9
|
|
10
|
-
context 'node creation' do
|
11
|
-
|
12
|
-
|
10
|
+
context '00: node creation' do
|
11
|
+
|
12
|
+
before :all do
|
13
|
+
subject.create
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'creates hiera data template' do
|
13
17
|
Bebox::PROVISION_STEPS.each do |step|
|
14
18
|
expect(File.exist?("#{subject.project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/hiera/data/#{subject.hostname}.yaml")).to eq(true)
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
|
-
it '
|
19
|
-
subject.create_manifests_node
|
22
|
+
it 'creates node in manifests file' do
|
20
23
|
Bebox::PROVISION_STEPS.each do |step|
|
21
24
|
content = File.read("spec/fixtures/puppet/steps/#{step}/manifests/site_with_node.pp.test").gsub(/\s+/, ' ').strip
|
22
25
|
output = File.read("#{subject.project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp").gsub(/\s+/, ' ').strip
|
@@ -24,8 +27,7 @@ describe 'Test 04: Bebox::Node' do
|
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
|
-
it '
|
28
|
-
subject.create_node_checkpoint
|
30
|
+
it 'creates checkpoint' do
|
29
31
|
expect(File.exist?("#{subject.project_root}/.checkpoints/environments/#{subject.environment}/nodes/#{subject.hostname}.yml")).to be (true)
|
30
32
|
node_content = File.read("#{subject.project_root}/.checkpoints/environments/#{subject.environment}/nodes/#{subject.hostname}.yml").gsub(/\s+/, ' ').strip
|
31
33
|
ouput_template = Tilt::ERBTemplate.new('spec/fixtures/node/node_0.test.erb')
|
@@ -33,33 +35,69 @@ describe 'Test 04: Bebox::Node' do
|
|
33
35
|
expect(node_content).to eq(node_output_content)
|
34
36
|
end
|
35
37
|
|
36
|
-
it '
|
38
|
+
it 'list the current nodes' do
|
37
39
|
current_nodes = [subject.hostname]
|
38
40
|
nodes = Bebox::Node.list(subject.project_root, subject.environment, 'nodes')
|
39
41
|
expect(nodes).to include(*current_nodes)
|
40
42
|
end
|
43
|
+
|
44
|
+
it 'gets a checkpoint parameter' do
|
45
|
+
hostname = subject.checkpoint_parameter_from_file('nodes', 'hostname')
|
46
|
+
expect(hostname).to eq(subject.hostname)
|
47
|
+
end
|
41
48
|
end
|
42
49
|
|
43
|
-
context '
|
44
|
-
it '
|
45
|
-
subject.
|
50
|
+
context '01: self methods' do
|
51
|
+
it 'obtains the nodes in a given environment and phase' do
|
52
|
+
expected_nodes = [subject.hostname]
|
53
|
+
object_nodes = Bebox::Node.nodes_in_environment(subject.project_root, subject.environment, 'nodes')
|
54
|
+
expect(object_nodes.map{|node| node.hostname}).to include(*expected_nodes)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'obtains a node provision description state' do
|
58
|
+
message = "Allocated at #{subject.checkpoint_parameter_from_file('nodes', 'created_at')}"
|
59
|
+
description_state = Bebox::Node.node_provision_state(subject.project_root, subject.environment, subject.hostname)
|
60
|
+
expect(description_state).to eq(message)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'obtains a state description for a checkpoint' do
|
64
|
+
checkpoints = %w{nodes prepared_nodes steps/step-0 steps/step-1 steps/step-2 steps/step-3}
|
65
|
+
expected_descriptions = ['Allocated', 'Prepared', 'Provisioned Fundamental step-0',
|
66
|
+
'Provisioned Users layer step-1', 'Provisioned Services layer step-2', 'Provisioned Security layer step-3']
|
67
|
+
descriptions = []
|
68
|
+
checkpoints.each do |checkpoint|
|
69
|
+
descriptions << Bebox::Node.state_from_checkpoint(checkpoint)
|
70
|
+
end
|
71
|
+
expect(descriptions).to include(*expected_descriptions)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'counts the nodes for types' do
|
75
|
+
nodes_count = Bebox::Node.count_all_nodes_by_type(subject.project_root, 'nodes')
|
76
|
+
expect(nodes_count).to eq(1)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context '02: node deletion' do
|
81
|
+
before :all do
|
82
|
+
subject.remove
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'removes the checkpoints' do
|
46
86
|
expect(File.exist?("#{subject.project_root}/.checkpoints/environments/#{subject.environment}/nodes/#{subject.hostname}.yml")).to be (false)
|
47
87
|
end
|
48
88
|
|
49
|
-
it '
|
89
|
+
it 'not list any nodes' do
|
50
90
|
nodes = Bebox::Node.list(subject.project_root, subject.environment, 'nodes')
|
51
91
|
expect(nodes.count).to eq(0)
|
52
92
|
end
|
53
93
|
|
54
|
-
it '
|
55
|
-
subject.remove_hiera_template
|
94
|
+
it 'removes hiera data' do
|
56
95
|
Bebox::PROVISION_STEPS.each do |step|
|
57
96
|
expect(File.exist?("#{subject.project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/hiera/data/#{subject.hostname}.yaml")).to be (false)
|
58
97
|
end
|
59
98
|
end
|
60
99
|
|
61
|
-
it '
|
62
|
-
subject.remove_manifests_node
|
100
|
+
it 'removes node from manifests' do
|
63
101
|
Bebox::PROVISION_STEPS.each do |step|
|
64
102
|
content = File.read("spec/fixtures/puppet/steps/#{step}/manifests/site.pp.test").gsub(/\s+/, ' ').strip
|
65
103
|
output = File.read("#{subject.project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp").gsub(/\s+/, ' ').strip
|
data/spec/ordered_phases_spec.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'project_wizard_spec'
|
2
|
+
require 'wizards/project_wizard_spec'
|
3
|
+
require 'wizards/environment_wizard_spec'
|
4
|
+
require 'wizards/node_wizard_spec'
|
5
|
+
require 'wizards/role_wizard_spec'
|
6
|
+
require 'wizards/profile_wizard_spec'
|
7
|
+
require 'wizards/provision_wizard_spec'
|
3
8
|
require 'project_spec'
|
4
9
|
require 'environment_spec'
|
5
|
-
require 'node_wizard_spec'
|
6
10
|
require 'node_spec'
|
7
11
|
require 'pre_prepare_spec'
|
8
12
|
require 'node0.server1.test/prepare_phase_spec'
|
@@ -44,7 +48,7 @@ describe 'Test 99: ordered specs' do
|
|
44
48
|
project.destroy
|
45
49
|
expect(Dir.exist?("#{project.path}")).to be(false)
|
46
50
|
# Test that the local hosts file was restored
|
47
|
-
puts "\nPlease provide your
|
51
|
+
puts "\nPlease provide your local password, if asked, to configure the local hosts file.".yellow
|
48
52
|
hosts_backup_content = File.read("#{node.local_hosts_path}/hosts_before_#{project.name}").gsub(/\s+/, ' ').strip
|
49
53
|
node.restore_local_hosts(project.name)
|
50
54
|
hosts_content = File.read("#{node.local_hosts_path}/hosts").gsub(/\s+/, ' ').strip
|
data/spec/pre_prepare_spec.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'tilt'
|
3
|
-
require 'colorize'
|
4
3
|
require_relative '../spec/factories/node.rb'
|
5
4
|
|
6
|
-
describe 'Test
|
5
|
+
describe 'Test 09: Bebox::Node' do
|
7
6
|
|
8
7
|
include Bebox::VagrantHelper
|
9
8
|
|
@@ -13,7 +12,6 @@ describe 'Test 05: Bebox::Node' do
|
|
13
12
|
let(:project_root) { "#{Dir.pwd}/tmp/bebox-pname" }
|
14
13
|
let(:environment) { 'vagrant' }
|
15
14
|
let(:project_name) {'bebox-pname'}
|
16
|
-
let(:vagrant_box_base) {"#{Dir.pwd}/ubuntu-server-12042-x64-vbox4210-nocm.box"}
|
17
15
|
|
18
16
|
context 'pre vagrant prepare' do
|
19
17
|
it 'should generate the Vagrantfile' do
|
@@ -32,13 +30,20 @@ describe 'Test 05: Bebox::Node' do
|
|
32
30
|
end
|
33
31
|
|
34
32
|
context 'vagrant prepare' do
|
33
|
+
|
34
|
+
let (:original_hosts_content) { File.read("#{nodes.first.local_hosts_path}/hosts").gsub(/\s+/, ' ').strip }
|
35
|
+
|
36
|
+
before :all do
|
37
|
+
node = nodes.first
|
38
|
+
puts "\nPlease provide your local password, if asked, to configure the local hosts file.".yellow
|
39
|
+
original_hosts_content
|
40
|
+
`sudo rm -rf #{node.local_hosts_path}/hosts_before_#{project_name}`
|
41
|
+
prepare_vagrant(node)
|
42
|
+
end
|
43
|
+
|
35
44
|
describe 'Configure the hosts file' do
|
36
45
|
it 'should create a hosts backup file' do
|
37
46
|
node = nodes.first
|
38
|
-
puts "\nPlease provide your account password, if ask you, to configure the local hosts file.".yellow
|
39
|
-
`sudo rm -rf #{node.local_hosts_path}/hosts_before_#{project_name}`
|
40
|
-
original_hosts_content = File.read("#{node.local_hosts_path}/hosts").gsub(/\s+/, ' ').strip
|
41
|
-
nodes.each{|node| node.backup_local_hosts(project_name)}
|
42
47
|
hosts_backup_file = "#{node.local_hosts_path}/hosts_before_#{project_name}"
|
43
48
|
expect(File).to exist(hosts_backup_file)
|
44
49
|
hosts_backup_content = File.read(hosts_backup_file).gsub(/\s+/, ' ').strip
|
@@ -46,7 +51,6 @@ describe 'Test 05: Bebox::Node' do
|
|
46
51
|
end
|
47
52
|
|
48
53
|
it 'should add the hosts config to hosts file' do
|
49
|
-
nodes.each{|node| add_to_local_hosts(node)}
|
50
54
|
node = nodes.first
|
51
55
|
hosts_content = File.read("#{node.local_hosts_path}/hosts").gsub(/\s+/, ' ').strip
|
52
56
|
expect(hosts_content).to include(*nodes.map{|node| "#{node.ip} #{node.hostname}"})
|
@@ -56,7 +60,6 @@ describe 'Test 05: Bebox::Node' do
|
|
56
60
|
describe 'vagrant setup' do
|
57
61
|
it 'should add the node to vagrant' do
|
58
62
|
vagrant_box_names_expected = nodes.map{|node| "#{project_name}-#{node.hostname}"}
|
59
|
-
nodes.each{|node| add_vagrant_node(project_name, vagrant_box_base, node)}
|
60
63
|
node = nodes.first
|
61
64
|
expect(installed_vagrant_box_names(node)).to include(*vagrant_box_names_expected)
|
62
65
|
end
|
@@ -3,7 +3,7 @@ require_relative '../spec/factories/role.rb'
|
|
3
3
|
require_relative '../spec/factories/profile.rb'
|
4
4
|
require_relative '../spec/factories/provision.rb'
|
5
5
|
|
6
|
-
describe 'Test
|
6
|
+
describe 'Test 15: Pre provision apply step' do
|
7
7
|
|
8
8
|
let(:provision) { build(:provision, step: 'step-2') }
|
9
9
|
let(:role) { build(:role) }
|
data/spec/profile_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require_relative '../spec/factories/profile.rb'
|
3
3
|
require_relative '../lib/bebox/wizards/wizards_helper'
|
4
4
|
|
5
|
-
describe 'Test
|
5
|
+
describe 'Test 12: Bebox::Profile' do
|
6
6
|
|
7
7
|
# include Wizard helper methods
|
8
8
|
include Bebox::WizardsHelper
|
@@ -17,7 +17,7 @@ describe 'Test 08: Bebox::Profile' do
|
|
17
17
|
|
18
18
|
context '00: profile creation' do
|
19
19
|
|
20
|
-
it '
|
20
|
+
it 'validates the profile name' do
|
21
21
|
# Test not valid reserved words
|
22
22
|
Bebox::RESERVED_WORDS.each{|reserved_word| expect(valid_puppet_class_name?(reserved_word)).to be (false)}
|
23
23
|
# Test not valid start by undescore
|
@@ -30,7 +30,7 @@ describe 'Test 08: Bebox::Profile' do
|
|
30
30
|
expect(valid_puppet_class_name?(subject.name)).to be (true)
|
31
31
|
end
|
32
32
|
|
33
|
-
it '
|
33
|
+
it 'cleans the profile path' do
|
34
34
|
# Profile path with slash
|
35
35
|
expect(Bebox::Profile.cleanpath('/')).to eq ('')
|
36
36
|
# Profile path with multiple slashes
|
@@ -39,17 +39,17 @@ describe 'Test 08: Bebox::Profile' do
|
|
39
39
|
expect(Bebox::Profile.cleanpath(subject.path)).to eq (subject.path)
|
40
40
|
end
|
41
41
|
|
42
|
-
it '
|
42
|
+
it 'creates profile directories' do
|
43
43
|
expect(Dir.exist?("#{subject.absolute_path}/manifests")).to be (true)
|
44
44
|
end
|
45
45
|
|
46
|
-
it '
|
46
|
+
it 'generates the manifests file' do
|
47
47
|
output_file = File.read("#{subject.absolute_path}/manifests/init.pp").strip
|
48
48
|
expected_content = File.read("spec/fixtures/puppet/profiles/#{subject.relative_path}/manifests/init.pp.test").strip
|
49
49
|
expect(output_file).to eq(expected_content)
|
50
50
|
end
|
51
51
|
|
52
|
-
it '
|
52
|
+
it 'generates the Puppetfile' do
|
53
53
|
output_file = File.read("#{subject.absolute_path}/Puppetfile").strip
|
54
54
|
expected_content = File.read("spec/fixtures/puppet/profiles/#{subject.relative_path}/Puppetfile.test").strip
|
55
55
|
expect(output_file).to eq(expected_content)
|
@@ -57,7 +57,7 @@ describe 'Test 08: Bebox::Profile' do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
context '01: profile list' do
|
60
|
-
it '
|
60
|
+
it 'list the profiles' do
|
61
61
|
current_profiles = [subject.relative_path]
|
62
62
|
profiles = Bebox::Profile.list(subject.project_root)
|
63
63
|
expect(profiles).to include(*current_profiles)
|
@@ -65,10 +65,23 @@ describe 'Test 08: Bebox::Profile' do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
context '02: profile deletion' do
|
68
|
-
it '
|
68
|
+
it 'deletes the profile directory' do
|
69
69
|
subject.remove
|
70
70
|
expect(Dir.exist?("#{subject.absolute_path}")).to be (false)
|
71
71
|
end
|
72
72
|
end
|
73
|
+
|
74
|
+
context '03: self methods' do
|
75
|
+
it 'counts the number of profiles in the project' do
|
76
|
+
profiles_count = Bebox::Profile.profiles_count(subject.project_root)
|
77
|
+
expect(profiles_count).to eq(9)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'validates a profile with path' do
|
81
|
+
path = 'basic/test'
|
82
|
+
valid_path = Bebox::Profile.valid_pathname?(path)
|
83
|
+
expect(valid_path).to eq(true)
|
84
|
+
end
|
85
|
+
end
|
73
86
|
end
|
74
87
|
end
|
data/spec/project_spec.rb
CHANGED
@@ -1,31 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require_relative '../spec/factories/project.rb'
|
3
3
|
|
4
|
-
describe 'Test
|
4
|
+
describe 'Test 06: Bebox::Project' do
|
5
5
|
|
6
6
|
describe 'Project creation' do
|
7
7
|
|
8
8
|
subject { build(:project) }
|
9
|
+
let(:temporary_project) { build(:project, name: 'temporary_project') }
|
9
10
|
|
10
|
-
|
11
|
-
subject.
|
11
|
+
before :all do
|
12
|
+
subject.create
|
13
|
+
temporary_project.create
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'creates the project directory' do
|
12
17
|
expect(Dir.exist?(subject.path)).to be true
|
13
18
|
end
|
14
19
|
|
20
|
+
it 'destroys a temporary project' do
|
21
|
+
temporary_project.destroy
|
22
|
+
expect(Dir.exist?(temporary_project.path)).to be false
|
23
|
+
end
|
24
|
+
|
15
25
|
context '00: Project config files creation' do
|
16
|
-
it '
|
17
|
-
|
18
|
-
subject.create_templates_directories
|
26
|
+
it 'creates the support directories' do
|
27
|
+
expected_directories = ['templates', 'roles', 'profiles']
|
19
28
|
directories = []
|
20
29
|
directories << Dir["#{subject.path}/*/"].map { |f| File.basename(f) }
|
21
30
|
directories << Dir["#{subject.path}/*/*/"].map { |f| File.basename(f) }
|
22
31
|
directories << Dir["#{subject.path}/*/*/*/"].map { |f| File.basename(f) }
|
23
|
-
expect(directories.flatten).to include(*
|
32
|
+
expect(directories.flatten).to include(*expected_directories)
|
24
33
|
end
|
25
34
|
|
26
|
-
it '
|
35
|
+
it 'creates the config deploy directories' do
|
27
36
|
directories_expected = ['config', 'deploy', 'keys', 'environments']
|
28
|
-
subject.create_config_deploy_directories
|
29
37
|
directories = []
|
30
38
|
directories << Dir["#{subject.path}/*/"].map { |f| File.basename(f) }
|
31
39
|
directories << Dir["#{subject.path}/*/*/"].map { |f| File.basename(f) }
|
@@ -33,36 +41,31 @@ describe 'Test 01: Bebox::Project' do
|
|
33
41
|
expect(directories.flatten).to include(*directories_expected)
|
34
42
|
end
|
35
43
|
|
36
|
-
it '
|
37
|
-
subject.generate_dot_bebox_file
|
44
|
+
it 'generates a .bebox file' do
|
38
45
|
dotbebox_content = File.read("#{subject.path}/.bebox").gsub(/\s+/, ' ').strip
|
39
46
|
ouput_template = Tilt::ERBTemplate.new('spec/fixtures/dot_bebox.test.erb')
|
40
|
-
dotbebox_expected_content = ouput_template.render(nil, created_at: subject.created_at).gsub(/\s+/, ' ').strip
|
47
|
+
dotbebox_expected_content = ouput_template.render(nil, created_at: subject.created_at, bebox_path: Dir.pwd).gsub(/\s+/, ' ').strip
|
41
48
|
expect(dotbebox_content).to eq(dotbebox_expected_content)
|
42
49
|
end
|
43
50
|
|
44
|
-
it '
|
45
|
-
subject.generate_gitignore_file
|
51
|
+
it 'generates a .gitignore file' do
|
46
52
|
expected_content = File.read("#{subject.path}/.gitignore")
|
47
53
|
output_file = File.read('spec/fixtures/dot_gitignore.test')
|
48
54
|
expect(output_file).to eq(expected_content)
|
49
55
|
end
|
50
56
|
|
51
|
-
it '
|
52
|
-
subject.generate_ruby_version
|
57
|
+
it 'generates a .ruby-version file' do
|
53
58
|
version = File.read("#{subject.path}/.ruby-version").strip
|
54
59
|
expect(version).to eq(RUBY_VERSION)
|
55
60
|
end
|
56
61
|
|
57
|
-
it '
|
58
|
-
subject.create_capfile
|
62
|
+
it 'creates a Capfile' do
|
59
63
|
expected_content = File.read("#{subject.path}/Capfile")
|
60
64
|
output_file = File.read('spec/fixtures/Capfile.test')
|
61
65
|
expect(output_file).to eq(expected_content)
|
62
66
|
end
|
63
67
|
|
64
|
-
it '
|
65
|
-
subject.generate_deploy_files
|
68
|
+
it 'generates the deploy files' do
|
66
69
|
# Generate deploy.rb file
|
67
70
|
config_deploy_content = File.read("#{subject.path}/config/deploy.rb").gsub(/\s+/, ' ').strip
|
68
71
|
config_deploy_output_content = File.read("spec/fixtures/config/deploy.test").gsub(/\s+/, ' ').strip
|
@@ -75,8 +78,7 @@ describe 'Test 01: Bebox::Project' do
|
|
75
78
|
end
|
76
79
|
end
|
77
80
|
|
78
|
-
it '
|
79
|
-
subject.create_gemfile
|
81
|
+
it 'creates a Gemfile' do
|
80
82
|
content = File.read("#{subject.path}/Gemfile").gsub(/\s+/, ' ').strip
|
81
83
|
output = File.read("spec/fixtures/Gemfile.test").gsub(/\s+/, ' ').strip
|
82
84
|
expect(output).to eq(content)
|
@@ -84,24 +86,21 @@ describe 'Test 01: Bebox::Project' do
|
|
84
86
|
end
|
85
87
|
|
86
88
|
context '01: Create puppet base' do
|
87
|
-
it '
|
88
|
-
subject.generate_so_dependencies_files
|
89
|
+
it 'generates the SO dependencies files' do
|
89
90
|
content = File.read("#{subject.path}/puppet/prepare/dependencies/ubuntu/packages")
|
90
91
|
output = File.read("spec/fixtures/puppet/ubuntu_dependencies.test")
|
91
92
|
expect(output).to eq(content)
|
92
93
|
end
|
93
94
|
|
94
|
-
it '
|
95
|
-
subject.copy_puppet_install_files
|
95
|
+
it 'copy the puppet installation files' do
|
96
96
|
expect(Dir.exist?("#{subject.path}/puppet/lib/deb/puppet_3.6.0")).to be (true)
|
97
97
|
expect(Dir["#{subject.path}/puppet/lib/deb/puppet_3.6.0/*"].count).to eq(18)
|
98
98
|
end
|
99
99
|
|
100
|
-
it '
|
100
|
+
it 'generates the step directories' do
|
101
101
|
expected_directories = ['prepare', 'profiles', 'roles', 'steps',
|
102
102
|
'0-fundamental', '1-users', '2-services', '3-security',
|
103
103
|
'hiera', 'manifests', 'modules', 'data']
|
104
|
-
subject.generate_steps_directories
|
105
104
|
directories = []
|
106
105
|
directories << Dir["#{subject.path}/puppet/*/"].map { |f| File.basename(f) }
|
107
106
|
directories << Dir["#{subject.path}/puppet/*/*/"].map { |f| File.basename(f) }
|
@@ -110,10 +109,9 @@ describe 'Test 01: Bebox::Project' do
|
|
110
109
|
expect(directories.flatten).to include(*expected_directories)
|
111
110
|
end
|
112
111
|
|
113
|
-
it '
|
112
|
+
it 'copy the default roles and profiles' do
|
114
113
|
expected_roles_directories = ['fundamental', 'security', 'users']
|
115
114
|
expected_profiles_directories = ['profiles', 'base', 'fundamental', 'ruby', 'manifests', 'sudo', 'users', 'security', 'fail2ban', 'iptables', 'ssh', 'sysctl']
|
116
|
-
subject.copy_default_roles_profiles
|
117
115
|
directories = Dir["#{subject.path}/puppet/roles/*/"].map { |f| File.basename(f) }.uniq
|
118
116
|
expect(directories).to include(*expected_roles_directories)
|
119
117
|
directories = Dir["#{subject.path}/puppet/profiles/**/"].map { |f| File.basename(f) }.uniq
|
@@ -121,24 +119,21 @@ describe 'Test 01: Bebox::Project' do
|
|
121
119
|
end
|
122
120
|
|
123
121
|
context '02: generate steps templates' do
|
124
|
-
|
125
|
-
subject.generate_steps_templates
|
126
|
-
end
|
127
|
-
it 'should generate manifests template' do
|
122
|
+
it 'generates the manifests templates' do
|
128
123
|
Bebox::PROVISION_STEPS.each do |step|
|
129
124
|
content = File.read("spec/fixtures/puppet/steps/#{step}/manifests/site.pp.test")
|
130
125
|
output = File.read("#{subject.path}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp")
|
131
126
|
expect(output).to eq(content)
|
132
127
|
end
|
133
128
|
end
|
134
|
-
it '
|
129
|
+
it 'generates the hiera config template' do
|
135
130
|
Bebox::PROVISION_STEPS.each do |step|
|
136
131
|
content = File.read("spec/fixtures/puppet/steps/#{step}/hiera/hiera.yaml.test")
|
137
132
|
output = File.read("#{subject.path}/puppet/steps/#{Bebox::Provision.step_name(step)}/hiera/hiera.yaml")
|
138
133
|
expect(output).to eq(content)
|
139
134
|
end
|
140
135
|
end
|
141
|
-
it '
|
136
|
+
it 'generates the hiera data common' do
|
142
137
|
Bebox::PROVISION_STEPS.each do |step|
|
143
138
|
content = File.read("spec/fixtures/puppet/steps/#{step}/hiera/data/common.yaml.test")
|
144
139
|
output = File.read("#{subject.path}/puppet/steps/#{Bebox::Provision.step_name(step)}/hiera/data/common.yaml")
|
@@ -149,9 +144,8 @@ describe 'Test 01: Bebox::Project' do
|
|
149
144
|
end
|
150
145
|
|
151
146
|
context '03: checkpoints' do
|
152
|
-
it '
|
147
|
+
it 'creates checkpoints directories' do
|
153
148
|
expected_directories = ['.checkpoints', 'environments']
|
154
|
-
subject.create_checkpoints
|
155
149
|
directories = []
|
156
150
|
directories << Dir["#{subject.path}/.checkpoints/"].map { |f| File.basename(f) }
|
157
151
|
directories << Dir["#{subject.path}/.checkpoints/*/"].map { |f| File.basename(f) }
|
@@ -160,19 +154,13 @@ describe 'Test 01: Bebox::Project' do
|
|
160
154
|
end
|
161
155
|
|
162
156
|
context '04: bundle project' do
|
163
|
-
it '
|
164
|
-
subject.bundle_project
|
157
|
+
it 'install project dependencies' do
|
165
158
|
expect(File).to exist("#{subject.path}/Gemfile.lock")
|
166
159
|
end
|
167
160
|
end
|
168
161
|
|
169
162
|
context '05: create default environments' do
|
170
|
-
|
171
|
-
before(:all) do
|
172
|
-
subject.create_default_environments
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'should generate deploy files' do
|
163
|
+
it 'generates the deploy environment files' do
|
176
164
|
subject.environments.each do |environment|
|
177
165
|
config_deploy_vagrant_content = File.read("#{subject.path}/config/deploy/#{environment.name}.rb").gsub(/\s+/, ' ').strip
|
178
166
|
config_deploy_vagrant_output_content = File.read("spec/fixtures/config/deploy/#{environment.name}.test").gsub(/\s+/, ' ').strip
|
@@ -180,7 +168,7 @@ describe 'Test 01: Bebox::Project' do
|
|
180
168
|
end
|
181
169
|
end
|
182
170
|
|
183
|
-
it '
|
171
|
+
it 'creates environments checkpoints' do
|
184
172
|
expected_directories = ['vagrant', 'staging', 'production', 'nodes', 'prepared_nodes',
|
185
173
|
'steps', 'step-0', 'step-1', 'step-2', 'step-3']
|
186
174
|
directories = []
|
@@ -190,7 +178,7 @@ describe 'Test 01: Bebox::Project' do
|
|
190
178
|
expect(directories.flatten).to include(*expected_directories)
|
191
179
|
end
|
192
180
|
|
193
|
-
it '
|
181
|
+
it 'creates environments capistrano base' do
|
194
182
|
subject.environments.each do |environment|
|
195
183
|
expect(Dir.exist?("#{subject.path}/config/keys/environments/#{environment.name}")).to be (true)
|
196
184
|
end
|
@@ -198,5 +186,23 @@ describe 'Test 01: Bebox::Project' do
|
|
198
186
|
expect(File.exist?("#{subject.path}/config/keys/environments/vagrant/id_rsa.pub")).to be (true)
|
199
187
|
end
|
200
188
|
end
|
189
|
+
|
190
|
+
context '06: self methods' do
|
191
|
+
it 'obtains a vagrant box provider' do
|
192
|
+
vagrant_box_provider = Bebox::Project.vagrant_box_provider_from_file(subject.path)
|
193
|
+
expect(vagrant_box_provider).to eq(subject.vagrant_box_provider)
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'obtains a vagrant box base' do
|
197
|
+
vagrant_box_base = Bebox::Project.vagrant_box_base_from_file(subject.path)
|
198
|
+
expect(vagrant_box_base).to eq(subject.vagrant_box_base)
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'obtains the SO dependencies' do
|
202
|
+
expected_dependencies = "git-core build-essential curl whois openssl libxslt1-dev autoconf bison libreadline5 libsqlite3-dev"
|
203
|
+
dependencies = Bebox::Project.so_dependencies
|
204
|
+
expect(dependencies).to eq(expected_dependencies)
|
205
|
+
end
|
206
|
+
end
|
201
207
|
end
|
202
208
|
end
|