summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBipin Bachhao <bipinbachhao@gmail.com>2020-05-27 18:49:38 -0400
committerGitHub <noreply@github.com>2020-05-27 18:49:38 -0400
commit0919bd46bbd1b12158c369569ec1298bb000dd8a (patch)
tree99a19ed0e42070678aabbed65ab2bf39cab81188
parenta99c8bcea597c17d83d90bf1e09c9a5b68c3dc22 (diff)
downloadvyos-cloud-init-0919bd46bbd1b12158c369569ec1298bb000dd8a.tar.gz
vyos-cloud-init-0919bd46bbd1b12158c369569ec1298bb000dd8a.zip
Enable chef_license support for chef infra client (#389)
Co-authored-by: Daniel Watkins <oddbloke@ubuntu.com>
-rw-r--r--cloudinit/config/cc_chef.py2
-rw-r--r--doc/examples/cloud-config-chef.txt3
-rw-r--r--templates/chef_client.rb.tmpl3
-rw-r--r--tests/unittests/test_handler/test_handler_chef.py2
4 files changed, 10 insertions, 0 deletions
diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py
index 01d61fa1..03285ef0 100644
--- a/cloudinit/config/cc_chef.py
+++ b/cloudinit/config/cc_chef.py
@@ -50,6 +50,7 @@ file).
written to /etc/chef/client.rb)
chef:
+ chef_license:
client_key:
encrypted_data_bag_secret:
environment:
@@ -125,6 +126,7 @@ CHEF_RB_TPL_PATH_KEYS = frozenset([
'file_cache_path',
'pid_file',
'encrypted_data_bag_secret',
+ 'chef_license',
])
CHEF_RB_TPL_KEYS = list(CHEF_RB_TPL_DEFAULTS.keys())
CHEF_RB_TPL_KEYS.extend(CHEF_RB_TPL_BOOL_KEYS)
diff --git a/doc/examples/cloud-config-chef.txt b/doc/examples/cloud-config-chef.txt
index 39957e58..bb4b058c 100644
--- a/doc/examples/cloud-config-chef.txt
+++ b/doc/examples/cloud-config-chef.txt
@@ -52,6 +52,9 @@ apt:
chef:
+ # Valid values are 'accept' and 'accept-no-persist'
+ chef_license: "accept"
+
# Valid values are 'gems' and 'packages' and 'omnibus'
install_type: "packages"
diff --git a/templates/chef_client.rb.tmpl b/templates/chef_client.rb.tmpl
index 99978d3b..0a759b04 100644
--- a/templates/chef_client.rb.tmpl
+++ b/templates/chef_client.rb.tmpl
@@ -14,6 +14,9 @@ you need to add the following to config:
The reason these are not in quotes is because they are ruby
symbols that will be placed inside here, and not actual strings...
#}
+{% if chef_license %}
+chef_license "{{chef_license}}"
+{% endif%}
{% if log_level %}
log_level {{log_level}}
{% endif %}
diff --git a/tests/unittests/test_handler/test_handler_chef.py b/tests/unittests/test_handler/test_handler_chef.py
index 513c18b5..8c476418 100644
--- a/tests/unittests/test_handler/test_handler_chef.py
+++ b/tests/unittests/test_handler/test_handler_chef.py
@@ -130,6 +130,7 @@ class TestChef(FilesystemMockingTestCase):
# 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
+ chef_license "accept"
log_level :info
ssl_verify_mode :verify_none
log_location "/var/log/chef/client.log"
@@ -153,6 +154,7 @@ class TestChef(FilesystemMockingTestCase):
util.write_file('/etc/cloud/templates/chef_client.rb.tmpl', tpl_file)
cfg = {
'chef': {
+ 'chef_license': "accept",
'server_url': 'localhost',
'validation_name': 'bob',
'validation_key': "/etc/chef/vkey.pem",