Class: Kitchen::Provisioner::PuppetAgent
- Inherits:
-
Base
- Object
- Base
- Kitchen::Provisioner::PuppetAgent
- Defined in:
- lib/kitchen/provisioner/puppet_agent.rb
Overview
Puppet Agent provisioner.
Instance Attribute Summary collapse
-
#tmp_dir ⇒ Object
Returns the value of attribute tmp_dir.
Instance Method Summary collapse
- #calculate_path(path, type = :directory) ⇒ Object
- #cleanup_sandbox ⇒ Object
- #create_sandbox ⇒ Object
- #init_command ⇒ Object
-
#install_busser ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
-
#install_command ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
- #prepare_command ⇒ Object
- #run_command ⇒ Object
Instance Attribute Details
#tmp_dir ⇒ Object
Returns the value of attribute tmp_dir.
39 40 41 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 39 def tmp_dir @tmp_dir end |
Instance Method Details
#calculate_path(path, type = :directory) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 80 def calculate_path(path, type = :directory) base = config[:test_base_path] candidates = [] candidates << File.join(base, instance.suite.name, 'puppet', path) candidates << File.join(base, instance.suite.name, path) candidates << File.join(base, path) candidates << File.join(Dir.pwd, path) candidates.find do |c| type == :directory ? File.directory?(c) : File.file?(c) end end |
#cleanup_sandbox ⇒ Object
196 197 198 199 200 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 196 def cleanup_sandbox return if sandbox_path.nil? debug("Cleaning up local sandbox in #{sandbox_path}") FileUtils.rmtree(sandbox_path) end |
#create_sandbox ⇒ Object
186 187 188 189 190 191 192 193 194 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 186 def create_sandbox super debug("Creating local sandbox in #{sandbox_path}") yield if block_given? prepare_puppet_config info('Finished Preparing files for transfer') end |
#init_command ⇒ Object
183 184 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 183 def init_command end |
#install_busser ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 166 def install_busser return unless config[:require_chef_for_busser] " \#{Util.shell_helpers}\n # install chef omnibus so that busser works as this is needed to run tests :(\n # TODO: work out how to install enough ruby\n # and set busser: { :ruby_bindir => '/usr/bin/ruby' } so that we dont need the\n # whole chef client\n if [ ! -d \"/opt/chef\" ]\n then\n echo \"-----> Installing Chef Omnibus to install busser to run tests\"\n do_download \#{chef_url} /tmp/install.sh\n \#{sudo('sh')} /tmp/install.sh\n fi\n INSTALL\nend\n" |
#install_command ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 94 def install_command return unless config[:require_puppet_omnibus] || config[:require_puppet_repo] if config[:require_puppet_omnibus] info('Installing puppet using puppet omnibus') if !config[:puppet_version].nil? version = "-v #{config[:puppet_version]}" else version = '' end " \#{Util.shell_helpers}\n\n if [ ! -d \"\#{config[:puppet_omnibus_remote_path]}\" ]; then\n echo \"-----> Installing Puppet Omnibus\"\n do_download \#{config[:puppet_omnibus_url]} /tmp/puppet_install.sh\n \#{sudo('sh')} /tmp/puppet_install.sh \#{version}\n fi\n \#{install_busser}\n INSTALL\n else\n case puppet_platform\n when 'debian', 'ubuntu'\n info(\"Installing puppet on \#{puppet_platform}\")\n <<-INSTALL\n if [ ! $(which puppet) ]; then\n \#{sudo('wget')} \#{wget_proxy_parm} \#{puppet_apt_repo}\n \#{sudo('dpkg')} -i \#{puppet_apt_repo_file}\n \#{update_packages_debian_cmd}\n \#{sudo('apt-get')} -y install puppet-common\#{puppet_debian_version}\n \#{sudo('apt-get')} -y install puppet\#{puppet_debian_version}\n fi\n \#{install_busser}\n INSTALL\n when 'redhat', 'centos', 'fedora', 'oracle', 'amazon'\n info(\"Installing puppet on \#{puppet_platform}\")\n <<-INSTALL\n if [ ! $(which puppet) ]; then\n \#{sudo('rpm')} -ivh \#{proxy_parm} \#{puppet_yum_repo}\n \#{update_packages_redhat_cmd}\n \#{sudo('yum')} -y install puppet\#{puppet_redhat_version}\n fi\n \#{install_busser}\n INSTALL\n else\n info('Installing puppet, will try to determine platform os')\n <<-INSTALL\n if [ ! $(which puppet) ]; then\n if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ]; then\n \#{sudo('rpm')} -ivh \#{proxy_parm} \#{puppet_yum_repo}\n \#{update_packages_redhat_cmd}\n \#{sudo('yum')} -y install puppet\#{puppet_redhat_version}\n else\n if [ -f /etc/system-release ] || grep -q 'Amazon Linux' /etc/system-release; then\n \#{sudo('rpm')} -ivh \#{proxy_parm} \#{puppet_yum_repo}\n \#{update_packages_redhat_cmd}\n \#{sudo('yum')} -y install puppet\#{puppet_redhat_version}\n else\n \#{sudo('wget')} \#{wget_proxy_parm} \#{puppet_apt_repo}\n \#{sudo('dpkg')} -i \#{puppet_apt_repo_file}\n \#{update_packages_debian_cmd}\n \#{sudo('apt-get')} -y install puppet-common\#{puppet_debian_version}\n \#{sudo('apt-get')} -y install puppet\#{puppet_debian_version}\n fi\n fi\n fi\n \#{install_busser}\n INSTALL\n end\n end\nend\n" |
#prepare_command ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 202 def prepare_command commands = [] if puppet_config commands << [ sudo('cp'), File.join(config[:root_path], 'puppet.conf'), '/etc/puppet' ].join(' ') end command = commands.join(' && ') debug(command) command end |
#run_command ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/kitchen/provisioner/puppet_agent.rb', line 218 def run_command if !config[:puppet_agent_command].nil? return config[:puppet_agent_command] else [ custom_facts, sudo_env('puppet'), 'agent', puppet_server_flag, "--waitforcert=#{config[:puppet_waitforcert]}", puppet_masterport_flag, puppet_certname_flag, puppet_digest_flag, puppet_detailed_exitcodes_flag, puppet_logdest_flag, puppet_test_flag, puppet_onetime_flag, puppet_no_daemonize_flag, puppet_noop_flag, puppet_verbose_flag, puppet_debug_flag ].join(' ') end end |