kitchen-cfengine 0.0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8149bc22bc0be99cbb713e35401d637128877ec1
4
+ data.tar.gz: 3aebf9e9e509b98ce0bc14065f3a788cd4c50e70
5
+ SHA512:
6
+ metadata.gz: 0126cf2c446b813bb259787f2c37718b8ef09f9079b84fe274b48ec3e4156ea6032dd110c1f07663c07963db9fde704802c27a460941ab35efc930e4f2f34155
7
+ data.tar.gz: 22cf52e48a225ef4b7b22f01338e52627c21526335bc364d6e8dd8a695eb9e481526a2613dc42b52187571f5ec92a5a5b644749cca47b91ddaecd86e525792ad
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .kitchen/
16
+ .kitchen.local.yml
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ kitchen-cfengine
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.5
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kitchen-cfengine.gemspec
4
+ gemspec
5
+
6
+ gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant.git', :tag => 'v1.6.5', :group => [:development, :test]
7
+ gem 'test-kitchen', :group => [:development, :test]
8
+ gem 'kitchen-vagrant', :group => [:development, :test]
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Nathan Mische
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Kitchen::Provisioner::Cfengine
2
+
3
+ A [CFEngine](http://cfengine.com/) provisioner for [Test Kitchen](http://kitchen.ci/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'kitchen-cfengine'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install kitchen-cfengine
20
+
21
+
22
+ ## Provisioner Configuration
23
+
24
+ The following attributes may be set at the provisioner level:
25
+
26
+ * `name` - cfengine
27
+ * `cfenging_type` - either `community` or `enterprise`, defaults to `community`
28
+ * `cfengine_community_quick_install_url` - url for the cfengine-community quick install script, defaults to `http://s3.amazonaws.com/cfengine.packages/quick-install-cfengine-community.sh`
29
+ * `cfengine_enterprise_quick_install_url` - url for the cfengine-enterprise quick install script, defaults to `http://s3.amazonaws.com/cfengine.packages/quick-install-cfengine-enterprise.sh`
30
+ * `chef_omnibus_url` - url for chef omnibus install, defaults to `https://www.getchef.com/chef/install.sh`
31
+ * `cfengine_policy_server_address` - optional IP address or hostname for policy server, if no address is provided the VM is bootstrapped to itself
32
+ * `cf_agent_args` - arguments to pass to cf-agent on provisioning, defaults to `-KI`
33
+ * `cf_agent_runs` - number of times to run cf-agent, useful if multiple runs are needed for full convergence, defaults to `1`
34
+ * `cfengine_files` - specifies a directory that will be copied into `/var/cfengine/` on the VM, defaults to `test/cfengine_files`
35
+
36
+ Additionally you may set the `run_list` attribute at the suite level to run a specific policy file.
37
+
38
+ ## Example Usage
39
+
40
+ Below is a sample `.kitchen.yaml` file that will install CFEngine Enterprise on CentOS 6.5, bootstrap it to the remote policy hub `192.168.33.33`, then run the `my_test.cf` policy file with the `-KI -D testrun` arguments:
41
+
42
+ ```
43
+ ---
44
+ driver:
45
+ name: vagrant
46
+
47
+ provisioner:
48
+ name: cfengine
49
+ cfenging_type: enterprise
50
+ cfengine_policy_server_address: 192.168.33.33
51
+ cf_agent_args: -KI -D testrun
52
+
53
+ platforms:
54
+ - name: centos-6.5
55
+ driver:
56
+ box: chef/centos-6.5
57
+
58
+ suites:
59
+ - name: default
60
+ run_list:
61
+ - my_test_.cf
62
+
63
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kitchen/provisioner/cfengine_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kitchen-cfengine"
8
+ spec.version = Kitchen::Provisioner::CFENGINE_VERSION
9
+ spec.authors = ["Nathan Mische"]
10
+ spec.email = ["nmische@gmail.com"]
11
+ spec.summary = "A CFEngine Provisioner for Test Kitchen."
12
+ spec.description = "Kitchen::Provisioner::Cfengine - A CFEngine Provisioner for Test Kitchen."
13
+ spec.homepage = "https://github.com/nmische/kitchen-cfengine"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = []
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "test-kitchen", "~> 1.2.1"
24
+ spec.add_development_dependency "kitchen-vagrant", "~> 0.15.0"
25
+ spec.add_development_dependency "vagrant", "~> 1.6.5"
26
+
27
+ end
@@ -0,0 +1,126 @@
1
+ require "kitchen"
2
+ require "kitchen/util"
3
+ require "kitchen/provisioner/base"
4
+ require "kitchen/provisioner/cfengine_version"
5
+
6
+ module Kitchen
7
+ module Provisioner
8
+
9
+ class Cfengine < Base
10
+
11
+ default_config :cfenging_type, "community"
12
+ default_config :cfengine_community_quick_install_url, "http://s3.amazonaws.com/cfengine.packages/quick-install-cfengine-community.sh"
13
+ default_config :cfengine_enterprise_quick_install_url, "http://s3.amazonaws.com/cfengine.packages/quick-install-cfengine-enterprise.sh"
14
+ default_config :chef_omnibus_url, "https://www.getchef.com/chef/install.sh"
15
+ default_config :cfengine_policy_server_address, ""
16
+ default_config :cf_agent_args, "-KI"
17
+ default_config :cf_agent_runs, "1"
18
+ default_config :run_list, []
19
+ default_config :cfengine_files do |provisioner|
20
+ provisioner.calculate_path("test/cfengine_files")
21
+ end
22
+ expand_path_for :cfengine_files
23
+
24
+ def create_sandbox
25
+ super
26
+ prepare_files
27
+ end
28
+
29
+ def install_command
30
+ lines = [Kitchen::Util.shell_helpers, install_cfengine, install_busser]
31
+ lines.join("\n")
32
+ end
33
+
34
+ def init_command
35
+ if config[:cfengine_policy_server_address] == ""
36
+ <<-INIT
37
+ if [ ! -e "/var/cfengine/policy_server.dat" ]
38
+ then
39
+ LANG=en /sbin/ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1 }' | head -n 1 | xargs #{sudo('/var/cfengine/bin/cf-agent')} --bootstrap
40
+ fi
41
+ INIT
42
+ else
43
+ <<-INIT
44
+ if [ ! -e "/var/cfengine/policy_server.dat" ]
45
+ then
46
+ #{sudo('/var/cfengine/bin/cf-agent')} --bootstrap #{config[:cfengine_policy_server_address]}
47
+ fi
48
+ INIT
49
+ end
50
+ end
51
+
52
+ def prepare_command
53
+ <<-PREP
54
+ #{sudo('cp')} -rf #{config[:root_path]}/* /var/cfengine
55
+ #{sudo('/var/cfengine/bin/cf-agent')} -KI -f failsafe.cf
56
+ sleep 5
57
+ PREP
58
+ end
59
+
60
+ def run_command
61
+ cmd = [sudo("/var/cfengine/bin/cf-agent"), config[:cf_agent_args]]
62
+ cmd << "-f" << config[:run_list] if config[:run_list].length > 0
63
+ cmd = cmd.join(" ").strip
64
+ if config[:cf_agent_runs].to_i > 1
65
+ cmd = <<-RUN
66
+ r=1
67
+ while [ $r -le #{config[:cf_agent_runs]} ]
68
+ do
69
+ /bin/echo "-----> cf-agent run $r"
70
+ #{cmd}
71
+ r=`expr $r + 1`
72
+ done
73
+ RUN
74
+ end
75
+ return cmd
76
+ end
77
+
78
+ def prepare_files
79
+ return unless config[:cfengine_files]
80
+
81
+ info("Preparing cfengine files")
82
+ debug("Using cfengine files from #{config[:cfengine_files]}")
83
+
84
+ tmpdata_dir = File.join(sandbox_path, "cfengine_files")
85
+ FileUtils.mkdir_p(tmpdata_dir)
86
+ FileUtils.cp_r(Dir.glob("#{config[:cfengine_files]}/*"), tmpdata_dir)
87
+ end
88
+
89
+ def install_cfengine
90
+ <<-INSTALL
91
+ if [ ! -d "/var/cfengine" ]
92
+ then
93
+ echo "-----> Installing cfengine (#{config[:cfenging_type]})"
94
+ do_download #{cfengine_quick_install_url} /tmp/install.sh
95
+ #{sudo('sh')} /tmp/install.sh
96
+ fi
97
+ INSTALL
98
+ end
99
+
100
+ def install_busser
101
+ <<-INSTALL
102
+ # install chef omnibus so that busser works as this is needed to run tests :(
103
+ # TODO: work out how to install enough ruby and set
104
+ # busser: { :ruby_bindir => '/usr/bin/ruby' } so that we dont need the
105
+ # whole chef client
106
+ if [ ! -d "/opt/chef" ]
107
+ then
108
+ echo "-----> Installing Chef Omnibus to install busser to run tests"
109
+ do_download #{config[:chef_omnibus_url]} /tmp/install.sh
110
+ #{sudo('sh')} /tmp/install.sh
111
+ fi
112
+ INSTALL
113
+ end
114
+
115
+ def cfengine_quick_install_url
116
+ if config[:cfenging_type] == "community"
117
+ config[:cfengine_community_quick_install_url]
118
+ else
119
+ config[:cfengine_enterprise_quick_install_url]
120
+ end
121
+ end
122
+
123
+ end
124
+
125
+ end
126
+ end
@@ -0,0 +1,5 @@
1
+ module Kitchen
2
+ module Provisioner
3
+ CFENGINE_VERSION = "0.0.3"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitchen-cfengine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Mische
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.9
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-kitchen
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: kitchen-vagrant
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.15.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.15.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: vagrant
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.6.5
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.6.5
83
+ description: Kitchen::Provisioner::Cfengine - A CFEngine Provisioner for Test Kitchen.
84
+ email:
85
+ - nmische@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".ruby-gemset"
92
+ - ".ruby-version"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - kitchen-cfengine.gemspec
98
+ - lib/kitchen/provisioner/cfengine.rb
99
+ - lib/kitchen/provisioner/cfengine_version.rb
100
+ homepage: https://github.com/nmische/kitchen-cfengine
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.4.3
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: A CFEngine Provisioner for Test Kitchen.
124
+ test_files: []