rouster 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/LICENSE +9 -0
  4. data/README.md +175 -0
  5. data/Rakefile +65 -0
  6. data/Vagrantfile +23 -0
  7. data/examples/bootstrap.rb +113 -0
  8. data/examples/demo.rb +71 -0
  9. data/examples/error.rb +30 -0
  10. data/lib/rouster.rb +737 -0
  11. data/lib/rouster/deltas.rb +481 -0
  12. data/lib/rouster/puppet.rb +398 -0
  13. data/lib/rouster/testing.rb +743 -0
  14. data/lib/rouster/tests.rb +596 -0
  15. data/path_helper.rb +21 -0
  16. data/rouster.gemspec +30 -0
  17. data/test/basic.rb +10 -0
  18. data/test/functional/deltas/test_get_crontab.rb +99 -0
  19. data/test/functional/deltas/test_get_groups.rb +48 -0
  20. data/test/functional/deltas/test_get_packages.rb +71 -0
  21. data/test/functional/deltas/test_get_ports.rb +119 -0
  22. data/test/functional/deltas/test_get_services.rb +43 -0
  23. data/test/functional/deltas/test_get_users.rb +45 -0
  24. data/test/functional/puppet/test_facter.rb +59 -0
  25. data/test/functional/test_caching.rb +124 -0
  26. data/test/functional/test_destroy.rb +51 -0
  27. data/test/functional/test_dirs.rb +88 -0
  28. data/test/functional/test_files.rb +64 -0
  29. data/test/functional/test_get.rb +76 -0
  30. data/test/functional/test_inspect.rb +31 -0
  31. data/test/functional/test_is_dir.rb +118 -0
  32. data/test/functional/test_is_file.rb +119 -0
  33. data/test/functional/test_new.rb +92 -0
  34. data/test/functional/test_put.rb +81 -0
  35. data/test/functional/test_rebuild.rb +49 -0
  36. data/test/functional/test_restart.rb +44 -0
  37. data/test/functional/test_run.rb +77 -0
  38. data/test/functional/test_status.rb +38 -0
  39. data/test/functional/test_suspend.rb +31 -0
  40. data/test/functional/test_up.rb +27 -0
  41. data/test/functional/test_validate_file.rb +30 -0
  42. data/test/puppet/manifests/default.pp +9 -0
  43. data/test/puppet/manifests/hiera.yaml +12 -0
  44. data/test/puppet/manifests/hieradata/common.json +3 -0
  45. data/test/puppet/manifests/hieradata/vagrant.json +3 -0
  46. data/test/puppet/manifests/manifest.pp +78 -0
  47. data/test/puppet/modules/role/manifests/ui.pp +5 -0
  48. data/test/puppet/test_apply.rb +149 -0
  49. data/test/puppet/test_roles.rb +186 -0
  50. data/test/tunnel_vs_scp.rb +41 -0
  51. data/test/unit/puppet/test_get_puppet_star.rb +68 -0
  52. data/test/unit/test_generate_unique_mac.rb +43 -0
  53. data/test/unit/test_new.rb +31 -0
  54. data/test/unit/test_parse_ls_string.rb +334 -0
  55. data/test/unit/test_traverse_up.rb +43 -0
  56. data/test/unit/testing/test_meets_constraint.rb +55 -0
  57. data/test/unit/testing/test_validate_file.rb +112 -0
  58. data/test/unit/testing/test_validate_group.rb +72 -0
  59. data/test/unit/testing/test_validate_package.rb +69 -0
  60. data/test/unit/testing/test_validate_port.rb +98 -0
  61. data/test/unit/testing/test_validate_service.rb +73 -0
  62. data/test/unit/testing/test_validate_user.rb +92 -0
  63. metadata +203 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ddfb8d54a1eb8670b64d6638c81866bc49764af6
