Class: Kitchen::Provisioner::Chef::Policyfile
- Inherits:
-
Object
- Object
- Kitchen::Provisioner::Chef::Policyfile
- Defined in:
- lib/kitchen/provisioner/chef/policyfile.rb
Overview
Chef cookbook resolver that uses Policyfiles to calculate dependencies.
Class Method Summary collapse
-
.load!(logger: Kitchen.logger) ⇒ Object
Loads the library code required to use the resolver.
Instance Method Summary collapse
-
#compile ⇒ Object
Runs ‘chef install` to determine the correct cookbook set and generate the policyfile lock.
-
#initialize(policyfile, path, license: nil, logger: Kitchen.logger, always_update: false, policy_group: nil) ⇒ Policyfile
constructor
Creates a new cookbook resolver.
-
#lockfile ⇒ String
Return the path to the lockfile corresponding to this policyfile.
-
#resolve ⇒ Object
Performs the cookbook resolution and vendors the resulting cookbooks in the desired path.
Methods included from ShellOut
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(policyfile, path, license: nil, logger: Kitchen.logger, always_update: false, policy_group: nil) ⇒ Policyfile
Creates a new cookbook resolver.
44 45 46 47 48 49 50 51 |
# File 'lib/kitchen/provisioner/chef/policyfile.rb', line 44 def initialize(policyfile, path, license: nil, logger: Kitchen.logger, always_update: false, policy_group: nil) @policyfile = policyfile @path = path @logger = logger @always_update = always_update @policy_group = policy_group @license = license end |
Class Method Details
Instance Method Details
#compile ⇒ Object
Runs ‘chef install` to determine the correct cookbook set and generate the policyfile lock.
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/kitchen/provisioner/chef/policyfile.rb', line 75 def compile if File.exist?(lockfile) info("Installing cookbooks for Policyfile #{policyfile} using `#{cli_path} install`") else info("Policy lock file doesn't exist, running `#{cli_path} install` for Policyfile #{policyfile}...") end run_command("#{cli_path} install #{escape_path(policyfile)} --chef-license #{license}") if always_update info("Updating policy lock using `#{cli_path} update`") run_command("#{cli_path} update #{escape_path(policyfile)} --chef-license #{license}") end end |
#lockfile ⇒ String
Return the path to the lockfile corresponding to this policyfile.
92 93 94 |
# File 'lib/kitchen/provisioner/chef/policyfile.rb', line 92 def lockfile policyfile.gsub(/\.rb\Z/, ".lock.json") end |
#resolve ⇒ Object
Performs the cookbook resolution and vendors the resulting cookbooks in the desired path.
63 64 65 66 67 68 69 70 71 |
# File 'lib/kitchen/provisioner/chef/policyfile.rb', line 63 def resolve if policy_group info("Exporting cookbook dependencies from Policyfile #{path} with policy_group #{policy_group} using `#{cli_path} export`...") run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --policy_group #{policy_group} --force --chef-license #{license}") else info("Exporting cookbook dependencies from Policyfile #{path} using `#{cli_path} export`...") run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --force --chef-license #{license}") end end |