so i'm trying to extract some values from vault in my attributes file. And the first few lines of code are the following:
chef_gem 'vault' do
compile_time true
end
require 'vault'
Vault.address = ENV['VAULT_ADDR']
var_role_id = ENV['VAULT_ROLE_ID']
var_secret_id = ENV['VAULT_SECRET_ID']
Vault.auth.approle(var_role_id.to_s, var_secret_id.to_s)
I'm running this through a jenkins job hence the ENV variables. Anyways, I keep getting this error:
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/****_core/attributes/rabbitmq.rb
================================================================================
[172.24.9.161]
NoMethodError
-------------
undefined method `chef_gem' for #<Chef::Node::Attribute:0x000055cb839ecd58>
[172.24.9.161]
Cookbook Trace: (most recent call first)
----------------------------------------
/var/chef/cache/cookbooks/****_core/attributes/rabbitmq.rb:1:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/****_core/attributes/rabbitmq.rb:
1>> chef_gem 'vault' do
2: compile_time true
3: end
[172.24.9.161] 4:
5: require 'vault'
6:
7: Vault.address = ENV['VAULT_ADDR']
8: var_role_id = ENV['VAULT_ROLE_ID']
9: var_secret_id = ENV['VAULT_SECRET_ID']
10: Vault.auth.approle(var_role_id.to_s, var_secret_id.to_s)
[172.24.9.161] System Info:
------------
[172.24.9.161] chef_version=16.13.16
Is there something that i'm missing? My only hunch is that it's probably because i'm doing it through the attributes file rather than the recipe itself, not really sure. Help!
You can't use resources like
chef_geminside an attributes file.