Class: Kitchen::Provisioner::Cfengine
- Inherits:
-
Base
- Object
- Base
- Kitchen::Provisioner::Cfengine
- Defined in:
- lib/kitchen/provisioner/cfengine.rb
Instance Method Summary collapse
- #cfengine_quick_install_url ⇒ Object
- #create_sandbox ⇒ Object
- #init_command ⇒ Object
- #install_busser ⇒ Object
- #install_cfengine ⇒ Object
- #install_command ⇒ Object
- #prepare_command ⇒ Object
- #prepare_files ⇒ Object
- #run_command ⇒ Object
Instance Method Details
#cfengine_quick_install_url ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 121 def cfengine_quick_install_url if config[:cfenging_type] == "community" config[:cfengine_community_quick_install_url] else config[:cfengine_enterprise_quick_install_url] end end |
#create_sandbox ⇒ Object
24 25 26 27 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 24 def create_sandbox super prepare_files end |
#init_command ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 34 def init_command cfengine_files = File.join(config[:root_path], "cfengine_files") if config[:cfengine_policy_server_address] == "" <<-INIT #{sudo("rm")} -rf #{cfengine_files} mkdir -p #{config[:root_path]} if [ ! -e "/var/cfengine/policy_server.dat" ] then 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 fi INIT else <<-INIT #{sudo("rm")} -rf #{cfengine_files} mkdir -p #{config[:root_path]} if [ ! -e "/var/cfengine/policy_server.dat" ] then #{sudo('/var/cfengine/bin/cf-agent')} --bootstrap #{config[:cfengine_policy_server_address]} fi INIT end end |
#install_busser ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 106 def install_busser <<-INSTALL # install chef omnibus so that busser works as this is needed to run tests :( # TODO: work out how to install enough ruby and set # busser: { :ruby_bindir => '/usr/bin/ruby' } so that we dont need the # whole chef client if [ ! -d "/opt/chef" ] then echo "-----> Installing Chef Omnibus to install busser to run tests" do_download #{config[:chef_omnibus_url]} /tmp/install.sh #{sudo('sh')} /tmp/install.sh fi INSTALL end |
#install_cfengine ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 95 def install_cfengine <<-INSTALL if [ ! -d "/var/cfengine" ] then echo "-----> Installing cfengine (#{config[:cfenging_type]})" do_download #{cfengine_quick_install_url} /tmp/install.sh #{sudo('bash')} /tmp/install.sh fi INSTALL end |
#install_command ⇒ Object
29 30 31 32 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 29 def install_command lines = [Kitchen::Util.shell_helpers, install_cfengine, install_busser] lines.join("\n") end |
#prepare_command ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 58 def prepare_command <<-PREP #{sudo('cp')} -rf #{config[:root_path]}/cfengine_files/* /var/cfengine #{sudo('/var/cfengine/bin/cf-agent')} -KI -f failsafe.cf sleep 5 PREP end |
#prepare_files ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 84 def prepare_files return unless config[:cfengine_files] info("Preparing cfengine files") debug("Using cfengine files from #{config[:cfengine_files]}") tmpdata_dir = File.join(sandbox_path, "cfengine_files") FileUtils.mkdir_p(tmpdata_dir) FileUtils.cp_r(Dir.glob("#{config[:cfengine_files]}/*"), tmpdata_dir) end |
#run_command ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/kitchen/provisioner/cfengine.rb', line 66 def run_command cmd = [sudo("/var/cfengine/bin/cf-agent"), config[:cf_agent_args]] cmd << "-f" << config[:run_list] if config[:run_list].length > 0 cmd = cmd.join(" ").strip if config[:cf_agent_runs].to_i > 1 cmd = <<-RUN r=1 while [ $r -le #{config[:cf_agent_runs]} ] do /bin/echo "-----> cf-agent run $r" #{cmd} r=`expr $r + 1` done RUN end return cmd end |