├── templates └── uchiwa.json.erb ├── Berksfile ├── .travis.yml ├── .gitignore ├── test ├── fixtures │ ├── ReadMe.md │ ├── unencrypted.json │ ├── encrypted_data_bag_secret │ └── data_bags │ │ └── uchiwa │ │ └── config.json └── integration │ ├── disabled_service │ └── serverspec │ │ └── uchiwa_spec.rb │ ├── package │ └── serverspec │ │ └── uchiwa_spec.rb │ ├── package_options_centos_http │ └── serverspec │ │ └── uchiwa_spec.rb │ ├── package_options_centos_repo │ └── serverspec │ │ └── uchiwa_spec.rb │ ├── package_options_ubuntu_http │ └── serverspec │ │ └── uchiwa_spec.rb │ ├── package_options_ubuntu_repo │ └── serverspec │ │ └── uchiwa_spec.rb │ └── helpers │ └── serverspec │ └── spec_helper.rb ├── Thorfile ├── Gemfile ├── .github ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE.md ├── .gitattributes ├── LICENSE ├── metadata.rb ├── .rubocop.yml ├── libraries └── uchiwa_helpers.rb ├── attributes └── default.rb ├── chefignore ├── recipes ├── repo.rb ├── default.rb └── http.rb ├── README.md ├── .kitchen.yml └── CHANGELOG.md /templates/uchiwa.json.erb: -------------------------------------------------------------------------------- 1 | <%= @config %> 2 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | metadata 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.0.0 4 | install: gem install foodcritic rubocop 5 | script: 6 | - foodcritic -f any . 7 | - rubocop 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | *~ 4 | *# 5 | .#* 6 | \#*# 7 | .*.sw[a-z] 8 | *.un~ 9 | /cookbooks 10 | 11 | # Bundler 12 | Gemfile.lock 13 | bin/* 14 | .bundle/* 15 | 16 | .kitchen/ 17 | .kitchen.local.yml 18 | -------------------------------------------------------------------------------- /test/fixtures/ReadMe.md: -------------------------------------------------------------------------------- 1 | Randomly generated encryption key. 2 | Created with the following command 3 | openssl rand -base64 512 -out test/fixtures/encrypted_data_bag_secret 4 | 5 | Purpose: Use encrypted data bags in kitchen tests -------------------------------------------------------------------------------- /Thorfile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'bundler' 4 | require 'bundler/setup' 5 | require 'berkshelf/thor' 6 | 7 | begin 8 | require 'kitchen/thor_tasks' 9 | Kitchen::ThorTasks.new 10 | rescue LoadError 11 | puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI'] 12 | end 13 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # This gemfile provides additional gems for testing and releasing this cookbook 2 | # It is meant to be installed on top of ChefDK which provides the majority 3 | # of the necessary gems for testing this cookbook 4 | # 5 | # Run 'chef exec bundle install' to install these dependencies 6 | 7 | source 'https://rubygems.org' 8 | 9 | gem 'stove' -------------------------------------------------------------------------------- /test/integration/disabled_service/serverspec/uchiwa_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'Installation' do 4 | it 'Has the uchiwa packaged installed' do 5 | expect(package 'uchiwa').to be_installed.with_version('0.23.1-1') 6 | end 7 | end 8 | 9 | describe 'Configuration' do 10 | it_behaves_like 'disabled service' 11 | it_behaves_like 'configuration file' 12 | end 13 | -------------------------------------------------------------------------------- /test/integration/package/serverspec/uchiwa_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'Installation' do 4 | it 'Has the uchiwa packaged installed' do 5 | expect(package 'uchiwa').to be_installed.with_version('0.23.1-1') 6 | end 7 | end 8 | 9 | describe 'Configuration' do 10 | it_behaves_like 'service' 11 | it_behaves_like 'port' 12 | it_behaves_like 'configuration file' 13 | end 14 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | [Describe what this change achieves] 4 | 5 | ### Issues Resolved 6 | 7 | [List any existing issues this PR resolves] 8 | 9 | ### Check List 10 | 11 | - [ ] All tests pass. See 12 | - [ ] New functionality includes testing. 13 | - [ ] New functionality has been documented in the README if applicable -------------------------------------------------------------------------------- /test/integration/package_options_centos_http/serverspec/uchiwa_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'Installation' do 4 | it 'Has the uchiwa packaged installed' do 5 | expect(package 'uchiwa').to be_installed 6 | end 7 | 8 | it 'Created a package log file' do 9 | expect(file '/tmp/uchiwa_pkg.log').to be_file 10 | end 11 | end 12 | 13 | describe 'Configuration' do 14 | it_behaves_like 'service' 15 | it_behaves_like 'port' 16 | it_behaves_like 'configuration file' 17 | end 18 | -------------------------------------------------------------------------------- /test/integration/package_options_centos_repo/serverspec/uchiwa_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'Installation' do 4 | it 'Has the uchiwa packaged installed' do 5 | expect(package 'uchiwa').to be_installed 6 | end 7 | 8 | it 'Created a package log file' do 9 | expect(file '/tmp/uchiwa_pkg.log').to be_file 10 | end 11 | end 12 | 13 | describe 'Configuration' do 14 | it_behaves_like 'service' 15 | it_behaves_like 'port' 16 | it_behaves_like 'configuration file' 17 | end 18 | -------------------------------------------------------------------------------- /test/integration/package_options_ubuntu_http/serverspec/uchiwa_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'Installation' do 4 | it 'Has the uchiwa packaged installed' do 5 | expect(package 'uchiwa').to be_installed 6 | end 7 | 8 | it 'Created a package log file' do 9 | expect(file '/tmp/uchiwa_pkg.log').to be_file 10 | end 11 | end 12 | 13 | describe 'Configuration' do 14 | it_behaves_like 'service' 15 | it_behaves_like 'port' 16 | it_behaves_like 'configuration file' 17 | end 18 | -------------------------------------------------------------------------------- /test/integration/package_options_ubuntu_repo/serverspec/uchiwa_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'Installation' do 4 | it 'Has the uchiwa packaged installed' do 5 | expect(package 'uchiwa').to be_installed 6 | end 7 | 8 | it 'Created a package log file' do 9 | expect(file '/tmp/uchiwa_pkg.log').to be_file 10 | end 11 | end 12 | 13 | describe 'Configuration' do 14 | it_behaves_like 'service' 15 | it_behaves_like 'port' 16 | it_behaves_like 'configuration file' 17 | end 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | #*.c text 7 | #*.h text 8 | encrypted_data_bag_secret text eol=lf 9 | 10 | # Declare files that will always have CRLF line endings on checkout. 11 | #*.sln text eol=crlf 12 | 13 | # Denote all files that are truly binary and should not be modified. 14 | #*.png binary 15 | #*.jpg binary 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Jean-Francois Theroux 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /test/fixtures/unencrypted.json: -------------------------------------------------------------------------------- 1 | { 2 | "settings": { 3 | "users": [ 4 | { 5 | "username": "kitchen_user", 6 | "password": "kitchen_password", 7 | "role": { 8 | "readonly": false 9 | } 10 | } 11 | ] 12 | }, 13 | "api": [ 14 | { 15 | "name": "sensu_kitchen1", 16 | "host": "api1.example.com", 17 | "port": 4567, 18 | "ssl": false, 19 | "timeout": 5000 20 | }, 21 | { 22 | "name": "sensu_kitchen2", 23 | "host": "api2.example.com", 24 | "port": 4567, 25 | "ssl": false, 26 | "timeout": 5000 27 | } 28 | ], 29 | "id": "config" 30 | } -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'uchiwa' 2 | maintainer 'Justin Kolberg' 3 | maintainer_email 'amd.prophet@gmail.com' 4 | license 'Apache-2.0' 5 | description 'Installs/Configures uchiwa' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '3.0.1' 8 | 9 | depends 'chef-vault', '>= 1.3.1' 10 | 11 | %w( 12 | ubuntu 13 | debian 14 | centos 15 | redhat 16 | fedora 17 | amazon 18 | ).each do |os| 19 | supports os 20 | end 21 | 22 | source_url 'https://github.com/sensu/uchiwa-chef' 23 | issues_url 'https://github.com/sensu/uchiwa-chef/issues' 24 | chef_version '>= 12.14' if respond_to?(:chef_version) 25 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # Max line length 2 | LineLength: 3 | Max: 160 4 | 5 | # Allow 1.8 hash style 6 | HashSyntax: 7 | Enabled: false 8 | 9 | # Don't require a _ to split an integer like 1000. 10 | Style/NumericLiterals: 11 | Enabled: false 12 | 13 | # Allow either fail or raise. 14 | Style/SignalException: 15 | Enabled: false 16 | 17 | # Needed for metadata.rb 18 | Style/SingleSpaceBeforeFirstArg: 19 | Enabled: false 20 | 21 | # Snakes are bad.. 22 | Style/FileName: 23 | Enabled: false 24 | 25 | # Don't require UTF8 26 | Style/Encoding: 27 | Enabled: false 28 | 29 | # Don't align else/end with if statements that come after = 30 | Lint/EndAlignment: 31 | AlignWith: variable 32 | -------------------------------------------------------------------------------- /test/fixtures/encrypted_data_bag_secret: -------------------------------------------------------------------------------- 1 | VwD9kqvyXtFeuGwP+SQ5+k5DdUyGl4+pdfhgkstbtJF9yNAW1YW18h1XZQ7Yz2Lw 2 | 7K+9gAGwXGJFnjrssgOU2RbACyrYHp5cM2t33vegj3IqBems1nrVyL10q4t4qwY3 3 | IjSgIliR2Qc7gt5rZ/YzMRf8ydXvB/Qx6Ks4DQNVa56o6sjeauI9voVYAKXbZLpG 4 | tyyDd08Qezy4yoX9XONWK8OQPzmgKTtDCGOBnpmH8C+vLp8CjsKDMey6k0Om+4a/ 5 | W4d2G4jiAI6fn5l/7TuNwylOBVUzrOdhthlVyDCvvKkms63Bki7pPLFNklZ7YFdd 6 | wC++DZ/v+n/3JOC+/RuS1oOXOI/26/bzo9aQZAy+pJkKT2/Z2eoWzH8BLWNS3E3s 7 | T0snaZISMJZmC6s3vkTVJLiIWzQFqyrozRxhrpZ6mKGBicNuq0QuKasTKmFjaWf7 8 | PROnR6QuYILvHhL37JEtcXSeYPPgKiVlLhc21Dqs2uHv0i4H+I7XuBAIOD7vzlxy 9 | 06u2LqDZzq281mkZP+vIKTs57L8M/0kF6P0HsOyTa0SM9t52h2hrROATe6anjL4i 10 | 9jLIsPPRvlTBab40w7gPKJvygLO+XPDJmC+9OPcC4QwypZ+DCimkNhOYJVTPKnCr 11 | aKjWfmxEgPD6LWvVgGpfStG5MMVRgVkXMmCF/B+LfaI= 12 | -------------------------------------------------------------------------------- /test/fixtures/data_bags/uchiwa/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "settings": { 3 | "encrypted_data": "X38NtwomNjMc0TZ69e9F3liakDtQcoQa1G9ckgG4YOkyAnPlh1KKUTSmL82i\nmgVuhodC5CkqpL9YJLQdP27cVZCtrCFQPE5FArnNvykZ7/zbdHmivu9UVHUb\nuwX5awAweVRL86trjgf2mS+zgJyZpR/h4vTcupYk6Uu8HhGxRDM=\n", 4 | "iv": "5Ls8fW9duziCa4nRbsBLgw==\n", 5 | "version": 1, 6 | "cipher": "aes-256-cbc" 7 | }, 8 | "api": { 9 | "encrypted_data": "WK9Qw2QWiUzf9mfWIRB9hDp9Mxx/dvpUqqvrF65tNyQMp7djdIAgM7ugDYv4\n5WWfNp1wYWLRXqM61sicV5/yEiHSaT+J/pvH0uD6+yQtR/PpAChoLYzabxSu\n5WrGZP1RhPjIvOH+5oYTMZMOCgXuWIpQywhbaL1Qo/Gx9VH3L06p7x3NWD7B\nxZ4yLjFzPWf2A1abgO5X39s8lv39vZhpWIt6PNiDuIYZxmyRsr+KsLwizCDv\n3rCsgm+O3z4n3oZ8AT3RY3s7WGsisu32Ab8MtA==\n", 10 | "iv": "vvy3UhWFpV4VgwLMHAwDOA==\n", 11 | "version": 1, 12 | "cipher": "aes-256-cbc" 13 | }, 14 | "id": "config" 15 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Cookbook version 2 | [Version of the cookbook where you are encountering the issue] 3 | 4 | ### Chef-client version 5 | [Version of chef-client in your environment] 6 | 7 | ### Platform Details 8 | [Operating system distribution and release version. Cloud provider if running in the cloud] 9 | 10 | ### Scenario: 11 | [What you are trying to achieve and you can't?] 12 | 13 | ### Steps to Reproduce: 14 | [If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this cookbook or any resources it includes?] 15 | 16 | ### Expected Result: 17 | [What are you expecting to happen as the consequence of above reproduction steps?] 18 | 19 | ### Actual Result: 20 | [What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.] 21 | -------------------------------------------------------------------------------- /libraries/uchiwa_helpers.rb: -------------------------------------------------------------------------------- 1 | module Uchiwa 2 | module Helpers 3 | 4 | extend ChefVaultCookbook if Kernel.const_defined?("ChefVaultCookbook") 5 | def self.data_bag_item(data_bag_name, data_bag_item, missing_ok=false) 6 | 7 | case ChefVault::Item.data_bag_item_type(data_bag_name, data_bag_item) 8 | when :normal 9 | Chef::DataBagItem.load(data_bag_name, data_bag_item) 10 | when :encrypted 11 | raw_hash = Chef::DataBagItem.load(data_bag_name, data_bag_item) 12 | secret = Chef::EncryptedDataBagItem.load_secret 13 | Chef::EncryptedDataBagItem.new(raw_hash, secret) 14 | when :vault 15 | chef_vault_item(data_bag_name, data_bag_item) 16 | end 17 | 18 | rescue Chef::Exceptions::ValidationFailed, 19 | Chef::Exceptions::InvalidDataBagPath, 20 | Chef::Exceptions::InvalidDataBagItemID, 21 | ChefVault::Exceptions::ItemNotFound, 22 | Net::HTTPServerException => error 23 | missing_ok ? nil : raise(error) 24 | end 25 | 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /test/integration/helpers/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | 5 | shared_examples_for 'service' do 6 | it 'Enables and starts the Uchiwa service' do 7 | expect(service 'uchiwa').to be_enabled 8 | expect(service 'uchiwa').to be_running.under('init') 9 | end 10 | end 11 | 12 | shared_examples_for 'disabled service' do 13 | it 'Uchiwa service is disabled and not running' do 14 | expect(service 'uchiwa').to_not be_enabled 15 | expect(service 'uchiwa').to_not be_running 16 | end 17 | end 18 | 19 | shared_examples_for 'port' do 20 | it 'Listens on port TCP/3000' do 21 | expect(port 3000).to be_listening 'tcp' 22 | end 23 | end 24 | 25 | shared_examples_for 'configuration file' do 26 | it 'Has a configuration file' do 27 | expect(file '/etc/sensu/uchiwa.json').to be_file 28 | expect(file '/etc/sensu/uchiwa.json').to be_mode '640' 29 | expect(file '/etc/sensu/uchiwa.json').to be_owned_by 'uchiwa' 30 | expect(file '/etc/sensu/uchiwa.json').to be_grouped_into 'uchiwa' 31 | end 32 | # Make sure we wrote the config files to disk 33 | describe file('/etc/sensu/uchiwa.json') do 34 | its(:content) { should contain 'name' } 35 | its(:content) { should contain 'host' } 36 | its(:content) { should contain 'port' } 37 | its(:content) { should contain 'ssl' } 38 | its(:content) { should contain 'timeout' } 39 | end 40 | 41 | 42 | end 43 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # Global 2 | default['uchiwa']['version'] = '0.23.1-1' 3 | default['uchiwa']['install_method'] = 'repo' 4 | default['uchiwa']['apt_repo_url'] = 'http://eol-repositories.sensuapp.org/apt' 5 | default['uchiwa']['yum_repo_url'] = 'http://eol-repositories.sensuapp.org' 6 | default['uchiwa']['use_unstable_repo'] = false 7 | default['uchiwa']['http_url'] = 'http://dl.bintray.com/palourde/uchiwa' 8 | default['uchiwa']['owner'] = 'uchiwa' 9 | default['uchiwa']['group'] = 'uchiwa' 10 | default['uchiwa']['sensu_homedir'] = '/etc/sensu' 11 | default['uchiwa']['add_repo'] = true 12 | default['uchiwa']['package_options'] = nil 13 | 14 | # Set to false if you want to wrap this with runit or another process monitor 15 | default['uchiwa']['manage_service'] = true 16 | 17 | # Uchiwa Settings 18 | default['uchiwa']['settings']['user'] = 'admin' 19 | default['uchiwa']['settings']['pass'] = 'supersecret' 20 | default['uchiwa']['settings']['refresh'] = 5 21 | default['uchiwa']['settings']['host'] = '0.0.0.0' 22 | default['uchiwa']['settings']['port'] = 3000 23 | 24 | # APIs Settings 25 | default['uchiwa']['api'] = [ 26 | { 27 | 'name' => 'Sensu', 28 | 'host' => '127.0.0.1', 29 | 'url' => 'http://127.0.0.1:4567', 30 | 'path' => '', 31 | 'ssl' => false, 32 | 'timeout' => 5 33 | } 34 | ] 35 | 36 | # data bag 37 | default['uchiwa']['data_bag']['name'] = 'uchiwa' 38 | default['uchiwa']['data_bag']['config_item'] = 'config' 39 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # to a chef-server or supermarket. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | examples/* 55 | Guardfile 56 | Procfile 57 | .kitchen* 58 | .rubocop.yml 59 | spec/* 60 | Rakefile 61 | .travis.yml 62 | .foodcritic 63 | .codeclimate.yml 64 | 65 | # SCM # 66 | ####### 67 | .git 68 | */.git 69 | .gitignore 70 | .gitmodules 71 | .gitconfig 72 | .gitattributes 73 | .svn 74 | */.bzr/* 75 | */.hg/* 76 | */.svn/* 77 | 78 | # Berkshelf # 79 | ############# 80 | Berksfile 81 | Berksfile.lock 82 | cookbooks/* 83 | tmp 84 | 85 | # Policyfile # 86 | ############## 87 | Policyfile.rb 88 | Policyfile.lock.json 89 | 90 | # Cookbooks # 91 | ############# 92 | CONTRIBUTING* 93 | CHANGELOG* 94 | TESTING* 95 | MAINTAINERS.toml 96 | 97 | # Strainer # 98 | ############ 99 | Colanderfile 100 | Strainerfile 101 | .colander 102 | .strainer 103 | 104 | # Vagrant # 105 | ########### 106 | .vagrant 107 | Vagrantfile 108 | -------------------------------------------------------------------------------- /recipes/repo.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: uchiwa 3 | # Recipe:: repo 4 | # 5 | # Copyright (C) 2014 Jean-Francois Theroux 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | package_options = '' 20 | 21 | platform_family = node['platform_family'] 22 | platform_version = node['platform_version'].to_i 23 | 24 | case platform_family 25 | when 'debian' 26 | package_options = '--force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew"' 27 | 28 | apt_repository 'sensu' do 29 | uri node['uchiwa']['apt_repo_url'] 30 | key "#{node['uchiwa']['apt_repo_url']}/pubkey.gpg" 31 | distribution node['lsb']['codename'] 32 | components node['uchiwa']['use_unstable_repo'] ? ['unstable'] : ['main'] 33 | only_if { node['uchiwa']['add_repo'] } 34 | end 35 | when 'rhel' 36 | package_options = '--nogpgcheck' 37 | branch = node['uchiwa']['use_unstable_repo'] ? 'yum-unstable' : 'yum' 38 | 39 | yum_repository 'uchiwa' do 40 | description 'Uchiwa repository' 41 | baseurl "#{node['uchiwa']['yum_repo_url']}/#{branch}/$releasever/$basearch/" 42 | gpgcheck false 43 | only_if { node['uchiwa']['add_repo'] } 44 | end 45 | else 46 | raise "Unsupported platform family #{platform_family}. Aborting." 47 | end 48 | 49 | package_options = node['uchiwa']['package_options'] || package_options 50 | 51 | package 'uchiwa' do 52 | options package_options 53 | version node['uchiwa']['version'] 54 | notifies :restart, 'service[uchiwa]' if node['uchiwa']['manage_service'] 55 | end 56 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: uchiwa 3 | # Recipe:: default 4 | # 5 | # Copyright (C) 2014 Jean-Francois Theroux 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | include_recipe "uchiwa::#{node['uchiwa']['install_method']}" 20 | 21 | # Generate config file 22 | settings = {} 23 | node['uchiwa']['settings'].each do |k, v| 24 | settings[k] = v 25 | end 26 | 27 | api_settings = node['uchiwa']['api'] 28 | 29 | # Retrieve the data bag config 30 | data_bag_name = node['uchiwa']['data_bag']['name'] 31 | config_item = node['uchiwa']['data_bag']['config_item'] 32 | 33 | uchiwa_config = Uchiwa::Helpers.data_bag_item(data_bag_name, config_item, true) 34 | 35 | if uchiwa_config 36 | # If any data bag settings exists, merge them with the node attribute settings 37 | if uchiwa_config['settings'] 38 | merged_settings = Chef::Mixin::DeepMerge.merge(uchiwa_config['settings'], settings.to_hash) 39 | settings = merged_settings 40 | end 41 | 42 | # If the data bag is used for api settings, override the node attributes 43 | if uchiwa_config['api'] 44 | api_settings = uchiwa_config['api'] 45 | end 46 | end 47 | 48 | config = {'uchiwa' => settings, 'sensu' => api_settings} 49 | 50 | template "#{node['uchiwa']['sensu_homedir']}/uchiwa.json" do 51 | user node['uchiwa']['owner'] 52 | group node['uchiwa']['group'] 53 | mode '0640' 54 | notifies :restart, 'service[uchiwa]' if node['uchiwa']['manage_service'] 55 | variables(:config => JSON.pretty_generate(config)) 56 | end 57 | 58 | service 'uchiwa' do 59 | action [:enable, :start] if node['uchiwa']['manage_service'] 60 | end 61 | -------------------------------------------------------------------------------- /recipes/http.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: uchiwa 3 | # Recipe:: http 4 | # 5 | # Copyright (C) 2014 Jean-Francois Theroux 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | 19 | platform_family = node['platform_family'] 20 | 21 | case platform_family 22 | when 'debian' 23 | package_options = node['uchiwa']['package_options'] || '--force-confdef --force-confnew' 24 | 25 | arch = if node['kernel']['machine'] == 'x86_64' 26 | 'amd64' 27 | else 28 | 'i386' 29 | end 30 | 31 | pkg = "uchiwa_#{node['uchiwa']['version']}_#{arch}.deb" 32 | url = "#{node['uchiwa']['http_url']}/#{pkg}" 33 | 34 | remote_file "#{Chef::Config[:file_cache_path]}/#{pkg}" do 35 | source url 36 | end 37 | 38 | dpkg_package pkg do 39 | options package_options 40 | source "#{Chef::Config[:file_cache_path]}/#{pkg}" 41 | notifies :restart, 'service[uchiwa]' if node['uchiwa']['manage_service'] 42 | end 43 | when 'rhel' 44 | package_options = node['uchiwa']['package_options'] || '--nogpgcheck' 45 | 46 | arch = if node['kernel']['machine'] == 'i686' 47 | 'i386' 48 | else 49 | node['kernel']['machine'] 50 | end 51 | 52 | pkg = "uchiwa-#{node['uchiwa']['version']}.#{arch}.rpm" 53 | url = "#{node['uchiwa']['http_url']}/#{pkg}" 54 | 55 | remote_file "#{Chef::Config[:file_cache_path]}/#{pkg}" do 56 | source url 57 | end 58 | 59 | package pkg do 60 | options package_options 61 | source "#{Chef::Config[:file_cache_path]}/#{pkg}" 62 | notifies :restart, 'service[uchiwa]' if node['uchiwa']['manage_service'] 63 | end 64 | else 65 | raise "Unsupported platform family #{node['platform_family']}. Aborting." 66 | end 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Installs and configures [Uchiwa](https://github.com/sensu/uchiwa). A simple dashboard for [Sensu](http://sensuapp.org/). This cookbook uses the omnibus packages. 2 | 3 | [![Build Status](https://travis-ci.org/sensu/uchiwa-chef.svg)](https://travis-ci.org/sensu/uchiwa-chef) 4 | [![pullreminders](https://pullreminders.com/badge.svg)](https://pullreminders.com?ref=badge) 5 | 6 | # Installation methods 7 | 8 | The cookbook supports the following installation methods: 9 | 10 | + repo (default) 11 | + http 12 | 13 | # Supported platforms 14 | 15 | These plateforms have been tested successfully. 16 | 17 | + Centos/RHEL 6 and 7 x86_64 18 | + Ubuntu 12.04 and 14.04 amd64 19 | 20 | # Contributing 21 | 22 | + Smaller commits are better if we need to cherry pick. 23 | + Make sure foodcritic runs without errors. 24 | + Make sure 'knife cookbook test' runs without errors. 25 | + Make sure 'kitchen test' runs without errors. 26 | + Make sure 'rubocop' runs without errors. 27 | + Write tests for your change. 28 | 29 | # Authors 30 | 31 | * Author: Justin Kolberg () 32 | * Author: Jean-Francois Theroux () 33 | 34 | ## Build and Release 35 | 36 | For maintainers looking to release new versions of this cookbook you should follow this process: 37 | 1. Add any `README.md` and `CHANGELOG.md` changes with links to Pull Requests. Commit this to develop branch. 38 | 1. Update `CHANGELOG.md` with new version header and update diff links. 39 | 1. Create a commit to then tag for release I would suggest something like this `git commit -am 'prep for v$MAJOR.$MINOR.$RELEASE release'`. Commit this to develop and make sure that everything is good to go (ci passing and such). 40 | 1. Push from develop to master: `git push origin develop:master` 41 | 1. checkout master branch and pull in changes: `git checkout master && git pull` 42 | 1. Create a tagged release: `hub release create v$MAJOR.$MINOR.$PATCH` this should prompt you in an editor to modify the tag message. I typically leave it default, but feel free to include any useful release notes. 43 | 1. Use the `stove` command to push the newly versioned cookbook to the supermarket: `stove --no-git`. This assumes that you have installed `stove`, properly configured authentication, and have been granted access to the supermarket. 44 | 1. Optionally but recommended to update any associated PRs with a release link. 45 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: vagrant 4 | 5 | provisioner: 6 | name: chef_zero 7 | encrypted_data_bag_secret_key_path: test/fixtures/encrypted_data_bag_secret 8 | data_bags_path: test/fixtures/data_bags 9 | attributes: 10 | uchiwa: 11 | api: [ 12 | { 13 | name: sensu1, 14 | host: api1.example.com, 15 | port: 4567, 16 | ssl: false, 17 | timeout: 5000 18 | }, 19 | { 20 | name: sensu2, 21 | host: api2.example.com, 22 | port: 4567, 23 | ssl: false, 24 | timeout: 5000 25 | } 26 | ] 27 | 28 | platforms: 29 | - name: centos-6.9 30 | - name: centos-7.3 31 | - name: ubuntu-12.04 32 | - name: ubuntu-14.04 33 | 34 | suites: 35 | - name: repo 36 | run_list: 37 | - recipe[uchiwa::default] 38 | attributes: 39 | uchiwa: 40 | install_method: repo 41 | 42 | - name: http 43 | run_list: 44 | - recipe[uchiwa::default] 45 | attributes: 46 | uchiwa: 47 | install_method: http 48 | version: 0.23.1-1 49 | 50 | - name: disabled_service 51 | excludes: 52 | - centos-7.3 53 | - ubuntu-12.04 54 | - ubuntu-14.04 55 | run_list: 56 | - recipe[uchiwa::default] 57 | attributes: 58 | uchiwa: 59 | install_method: repo 60 | manage_service: false 61 | 62 | - name: package_options_ubuntu_http 63 | excludes: 64 | - centos-6.9 65 | - centos-7.3 66 | run_list: 67 | - recipe[uchiwa::default] 68 | attributes: 69 | uchiwa: 70 | install_method: http 71 | version: 0.23.1-1 72 | package_options: --log=/tmp/uchiwa_pkg.log 73 | 74 | - name: package_options_ubuntu_repo 75 | excludes: 76 | - centos-6.9 77 | - centos-7.3 78 | run_list: 79 | - recipe[uchiwa::default] 80 | attributes: 81 | uchiwa: 82 | install_method: repo 83 | package_options: -o Dpkg::Options::="--log=/tmp/uchiwa_pkg.log" 84 | 85 | - name: package_options_centos_http 86 | excludes: 87 | - ubuntu-12.04 88 | - ubuntu-14.04 89 | run_list: 90 | - recipe[uchiwa::default] 91 | attributes: 92 | uchiwa: 93 | install_method: http 94 | version: 0.23.1-1 95 | package_options: --nogpgcheck > /tmp/uchiwa_pkg.log 96 | 97 | - name: package_options_centos_repo 98 | excludes: 99 | - ubuntu-12.04 100 | - ubuntu-14.04 101 | run_list: 102 | - recipe[uchiwa::default] 103 | attributes: 104 | uchiwa: 105 | install_method: repo 106 | package_options: --nogpgcheck > /tmp/uchiwa_pkg.log 107 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | This project adheres to [Semantic Versioning](http://semver.org/). 3 | 4 | This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md) 5 | 6 | ## [Unreleased] 7 | 8 | ## [v3.0.1] 9 | ### Fixed 10 | - rescue on `ChefVault::Exceptions::ItemNotFound` as `chef-valut` starting `v4.0.6` now returns an exception when the item is not found (@mark-wagner) 11 | 12 | ## [v3.0.0] - 2019-12-17 13 | ### Breaking Changes 14 | - upodated the `apt`, `yum`, and `msi` repo paths to use the [EOL urls](http://eol-repositories.sensuapp.org/) which was announced [here](https://blog.sensu.io/announcing-the-sensu-archives). This is only breaking if you have specific whitelisted URLs for the old repos in an `http(s)` proxy. See [#632](https://github.com/sensu/sensu-chef/pull/632) for more details. (@duncaan) 15 | 16 | ## [v2.1.0] - 2018-05-15 17 | ### Added 18 | - rescue on `Chef::Exceptions::InvalidDataBagItemID` when a data bag doesn't exist changed (@bleything) 19 | 20 | ## [v2.0.1] - 2018-05-14 21 | ### Fixed 22 | - removed `apt` recipe that is no longer needed see #65, #66 for details (@bleything) 23 | 24 | ## [v2.0.0] - 2018-04-29 25 | ### Breaking Change 26 | - now requires at least `chef-client >= 12.14` and removes the dependency on `apt` and `yum` cookbooks as they are now chef official resources (@tas50) 27 | 28 | ## [v1.5.0] - 2018-03-25 29 | ### Added 30 | - `libraries/uchiwa_helpers.rb`: Add the ability to store settings in chef-vault 31 | 32 | ## [v1.4.0] 2017-09-16 33 | ### Added 34 | - add the ability to optionally store uchiwa settings in a databag (supports encrypted data bags) 35 | 36 | ## [v1.3.0] - 2017-04-11 37 | ### Changed 38 | - Bump default Uchiwa version to 0.23.1 39 | - Use new repository layout (releasever & codename) 40 | 41 | ## [v1.2.0] 2015-11-21 42 | ### Changed 43 | - Bump default Uchiwa version to 0.12.1 44 | - Use new repository URL (repositories.sensuapp.org) 45 | 46 | ## [v1.1.0] - 2015-05-27 47 | ### Changed 48 | - Bump default Uchiwa version to 0.8.1 49 | 50 | ### Added 51 | - Allow for automatic restarts when a new version is installed 52 | 53 | ## [v1.0.0] - 2014-12-09 54 | ### Changed 55 | - Bump default Uchiwa version to 0.4.0 56 | 57 | ## [v0.7.0] - 2014-12-08 58 | ### Changed 59 | - Set default package options (apt/dpkg/yum) 60 | 61 | ### Added 62 | - Allow default package options to be overridden 63 | 64 | 65 | [Unreleased]: https://github.com/sensu/uchiwa-chef/compare/v3.0.1...HEAD 66 | [v3.0.1]: https://github.com/sensu/uchiwa-chef/compare/v3.0.0...v3.0.1 67 | [v3.0.0]: https://github.com/sensu/uchiwa-chef/compare/v2.1.0...v3.0.0 68 | [v2.1.0]: https://github.com/sensu/uchiwa-chef/compare/v2.0.1...v2.1.0 69 | [v2.0.1]: https://github.com/sensu/uchiwa-chef/compare/v2.0.0...v2.0.1 70 | [v2.0.0]: https://github.com/sensu/uchiwa-chef/compare/v1.5.0...v2.0.0 71 | [v1.5.0]: https://github.com/sensu/uchiwa-chef/compare/v1.4.0...v1.5.0 72 | [v1.4.0]: https://github.com/sensu/uchiwa-chef/compare/1.3.0...v1.4.0 73 | [v1.3.0]: https://github.com/sensu/uchiwa-chef/compare/1.2.0...1.3.0 74 | [v1.2.0]: https://github.com/sensu/uchiwa-chef/compare/1.1.0...1.2.0 75 | [v1.1.0]: https://github.com/sensu/uchiwa-chef/compare/1.0.0...1.1.0 76 | [v1.0.0]: https://github.com/sensu/uchiwa-chef/compare/0.7.0...1.0.0 77 | --------------------------------------------------------------------------------