4
+ data.tar.gz: 3b4f207c05540dc6daa16cfe29d46948b8ff3aab
5
+ SHA512:
6
+ metadata.gz: 2878c4b222c5ff88a77db0a88ae5102752f6fcdb31fe7613cdba71f8c51b4228db33f0e4a9c34aa62e184f43e0b183fb66cb5574843673c009d12d32f18b35f5
7
+ data.tar.gz: 910cd5e1519e3de2f0c759799a04d8dce487e97d8c29f456061a75cf63e9cbae97023ecd8feeb5e047165d1f22c5e80be88f6be61fa9ddfd7d3d233108292415
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ doc/*
2
+ .vagrant
3
+ *.box
4
+ *.swp
5
+ *tmp*
6
+ *.gem
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) 2012, Salesforce.com, Inc.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+ Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,175 @@
1
+ Rouster
2
+ ======
3
+
4
+ ```rb
5
+ Rouster.is_a?('abstraction layer for controlling Vagrant virtual machines')
6
+ => true
7
+ ```
8
+
9
+ Rouster was conceived as the missing piece needed to functionally test Puppet manifests: while RSpec is nice (and _much_ faster), compiling a catalog and applying it are 2 distinct operations.
10
+
11
+ ```rb
12
+ app = Rouster.new(:name => 'app' )
13
+ app.up()
14
+
15
+ p app.run('/sbin/service puppet once -t', 2)
16
+ # or p app.run_puppet('master', { :expected_exitcode => 2}), if you've required 'rouster/puppet'
17
+
18
+ app.destroy()
19
+ ```
20
+
21
+ The first implementation of Rouster was in Perl, called [Salesforce::Vagrant](http://github.com/forcedotcom/SalesforceVagrant). Salesforce::Vagrant is functional, but new functionality may or may not be ported back.
22
+
23
+ ## Requirements
24
+
25
+ * [Ruby](http://rubylang.org), version 2.0+ (best attempt made to support 1.8.7 and 1.9.3 as well)
26
+ * [Vagrant](http://vagrantup.com), version 1.0.5+
27
+
28
+ Note: Vagrant itself requires VirtualBox or VMWare Fusion (1.0.3+)
29
+
30
+ Note: Rouster should work exactly the same on Windows as it does on \*nix and OSX (minus rouster/deltas.rb functionality, at least currently),
31
+ but no real testing has been done to confirm this. Please file issues as appropriate.
32
+
33
+ ### From-source installation (latest)
34
+
35
+ ```sh
36
+ git clone https://github.com/chorankates/rouster.git
37
+ cd rouster
38
+ rake buildgem
39
+ gem install rouster-<version>.gem
40
+ ```
41
+
42
+ ### pre-built gem installation (stable)
43
+
44
+ [RubyGems](http://rubygems.org/gems/rouster)
45
+ [![Gem Version](https://badge.fury.io/rb/rouster.png)](http://badge.fury.io/rb/rouster)
46
+
47
+ ```sh
48
+ gem install rouster
49
+ ```
50
+
51
+ ## Using Rouster
52
+
53
+ Rouster supports many of the vagrant faces:
54
+ * destroy()
55
+ * suspend()
56
+ * status()
57
+ * up()
58
+
59
+ All Rouster workers also support:
60
+ * get()
61
+ * put()
62
+ * rebuild()
63
+ * restart()
64
+ * run()
65
+
66
+ And depending on which pieces of rouster you 'require':
67
+
68
+ * rouster/deltas
69
+ * get_groups()
70
+ * get_packages()
71
+ * get_ports()
72
+ * get_services()
73
+ * get_users()
74
+
75
+ * rouster/puppet
76
+ * facter()
77
+ * get_catalog()
78
+ * get_puppet_errors()
79
+ * get_puppet_notices()
80
+ * parse_catalog()
81
+ * remove_existing_certs()
82
+ * run_puppet()
83
+
84
+ * rouster/testing
85
+ * validate_file()
86
+ * validate_group()
87
+ * validate_package()
88
+ * validate_service()
89
+ * validate_user()
90
+
91
+ * rouster/tests
92
+ * is_dir?()
93
+ * is_executable?()
94
+ * is_file?()
95
+ * is_group?()
96
+ * is_in_file?()
97
+ * is_in_path?()
98
+ * is_package?()
99
+ * is_port_active?()
100
+ * is_port_open?()
101
+ * is_process_running?())
102
+ * is_readable?()
103
+ * is_service?()
104
+ * is_service_running?()
105
+ * is_user?()
106
+ * is_user_in_group?()
107
+ * is_writeable?()
108
+
109
+ These additional methods are added to the Rouster object via class extension.
110
+
111
+ ### basic instantiation and usage
112
+
113
+ ```rb
114
+ require 'rouster'
115
+
116
+ # the value for the 'name' attribute should be a name shown when you execute `vagrant status`
117
+ app = Rouster.new(:name => 'app')
118
+
119
+ # equivalent to `vagrant up app`
120
+ app.up()
121
+
122
+ # STD(OUT|ERR) of this is available in app.get_output()
123
+ app.run('cat /etc/hosts')
124
+ app.put('new-foo', '/tmp/foo')
125
+ app.get('/tmp/foo')
126
+
127
+ app.destroy()
128
+ ```
129
+
130
+ ### functional puppet test
131
+
132
+ ```rb
133
+ require 'rouster'
134
+ require 'rouster/puppet'
135
+ require 'test/unit'
136
+
137
+ class TestPuppetRun < Test::Unit::TestCase
138
+
139
+ def setup
140
+ @ppm = Rouster.new(:name => 'ppm', :verbose => 4)
141
+ @app = Rouster.new(:name => 'app')
142
+ end
143
+
144
+ def test_it
145
+
146
+ workers = [@ppm, @app]
147
+
148
+ workers.each do |w|
149
+ # tear them down and build back up for clean run
150
+ w.destroy()
151
+ w.up()
152
+
153
+ #res = w.run('puppet agent -t --environment development', 2)
154
+ assert_raises_nothing do
155
+ res = w.run_puppet('master', { :expected_exitcode => 2 })
156
+ end
157
+ assert_match(/Finished catalog/, res, "output contains 'Finished catalog'")
158
+ end
159
+ end
160
+
161
+ def teardown
162
+ @ppm.destroy()
163
+ @app.destroy()
164
+ end
165
+
166
+ end
167
+ ```
168
+
169
+
170
+ ## Base Methods
171
+
172
+ ```rb
173
+ irb(main):003:0> (Rouster.new(:name => 'app').methods - Object.methods).sort
174
+ => [:_run, :_vm, :check_key_permissions, :connect_ssh_tunnel, :deltas, :destroy, :dir, :exitcode, :facter, :facts, :file, :generate_unique_mac, :get, :get_catalog, :get_groups, :get_output, :get_packages, :get_ports, :get_puppet_errors, :get_puppet_notices, :get_services, :get_ssh_info, :get_users, :is_available_via_ssh?, :is_dir?, :is_executable?, :is_file?, :is_group?, :is_in_file?, :is_in_path?, :is_package?, :is_passthrough?, :is_port_active?, :is_port_open?, :is_process_running?, :is_readable?, :is_service?, :is_service_running?, :is_user?, :is_user_in_group?, :is_writeable?, :log, :os_type, :output, :parse_catalog, :parse_ls_string, :passthrough, :put, :rebuild, :remove_existing_certs, :restart, :run, :run_puppet, :sshkey, :status, :sudo, :suspend, :traverse_up, :up, :uses_sudo?, :vagrantfile, :verbosity]
175
+ ```
data/Rakefile ADDED
@@ -0,0 +1,65 @@
1
+ require sprintf('%s/%s', File.dirname(File.expand_path(__FILE__)), 'path_helper')
2
+ require 'rubygems'
3
+ require 'rake/testtask'
4
+
5
+ task :buildgem do
6
+ sh 'gem build rouster.gemspec'
7
+ end
8
+
9
+ task :default do
10
+ sh 'ruby test/basic.rb'
11
+ end
12
+
13
+ task :demo do
14
+ sh 'ruby examples/demo.rb'
15
+ end
16
+
17
+ task :doc do
18
+ sh 'rdoc --line-numbers lib/*'
19
+ end
20
+
21
+ task :examples do
22
+ Dir['examples/**/*.rb'].each do |example|
23
+ sh "ruby #{example}"
24
+ end
25
+ end
26
+
27
+ task :reek do
28
+ sh "reek lib/**/*.rb"
29
+ end
30
+
31
+ Rake::TestTask.new do |t|
32
+ t.name = 'test'
33
+ t.libs << 'lib'
34
+ t.test_files = FileList['test/**/test_*.rb']
35
+ t.verbose = true
36
+ end
37
+
38
+ Rake::TestTask.new do |t|
39
+ t.name = 'unit'
40
+ t.libs << 'lib'
41
+ t.test_files = FileList['test/unit/**/test_*.rb']
42
+ t.verbose = true
43
+ end
44
+
45
+ Rake::TestTask.new do |t|
46
+ t.name = 'functional'
47
+ t.libs << 'lib'
48
+ t.test_files = FileList['test/functional/**/test_*.rb']
49
+ t.verbose = true
50
+ end
51
+
52
+ Rake::TestTask.new do |t|
53
+ t.name = 'deltas'
54
+ t.libs << 'lib'
55
+ t.test_files = FileList['test/functional/deltas/test_*.rb']
56
+ t.verbose = true
57
+ end
58
+
59
+ Rake::TestTask.new do |t|
60
+ t.name = 'puppet'
61
+ t.libs << 'lib'
62
+ t.test_files = FileList['test/puppet/test*.rb']
63
+ t.verbose = true
64
+ end
65
+
data/Vagrantfile ADDED
@@ -0,0 +1,23 @@
1
+ # stripped down example piab Vagrantfile for rouster
2
+
3
+ box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box'
4
+ box_name = 'centos6'
5
+ boxes = [:ppm, :app]
6
+
7
+ Vagrant::Config.run do |config|
8
+ boxes.each do |box|
9
+ config.vm.define box do |worker|
10
+
11
+ worker.vm.box = box_name
12
+ worker.vm.box_url = box_url
13
+ worker.vm.host_name = box.to_s
14
+ worker.vm.network :hostonly, sprintf('10.0.1.%s', rand(253).to_i + 1)
15
+ worker.ssh.forward_agent = true
16
+
17
+ if box.to_s.eql?('ppm') and File.directory?('../puppet')
18
+ worker.vm.share_folder('puppet', '/etc/puppet/', '../puppet/')
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,113 @@
1
+ require sprintf('%s/../%s', File.dirname(File.expand_path(__FILE__)), 'path_helper')
2
+
3
+ require 'rouster'
4
+ require 'rouster/puppet'
5
+ require 'rouster/tests'
6
+
7
+ app = Rouster.new(:name => 'app', :verbosity => 4, :sudo => true)
8
+ ppm = Rouster.new(:name => 'ppm', :verbosity => 1, :sudo => true)
9
+
10
+ # passthrough boxes do not need to specify a name
11
+ # commented out currently because passthrough is not MVP
12
+ #lpt = Rouster.new(:passthrough => 'local', :verbosity => 4)
13
+ #rpt = Rouster.new(:passthrough => 'remote', :verbosity => 4, :sshkey => '~/.ssh/id_dsa')
14
+
15
+ workers = [app]
16
+
17
+ workers.each do |w|
18
+ p '%s config: ' % w.name
19
+ p w
20
+
21
+ p 'status: %s' % w.status()
22
+ p 'upping the box'
23
+ w.up()
24
+
25
+ p sprintf('%s status: %s', w.name, w.status())
26
+ p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
27
+
28
+ p 'suspending the box'
29
+ w.suspend()
30
+
31
+ p sprintf('%s status: %s', w.name, w.status())
32
+ p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
33
+
34
+ p 'bringing the box back'
35
+ w.up()
36
+
37
+ p sprintf('%s status: %s', w.name, w.status())
38
+ p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
39
+
40
+ ## expected success
41
+ p sprintf('is_dir?(/tmp): %s', w.is_dir?('/tmp'))
42
+ p sprintf('is_exectuable?(/sbin/service: %s', w.is_executable?('/sbin/service'))
43
+ p sprintf('is_file?(/etc/hosts): %s', w.is_file?('/etc/hosts'))
44
+ p sprintf('is_group?(root): %s', w.is_group?('root'))
45
+ p sprintf('is_in_file?(/etc/hosts, puppet): %s', w.is_in_file?('/etc/hosts', 'puppet'))
46
+ p sprintf('is_in_path?(ping): %s', w.is_in_path?('ping'))
47
+ p sprintf('is_package?(libpcap): %s', w.is_package?('libpcap'))
48
+ p sprintf('is_port_open?(9999): %s', w.is_port_open?(9999))
49
+ p sprintf('is_port_active?(22): %s', w.is_port_active?(22))
50
+ p sprintf('is_process_running?(sshd): %s', w.is_process_running?('sshd'))
51
+ p sprintf('is_readable?(/etc/hosts): %s', w.is_readable?('/etc/hosts'))
52
+ p sprintf('is_service?(iptables): %s', w.is_service?('iptables'))
53
+ p sprintf('is_service_running?(iptables): %s', w.is_service_running?('iptables'))
54
+ p sprintf('is_user?(root): %s', w.is_user?('root'))
55
+ p sprintf('is_writeable?(/etc/hosts): %s', w.is_writeable?('/etc/hosts'))
56
+
57
+ ## expected failure
58
+ p sprintf('is_dir?(/dne): %s', w.is_dir?('/dne'))
59
+ p sprintf('is_executable?(fizzybang): %s', w.is_executable?('fizzybang'))
60
+ p sprintf('is_file?(/dne/fizzy): %s', w.is_file?('/dne/fizzy'))
61
+ p sprintf('is_group?(three-amigos): %s', w.is_group?('three-amigos'))
62
+ p sprintf('is_in_file?(/etc/hosts, this content is not there): %s', w.is_in_file?('/etc/hosts', 'this content is not there'))
63
+ p sprintf('is_in_file?(/dne/fizzy, this file is not there): %s', w.is_in_file?('/dne/fizzy', 'this file is not there'))
64
+ p sprintf('is_in_path?(fizzy): %s', w.is_in_path?('fizzy'))
65
+ p sprintf('is_package?(fizzybang): %s', w.is_package?('fizzybang'))
66
+ p sprintf('is_port_open?(123, udp): %s', w.is_port_open?(123, 'udp'))
67
+ p sprintf('is_port_open?(22): %s', w.is_port_open?(22))
68
+ p sprintf('is_process_running?(fizzy): %s', w.is_process_running?('fizzy'))
69
+ p sprintf('is_readable?(/dne/fizzy): %s', w.is_readable?('/dne/fizzy'))
70
+ p sprintf('is_service?(syslogd): %s', w.is_service?('syslogd'))
71
+ p sprintf('is_service_running?(smartd): %s', w.is_service_running?('smartd'))
72
+ p sprintf('is_user?(toor): %s', w.is_user?('toor'))
73
+ #p sprintf('is_writable?(/etc/hosts): %s', w.is_writeable?('/etc/hosts')) # running as sudo, so everything is writeable -- can we test this with a file in a path that DNE?
74
+
75
+ # put a file on the box and then bring it back
76
+ w.put(__FILE__, '/tmp/foobar')
77
+ w.get('/tmp/foobar', 'foobar_from_piab_host.tmp')
78
+
79
+ # output should be the same
80
+ p sprintf('%s uname -a via run: %s', w.name, w.run('uname -a'))
81
+ p sprintf('%s uname -a via output: %s', w.name, w.get_output())
82
+
83
+ begin
84
+ p sprintf('%s fizzy: %s', w.name, w.run('fizzy'))
85
+ rescue => e
86
+ p e
87
+ end
88
+
89
+ begin
90
+ p sprintf('%s ls /dne/ %s', w.name, w.run('ls /dne/'))
91
+ rescue => e
92
+ p e
93
+ end
94
+
95
+ p sprintf('%s ls /dne/ expected exit code 2: %s', w.name, w.run('ls /dne/', 2))
96
+
97
+ # tear the box down
98
+ p 'destroying the box'
99
+ w.destroy()
100
+
101
+ p sprintf('%s status: %s', w.name, w.status())
102
+ p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
103
+
104
+ # bring it back again
105
+ p 'upping the box again'
106
+ w.up()
107
+
108
+ p sprintf('%s status: %s', w.name, w.status())
109
+ p sprintf('%s available via ssh: %s', w.name, w.is_available_via_ssh?())
110
+
111
+ end
112
+
113
+ exit
data/examples/demo.rb ADDED
@@ -0,0 +1,71 @@
1
+ require sprintf('%s/../%s', File.dirname(File.expand_path(__FILE__)), 'path_helper')
2
+
3
+ require 'rouster'
4
+ require 'rouster/tests'
5
+
6
+ @app = Rouster.new(:name => 'app', :sudo => true, :verbosity => 3)
7
+ @app.up()
8
+
9
+ # get list of packages
10
+ before_packages = @app.get_packages()
11
+
12
+ # need this if not on vpn
13
+ @app.run('wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm')
14
+ @app.run('wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm')
15
+ @app.run('rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm', [0,2])
16
+ @app.run('yum makecache')
17
+
18
+ # install new package
19
+ @app.run('yum -y install httpd')
20
+ print @app.get_output()
21
+
22
+ # get list of packages
23
+ after_packages = @app.get_packages(false)
24
+
25
+ # look for files specific to new pacakge
26
+ p sprintf('delta of before/after packages: %s', after_packages.keys() - before_packages.keys())
27
+ p sprintf('/var/www exists: %s', @app.is_dir?('/var/www'))
28
+ p sprintf('/etc/httpd/conf/httpd.conf: %s', @app.file('/etc/httpd/conf/httpd.conf'))
29
+
30
+ # look for port state changes
31
+ httpd_off_ports = @app.get_ports()
32
+
33
+ @app.run('service httpd start')
34
+ httpd_on_ports = @app.get_ports()
35
+ p sprintf('while httpd is running, is_port_active?(80): %s', @app.is_port_active?(80, 'tcp', true))
36
+ p sprintf('delta of before/after ports: %s', httpd_on_ports['tcp'].keys() - httpd_off_ports['tcp'].keys())
37
+
38
+ # look for groups/users created
39
+ p sprintf('apache group created? %s', @app.is_group?('apache'))
40
+ p sprintf('apache user created? %s', @app.is_user?('apache'))
41
+
42
+ # look at is_process_running / is_service / is_service_running
43
+ is_service = @app.is_service?('httpd')
44
+ is_service_running = @app.is_service_running?('httpd')
45
+ is_process_running = @app.is_process_running?('httpd')
46
+ p sprintf('is_service?(httpd) %s', is_service)
47
+ p sprintf('is_service_running?(httpd) %s', is_service_running)
48
+ p sprintf('is_process_running?(httpd) %s', is_process_running)
49
+
50
+ @app.run('service httpd stop')
51
+ is_service_running = @app.is_service_running?('httpd')
52
+ p sprintf('is_service_running?(httpd) %s', is_service_running)
53
+ p sprintf('when httpd is stopped, is_port_active(80): %s', @app.is_port_active?(80))
54
+
55
+ # get a conf file, modify it, send it back, restart service
56
+ tmp_filename = sprintf('/tmp/httpd.conf.%s', Time.now.to_i)
57
+
58
+ @app.get('/etc/httpd/conf/httpd.conf', tmp_filename)
59
+
60
+ ## this should be smoother..
61
+ @app._run(sprintf("sed -i 's/Listen 80/Listen 1234/' %s", tmp_filename))
62
+ @app.put(tmp_filename)
63
+ @app.run("mv #{File.basename(tmp_filename)} /etc/httpd/conf/httpd.conf") # the ssh tunnel runs under the vagrant user
64
+
65
+ @app.run('service httpd start')
66
+ is_service_running = @app.is_service_running?('httpd')
67
+ p sprintf('is_service_running?(httpd): %s', is_service_running)
68
+ p sprintf('after modification and restart, is_port_active?(1234): %s', @app.is_port_active?(1234))
69
+ p sprintf('after modification and restart, is_port_active?(80): %s', @app.is_port_active?(80))
70
+
71
+ @app._run(sprintf('rm %s', tmp_filename))