More adjustments
- Use the generated_by() utility function to give the ruby template a better header comment - Set special parameters after selecting the basic chef parameters.
This commit is contained in:
parent
d40f2a152a
commit
4b53ce5e10
@ -79,13 +79,6 @@ def is_installed():
|
||||
|
||||
def get_template_params(iid, chef_cfg, log):
|
||||
params = CHEF_RB_TPL_DEFAULTS.copy()
|
||||
params.update({
|
||||
'server_url': chef_cfg['server_url'],
|
||||
'node_name': util.get_cfg_option_str(chef_cfg, 'node_name', iid),
|
||||
'environment': util.get_cfg_option_str(chef_cfg, 'environment',
|
||||
'_default'),
|
||||
'validation_name': chef_cfg['validation_name'],
|
||||
})
|
||||
# Allow users to overwrite any of the keys they want (if they so choose),
|
||||
# when a value is None, then the value will be set to None and no boolean
|
||||
# or string version will be populated...
|
||||
@ -101,7 +94,17 @@ def get_template_params(iid, chef_cfg, log):
|
||||
params[k] = util.get_cfg_option_bool(chef_cfg, k)
|
||||
else:
|
||||
params[k] = util.get_cfg_option_str(chef_cfg, k)
|
||||
params['generated_on'] = datetime.now().isoformat()
|
||||
# These ones are overwritten to be exact values...
|
||||
params.update({
|
||||
'generated_by': util.make_header(),
|
||||
'server_url': util.get_cfg_option_str(chef_cfg, 'server_url'),
|
||||
'node_name': util.get_cfg_option_str(chef_cfg, 'node_name',
|
||||
default=iid),
|
||||
'environment': util.get_cfg_option_str(chef_cfg, 'environment',
|
||||
default='_default'),
|
||||
'validation_name': util.get_cfg_option_str(chef_cfg,
|
||||
'validation_name'),
|
||||
})
|
||||
return params
|
||||
|
||||
|
||||
|
@ -9,12 +9,11 @@ you need to add the following to config:
|
||||
validation_name: XYZ
|
||||
server_url: XYZ
|
||||
-#}
|
||||
|
||||
{{generated_by}}
|
||||
{#
|
||||
The reason these are not in quotes is because they are ruby
|
||||
symbols that will be placed inside here, and not actual strings...
|
||||
#}
|
||||
# This is a generated file, created on {{generated_on}}.
|
||||
{% if log_level %}
|
||||
log_level {{log_level}}
|
||||
{% endif %}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import os
|
||||
import json
|
||||
import os
|
||||
|
||||
from cloudinit.config import cc_chef
|
||||
|
||||
@ -38,6 +38,24 @@ class TestChef(t_help.FilesystemMockingTestCase):
|
||||
self.assertFalse(os.path.isdir(d))
|
||||
|
||||
def test_basic_config(self):
|
||||
# This should create a file of the format...
|
||||
"""
|
||||
# Created by cloud-init v. 0.7.6 on Sat, 11 Oct 2014 23:57:21 +0000
|
||||
log_level :info
|
||||
ssl_verify_mode :verify_none
|
||||
log_location "/var/log/chef/client.log"
|
||||
validation_client_name "bob"
|
||||
validation_key "/etc/chef/validation.pem"
|
||||
client_key "/etc/chef/client.pem"
|
||||
chef_server_url "localhost"
|
||||
environment "_default"
|
||||
node_name "iid-datasource-none"
|
||||
json_attribs "/etc/chef/firstboot.json"
|
||||
file_cache_path "/var/cache/chef"
|
||||
file_backup_path "/var/backups/chef"
|
||||
pid_file "/var/run/chef/client.pid"
|
||||
Chef::Log::Formatter.show_time = true
|
||||
"""
|
||||
tpl_file = util.load_file('templates/chef_client.rb.tmpl')
|
||||
self.patchUtils(self.tmp)
|
||||
self.patchOS(self.tmp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user