diff --git a/.kitchen.dokken.yml b/.kitchen.dokken.yml index 0a1a707..cf89f85 100644 --- a/.kitchen.dokken.yml +++ b/.kitchen.dokken.yml @@ -72,4 +72,4 @@ platforms: - name: opensuse-leap driver: image: dokken/opensuse-leap - pid_one_command: /bin/systemd \ No newline at end of file + pid_one_command: /bin/systemd diff --git a/.kitchen.yml b/.kitchen.yml index ded8d53..deadec0 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -18,3 +18,7 @@ suites: run_list: - recipe[chef-grafana::default] attributes: + chef-grafana: + config: + security: + admin_password: "non-default" diff --git a/metadata.rb b/metadata.rb index c4b654d..67c6ffa 100644 --- a/metadata.rb +++ b/metadata.rb @@ -12,6 +12,7 @@ end depends 'apt' +depends 'dpkg_autostart' depends 'yum' source_url 'https://github.com/chef-cookbooks/chef-grafana' diff --git a/recipes/install.rb b/recipes/install.rb index 9d79392..583fecc 100644 --- a/recipes/install.rb +++ b/recipes/install.rb @@ -14,6 +14,10 @@ components ['main'] action :add end + + dpkg_autostart 'grafana-server' do + allow false + end when 'rhel' yum_repository 'grafana' do description "Grafana - #{node['chef-grafana']['install']['channel']}" @@ -32,5 +36,5 @@ end service 'grafana-server' do - action [:enable, :start] + action :enable end diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index 315eaa8..4409db0 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -24,4 +24,9 @@ it { should be_mode 644 } it { should contain '# Managed by Chef' } end + + # check if non-default admin password is set + describe command('curl -I http://localhost:3000/api/datasources -H "Authorization: Basic YWRtaW46bm9uLWRlZmF1bHQ="') do + its(:stdout) { should match '200 OK' } + end end