Module: ChefAPI::Defaults
- Defined in:
- lib/chef-api/defaults.rb
Constant Summary collapse
- ENDPOINT =
Default API endpoint
'https://api.opscode.com/'.freeze
- USER_AGENT =
Default User Agent header string
"ChefAPI Ruby Gem #{ChefAPI::VERSION}".freeze
Class Method Summary collapse
-
.client ⇒ String?
The name of the Chef API client.
-
.config ⇒ Hash
The Chef API configuration.
-
.endpoint ⇒ String
The endpoint where the Chef Server lives.
-
.flavor ⇒ true, false
The flavor of the target Chef Server.
-
.key ⇒ String?
The private key to authentication against the Chef Server.
-
.options ⇒ Hash
The list of calculated default options for the configuration.
-
.proxy_address ⇒ String?
The HTTP Proxy server address as a string.
-
.proxy_password ⇒ String?
The HTTP Proxy user password as a string.
-
.proxy_port ⇒ String?
The HTTP Proxy server port as a string.
-
.proxy_username ⇒ String?
The HTTP Proxy server username as a string.
-
.ssl_pem_file ⇒ String?
The path to a pem file on disk for use with a custom SSL verification.
-
.ssl_verify ⇒ true, false
Verify SSL requests (default: true).
-
.user_agent ⇒ String
The User Agent header to send along.
Class Method Details
.client ⇒ String?
The name of the Chef API client. This is the equivalent of client_name
in Chef terminology. In most cases, this is your Chef username.
88 89 90 |
# File 'lib/chef-api/defaults.rb', line 88 def client ENV['CHEF_API_CLIENT'] || config['CHEF_API_CLIENT'] end |
.config ⇒ Hash
The Chef API configuration
26 27 28 29 |
# File 'lib/chef-api/defaults.rb', line 26 def config path = File.(ENV['CHEF_API_CONFIG'] || '~/.chef-api') @config ||= File.exist?(path) ? JSON.parse(File.read(path)) : {} end |
.endpoint ⇒ String
The endpoint where the Chef Server lives. This is equivalent to the chef_server_url
in Chef terminology. If you are using Enterprise Hosted Chef or Enterprise Chef on premise, this endpoint should include your organization name. For example:
https://api.opscode.com/organizations/bacon
If you are running Open Source Chef Server or Chef Zero, this is the full URL to your Chef Server instance, including the server port and FQDN.
https://chef.server.local:4567/
47 48 49 |
# File 'lib/chef-api/defaults.rb', line 47 def endpoint ENV['CHEF_API_ENDPOINT'] || config['CHEF_API_ENDPOINT'] || ENDPOINT end |
.flavor ⇒ true, false
The flavor of the target Chef Server. There are two possible values:
- enterprise
- open_source
“Enterprise” covers both Hosted Chef and Enterprise Chef. “Open Source” covers both Chef Zero and Open Source Chef Server.
62 63 64 65 66 67 68 69 70 |
# File 'lib/chef-api/defaults.rb', line 62 def flavor if ENV['CHEF_API_FLAVOR'] ENV['CHEF_API_FLAVOR'].to_sym elsif config['CHEF_API_FLAVOR'] config['CHEF_API_FLAVOR'] else endpoint.include?('/organizations') ? :enterprise : :open_source end end |
.key ⇒ String?
The private key to authentication against the Chef Server. This is equivalent to the client_key
in Chef terminology. This value can be the client key in plain text or a path to the key on disk.
99 100 101 |
# File 'lib/chef-api/defaults.rb', line 99 def key ENV['CHEF_API_KEY'] || config['CHEF_API_KEY'] end |
.options ⇒ Hash
The list of calculated default options for the configuration.
18 19 20 |
# File 'lib/chef-api/defaults.rb', line 18 def Hash[Configurable.keys.map { |key| [key, send(key)] }] end |
.proxy_address ⇒ String?
The HTTP Proxy server address as a string
107 108 109 |
# File 'lib/chef-api/defaults.rb', line 107 def proxy_address ENV['CHEF_API_PROXY_ADDRESS'] || config['CHEF_API_PROXY_ADDRESS'] end |
.proxy_password ⇒ String?
The HTTP Proxy user password as a string
116 117 118 |
# File 'lib/chef-api/defaults.rb', line 116 def proxy_password ENV['CHEF_API_PROXY_PASSWORD'] || config['CHEF_API_PROXY_PASSWORD'] end |
.proxy_port ⇒ String?
The HTTP Proxy server port as a string
125 126 127 |
# File 'lib/chef-api/defaults.rb', line 125 def proxy_port ENV['CHEF_API_PROXY_PORT'] || config['CHEF_API_PROXY_PORT'] end |
.proxy_username ⇒ String?
The HTTP Proxy server username as a string
134 135 136 |
# File 'lib/chef-api/defaults.rb', line 134 def proxy_username ENV['CHEF_API_PROXY_USERNAME'] || config['CHEF_API_PROXY_USERNAME'] end |
.ssl_pem_file ⇒ String?
The path to a pem file on disk for use with a custom SSL verification
143 144 145 |
# File 'lib/chef-api/defaults.rb', line 143 def ssl_pem_file ENV['CHEF_API_SSL_PEM_FILE'] || config['CHEF_API_SSL_PEM_FILE'] end |
.ssl_verify ⇒ true, false
Verify SSL requests (default: true)
152 153 154 155 156 157 158 |
# File 'lib/chef-api/defaults.rb', line 152 def ssl_verify if ENV['CHEF_API_SSL_VERIFY'].nil? && config['CHEF_API_SSL_VERIFY'].nil? true else %w[t y].include?(ENV['CHEF_API_SSL_VERIFY'].downcase[0]) || config['CHEF_API_SSL_VERIFY'] end end |
.user_agent ⇒ String
The User Agent header to send along.
77 78 79 |
# File 'lib/chef-api/defaults.rb', line 77 def user_agent ENV['CHEF_API_USER_AGENT'] || config['CHEF_API_USER_AGENT'] || USER_AGENT end |