From 38211c83410f610aa889a687fdecebb3fed53f02 Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Wed, 24 Jan 2018 17:59:53 +0200 Subject: ES OOM alignment Change-Id: I986fc13f8e32a103e3868f4da9ffb41631c70201 Issue-ID: SDC-912 Signed-off-by: Tal Gitelman --- sdc-os-chef/pom.xml | 22 +- sdc-os-chef/scripts/docker_run.sh | 11 +- .../recipes/ES_1_setup_elasticsearch.rb | 3 +- .../recipes/ES_3_create_audit_template.rb | 245 ------- .../recipes/ES_4_create_resources_template.rb | 37 -- .../recipes/ES_5_create_monitoring_template.rb | 53 -- .../ES_6_create_kibana_dashboard_virtualization.rb | 49 -- sdc-os-chef/sdc-elasticsearch/startup.sh | 15 +- sdc-os-chef/sdc-init-elasticsearch/Dockerfile | 11 + sdc-os-chef/sdc-init-elasticsearch/chef-install.sh | 707 +++++++++++++++++++++ .../init-sdc-elasticsearch/attributes/default.rb | 1 + .../files/default/dashboard_BI-Dashboard.json | 13 + .../default/dashboard_Monitoring-Dashboared.json | 15 + .../files/default/visualization_JVM-used-CPU.json | 10 + .../default/visualization_JVM-used-Memory.json | 10 + .../visualization_JVM-used-Threads-Num.json | 10 + ...ied-services-ampersand-resources-(per-day).json | 10 + ...ed-Resources-slash-Services-slash-Products.json | 10 + ...isualization_Show-all-distributed-services.json | 10 + .../files/default/visualization_host-used-CPU.json | 10 + .../visualization_host-used-Threads-Num.json | 10 + .../visualization_number-of-user-accesses.json | 10 + .../recipes/ES_1_create_audit_template.rb | 245 +++++++ .../recipes/ES_2_create_resources_template.rb | 37 ++ .../recipes/ES_3_create_monitoring_template.rb | 53 ++ .../ES_4_create_kibana_dashboard_virtualization.rb | 49 ++ .../sdc-init-elasticsearch/chef-solo/LICENSE | 201 ++++++ .../sdc-init-elasticsearch/chef-solo/README.md | 37 ++ .../sdc-init-elasticsearch/chef-solo/chefignore | 11 + .../chef-solo/cookbooks/README.md | 54 ++ .../chef-solo/data_bags/README.md | 63 ++ .../chef-solo/environments/README.md | 5 + .../chef-solo/roles/README.md | 16 + .../chef-solo/roles/init-elasticsearch.json | 21 + .../sdc-init-elasticsearch/chef-solo/solo.json | 4 + .../sdc-init-elasticsearch/chef-solo/solo.rb | 16 + sdc-os-chef/sdc-init-elasticsearch/startup.sh | 7 + sdc-os-chef/sdc-sanity/startup.sh | 17 +- 38 files changed, 1687 insertions(+), 421 deletions(-) delete mode 100644 sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_3_create_audit_template.rb delete mode 100644 sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_4_create_resources_template.rb delete mode 100644 sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_5_create_monitoring_template.rb delete mode 100644 sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_6_create_kibana_dashboard_virtualization.rb create mode 100644 sdc-os-chef/sdc-init-elasticsearch/Dockerfile create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-install.sh create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/attributes/default.rb create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/dashboard_BI-Dashboard.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/dashboard_Monitoring-Dashboared.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-CPU.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-Memory.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-Threads-Num.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-certified-services-ampersand-resources-(per-day).json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-created-Resources-slash-Services-slash-Products.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-distributed-services.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_host-used-CPU.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_host-used-Threads-Num.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_number-of-user-accesses.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_1_create_audit_template.rb create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_2_create_resources_template.rb create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_4_create_kibana_dashboard_virtualization.rb create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/LICENSE create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/README.md create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/chefignore create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/cookbooks/README.md create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/data_bags/README.md create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/environments/README.md create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/roles/README.md create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/roles/init-elasticsearch.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/solo.json create mode 100644 sdc-os-chef/sdc-init-elasticsearch/chef-solo/solo.rb create mode 100644 sdc-os-chef/sdc-init-elasticsearch/startup.sh diff --git a/sdc-os-chef/pom.xml b/sdc-os-chef/pom.xml index f27a9434fa..542a58ea7f 100644 --- a/sdc-os-chef/pom.xml +++ b/sdc-os-chef/pom.xml @@ -392,7 +392,22 @@ - + + + + onap/sdc-init-elasticsearch + sdc-init-elasticsearch + + try + ${project.basedir}/sdc-init-elasticsearch + + ${docker.tag} + ${docker.latest.tag} + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + + onap/sdc-elasticsearch @@ -464,7 +479,7 @@ true - onap/sdc-backend,onap/sdc-frontend,onap/sdc-elasticsearch,onap/sdc-kibana,onap/sdc-cassandra,onap/sdc-sanity + onap/sdc-backend,onap/sdc-frontend,onap/sdc-init-elasticsearch,onap/sdc-elasticsearch,onap/sdc-kibana,onap/sdc-cassandra,onap/sdc-sanity @@ -483,8 +498,7 @@ push - - onap/sdc-backend,onap/sdc-frontend,onap/sdc-elasticsearch,onap/sdc-kibana,onap/sdc-cassandra,onap/sdc-sanity + onap/sdc-backend,onap/sdc-frontend,onap/sdc-init-elasticsearch,onap/sdc-elasticsearch,onap/sdc-kibana,onap/sdc-cassandra,onap/sdc-sanity diff --git a/sdc-os-chef/scripts/docker_run.sh b/sdc-os-chef/scripts/docker_run.sh index 818181d9c5..2a8591cdfa 100755 --- a/sdc-os-chef/scripts/docker_run.sh +++ b/sdc-os-chef/scripts/docker_run.sh @@ -140,10 +140,17 @@ if [ ${LOCAL} = false ]; then echo "pulling code" docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE} fi -docker run --detach --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 750m -e ES_JAVA_OPTS="-Xms512m -Xmx512m" --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro -e ES_HEAP_SIZE=1024M --volume ${WORKSPACE}/data/ES:/usr/share/elasticsearch/data --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ${PREFIX}/sdc-elasticsearch:${RELEASE} +docker run --detach --name sdc-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 750m --env ES_JAVA_OPTS="-Xms512m -Xmx512m" --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --env ES_HEAP_SIZE=1024M --volume ${WORKSPACE}/data/ES:/usr/share/elasticsearch/data --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ${PREFIX}/sdc-elasticsearch:${RELEASE} +# Init-Elastic-Search +echo "docker run sdc-init-elasticsearch..." +if [ ${LOCAL} = false ]; then + echo "pulling code" + docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE} +fi +docker run --detach --name sdc-init-es --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --memory 750m --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-init-elasticsearch:${RELEASE} -# cassandra +# Cassandra echo "docker run sdc-cassandra..." if [ ${LOCAL} = false ]; then docker pull ${PREFIX}/sdc-cassandra:${RELEASE} diff --git a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_1_setup_elasticsearch.rb b/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_1_setup_elasticsearch.rb index 854898c1b7..b93ca7310b 100644 --- a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_1_setup_elasticsearch.rb +++ b/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_1_setup_elasticsearch.rb @@ -1,5 +1,4 @@ clusterName = node['elasticsearch'][:cluster_name]+node.chef_environment -node_name = node[:hostname] template "/usr/share/elasticsearch/config/elasticsearch.yml" do source "ES-elasticsearch.yml.erb" @@ -8,7 +7,7 @@ template "/usr/share/elasticsearch/config/elasticsearch.yml" do mode "0755" variables({ :cluster_name => "#{clusterName}", - :node_name => node_name, + :node_name => node[:hostname], :ES_IP => node['Nodes']['ES'], :num_of_shards => node['elasticsearch'][:num_of_shards], :num_of_replicas => node['elasticsearch'][:num_of_replicas] diff --git a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_3_create_audit_template.rb b/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_3_create_audit_template.rb deleted file mode 100644 index 4e8136c626..0000000000 --- a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_3_create_audit_template.rb +++ /dev/null @@ -1,245 +0,0 @@ -ruby_block "check_ElasticSearch_Cluster_Health" do - block do - #tricky way to load this Chef::Mixin::ShellOut utilities - Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) - #curl_command = "http://#{node['ipaddress']}:9200/_cluster/health?pretty=true" - curl_command = "http://localhost:9200/_cluster/health?pretty=true" - resp = Net::HTTP.get_response URI.parse(curl_command) - stat = JSON.parse(resp.read_body)['status'] - - case stat - when "green" - printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.") - when "yellow" - printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...") - when "red" - printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!") - end - end - retries 10 - retry_delay 2 -end - - -bash "create audit mapping" do - code <<-EOH - curl -i -X PUT -d '{ "order": 1, "template": "auditingevents-*", "settings": {}, "mappings": - { - "distributiondownloadevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "RESOURCE_URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } - }, - "_all": { "enabled": true } - }, - "auditinggetuebclusterevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } - }, - "_all": { "enabled": true } - }, - "distributionstatusevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "RESOURCE_URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } - }, - "_all": { "enabled": true } - }, - "distributionengineevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ROLE": { "include_in_all": true, "type": "string" }, - "API_KEY": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "D_ENV": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } - }, - "_all": { "enabled": true } - }, - "useraccessevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "USER": { "include_in_all": true, "type": "string" } - }, - "_all": { "enabled": true } - }, - "resourceadminevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "INVARIANT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CURR_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "MODIFIER": { "include_in_all": true, "type": "string" }, - "PREV_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "PREV_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "RESOURCE_NAME": { "include_in_all": true, "type": "string" }, - "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DPREV_STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DCURR_STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TOSCA_NODE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "COMMENT": { "include_in_all": true, "type": "string" }, - "ARTIFACT_DATA": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "PREV_ARTIFACT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CURR_ARTIFACT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } - }, - "_all": { "enabled": true } - }, - "useradminevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "USER_AFTER": { "include_in_all": true, "type": "string" }, - "USER_BEFORE": { "include_in_all": true, "type": "string" }, - "MODIFIER": { "include_in_all": true, "type": "string" } - }, - "_all": { "enabled": true } - }, - "distributionnotificationevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CURR_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "MODIFIER": { "include_in_all": true, "type": "string" }, - "RESOURCE_NAME": { "include_in_all": true, "type": "string" }, - "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" } - }, - "_all": { "enabled": true } - }, - "categoryevent": { - "properties": { - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "MODIFIER": { "include_in_all": true, "type": "string" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CATEGORY_NAME": { "include_in_all": true, "type": "string" }, - "SUB_CATEGORY_NAME": { "include_in_all": true, "type": "string" }, - "GROUPING_NAME": { "include_in_all": true, "type": "string" }, - "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } - }, - "_all": { "enabled": true } - }, - "authevent": { - "properties": { - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, - "DESC": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "USER": { "include_in_all": true, "type": "string" }, - "AUTH_STATUS": { "include_in_all": true, "index": "not_analyzed","type": "string" } , - "REALM": { "include_in_all": true, "index": "not_analyzed","type": "string" } - }, - "_all": { "enabled": true } - }, - "consumerevent": { - "properties": { - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "MODIFIER": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "ECOMP_USER": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } - }, - "_all": { "enabled": true } - }, - "getuserslistevent": { - "properties": { - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "MODIFIER": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DETAILS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } - }, - "_all": { "enabled": true } - }, - "getcategoryhierarchyevent": { - "properties": { - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "MODIFIER": { "include_in_all": true, "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DETAILS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } - }, - "_all": { "enabled": true } - }, - "distributiondeployevent": { - "properties": { - "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "DESC": { "include_in_all": true, "type": "string" }, - "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "MODIFIER": { "include_in_all": true, "type": "string" }, - "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "RESOURCE_NAME": { "include_in_all": true, "type": "string" }, - "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } - }, - "_all": { "enabled": true } } - }, - "aliases": { "last_3_months": {}}}' http://localhost:9200/_template/audit_template - EOH -end - -bash "set default index for Kibana" do - code <<-EOH - curl -XPUT http://localhost:9200/.kibana/index-pattern/auditingevents-* -d '{"title" : "events-*", "timeFieldName": "TIMESTAMP"}' - curl -XPUT http://localhost:9200/.kibana/config/4.3.3 -d '{"defaultIndex" : "auditingevents-*"}' - EOH -end diff --git a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_4_create_resources_template.rb b/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_4_create_resources_template.rb deleted file mode 100644 index 4dc264153d..0000000000 --- a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_4_create_resources_template.rb +++ /dev/null @@ -1,37 +0,0 @@ -ruby_block "check_ElasticSearch_Cluster_Health" do - block do - #tricky way to load this Chef::Mixin::ShellOut utilities - Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) - #curl_command = "http://#{node['ipaddress']}:9200/_cluster/health?pretty=true" - curl_command = "http://localhost:9200/_cluster/health?pretty=true" - resp = Net::HTTP.get_response URI.parse(curl_command) - stat = JSON.parse(resp.read_body)['status'] - - case stat - when "green" - printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.") - when "yellow" - printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...") - when "red" - printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!") - end - end - retries 10 - retry_delay 2 -end - -bash "create resources mapping" do - code <<-EOH - curl -i -X PUT -d '{ "order": 1, "template": "resources", "settings": {}, "mappings": - { - "esartifactdata": { - "properties": { - "id": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "data": { "include_in_all": false, "type": "string" } - }, - "_all": { "enabled": true } - } - } - }' http://localhost:9200/_template/resources_template - EOH -end \ No newline at end of file diff --git a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_5_create_monitoring_template.rb b/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_5_create_monitoring_template.rb deleted file mode 100644 index 5b1f9f8180..0000000000 --- a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_5_create_monitoring_template.rb +++ /dev/null @@ -1,53 +0,0 @@ -ruby_block "check_ElasticSearch_Cluster_Health" do - block do - #tricky way to load this Chef::Mixin::ShellOut utilities - Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) - #curl_command = "http://#{node['ipaddress']}:9200/_cluster/health?pretty=true" - curl_command = "http://localhost:9200/_cluster/health?pretty=true" - resp = Net::HTTP.get_response URI.parse(curl_command) - stat = JSON.parse(resp.read_body)['status'] - - case stat - when "green" - printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.") - when "yellow" - printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...") - when "red" - printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!") - end - end - retries 10 - retry_delay 2 -end - -bash "echo status" do - code <<-EOH - echo "DOCKER STARTED" - EOH -end - -bash "create monitoring mapping" do - code <<-EOH - curl -i -X PUT -d '{ "order": 1, "template": "monitoring_events-*", "settings": {}, "mappings": - { - "monitoringevent": { - "properties": { - "hostid": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "hostcpu": { "include_in_all": true, "type": "long" }, - "hostmem": { "include_in_all": true, "type": "double" }, - "hostdisk": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "jvmid": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "jvmcpu": { "include_in_all": true,"type": "long" }, - "jvmmem": { "include_in_all": true, "type": "long" }, - "jvmtnum": { "include_in_all": true, "type": "integer" }, - "appid": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "appstat": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, - "timestamp": { "include_in_all": true, "index": "not_analyzed", "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } - }, - "_all": { "enabled": true } - } - }, - "aliases": { "last_3_months": {} } - }' http://localhost:9200/_template/monitoring_template - EOH -end diff --git a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_6_create_kibana_dashboard_virtualization.rb b/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_6_create_kibana_dashboard_virtualization.rb deleted file mode 100644 index a35c9bec40..0000000000 --- a/sdc-os-chef/sdc-elasticsearch/chef-repo/cookbooks/sdc-elasticsearch/recipes/ES_6_create_kibana_dashboard_virtualization.rb +++ /dev/null @@ -1,49 +0,0 @@ -ruby_block "check_ElasticSearch_Cluster_Health" do - block do - #tricky way to load this Chef::Mixin::ShellOut utilities - Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) - #curl_command = "http://#{node['ipaddress']}:9200/_cluster/health?pretty=true" - curl_command = "http://localhost:9200/_cluster/health?pretty=true" - resp = Net::HTTP.get_response URI.parse(curl_command) - stat = JSON.parse(resp.read_body)['status'] - - case stat - when "green" - printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.") - when "yellow" - printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...") - when "red" - printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!") - end - end - retries 10 - retry_delay 2 -end - -bash "create Kibana dashboard" do - code <<-EOH - for file in /root/chef-solo/cookbooks/sdc-elasticsearch/files/default/dashboard_*.json; do - name=`basename $file .json | awk -F"_" '{print $2}'` - echo "Loading dashboard $name:" - curl -XPUT http://localhost:9200/.kibana/dashboard/$name -d @$file || exit 1 - echo - done - EOH -end - -bash "create Kibana visualization" do - code <<-EOH - for file in /root/chef-solo/cookbooks/sdc-elasticsearch/files/default/visualization_*.json; do - name=`basename $file .json | awk -F"_" '{print $2}'` - echo "Loading visualization $name:" - curl -XPUT http://localhost:9200/.kibana/visualization/$name -d @$file || exit 1 - echo - done - EOH -end - -bash "echo status" do - code <<-EOH - echo "DOCKER STARTED" - EOH -end \ No newline at end of file diff --git a/sdc-os-chef/sdc-elasticsearch/startup.sh b/sdc-os-chef/sdc-elasticsearch/startup.sh index 0a602ade56..6c9b0c0629 100644 --- a/sdc-os-chef/sdc-elasticsearch/startup.sh +++ b/sdc-os-chef/sdc-elasticsearch/startup.sh @@ -1,20 +1,9 @@ #!/bin/sh -export CHEFNAME=${ENVNAME} -cd /root/chef-solo -echo "normal['HOST_IP'] = \"${HOST_IP}\"" > /root/chef-solo/cookbooks/sdc-elasticsearch/attributes/default.rb - -sed -i '/^exec/iES_JAVA_OPTS=\"-Xms1024M -Xmx1024M\"' /docker-entrypoint.sh - -chef-solo -c solo.rb -E ${CHEFNAME} +cd /root/chef-solo/ +chef-solo -c solo.rb -E ${ENVNAME} /docker-entrypoint.sh elasticsearch & -cd /root/chef-solo -chef-solo -c solo.rb -o recipe[sdc-elasticsearch::ES_3_create_audit_template] -chef-solo -c solo.rb -o recipe[sdc-elasticsearch::ES_4_create_resources_template] -chef-solo -c solo.rb -o recipe[sdc-elasticsearch::ES_5_create_monitoring_template] -chef-solo -c solo.rb -o recipe[sdc-elasticsearch::ES_6_create_kibana_dashboard_virtualization] - while true; do sleep 2; done diff --git a/sdc-os-chef/sdc-init-elasticsearch/Dockerfile b/sdc-os-chef/sdc-init-elasticsearch/Dockerfile new file mode 100644 index 0000000000..63fba6caaf --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/Dockerfile @@ -0,0 +1,11 @@ +FROM onap/base_sdc-sanity:1.2.0-SNAPSHOT-latest + +COPY chef-solo /root/chef-solo/ + +COPY chef-repo/cookbooks /root/chef-solo/cookbooks/ + +COPY startup.sh /root/ + +RUN chmod 770 /root/startup.sh + +ENTRYPOINT [ "/root/startup.sh" ] diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-install.sh b/sdc-os-chef/sdc-init-elasticsearch/chef-install.sh new file mode 100644 index 0000000000..5a4be8ba18 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-install.sh @@ -0,0 +1,707 @@ +#!/bin/sh +# WARNING: REQUIRES /bin/sh +# +# - must run on /bin/sh on solaris 9 +# - must run on /bin/sh on AIX 6.x +# +# Copyright:: Copyright (c) 2010-2015 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# helpers.sh +############ +# This section has some helper functions to make life easier. +# +# Outputs: +# $tmp_dir: secure-ish temp directory that can be used during installation. +############ + +# Check whether a command exists - returns 0 if it does, 1 if it does not +exists() { + if command -v $1 >/dev/null 2>&1 + then + return 0 + else + return 1 + fi +} + +# Output the instructions to report bug about this script +report_bug() { + echo "Version: $version" + echo "" + echo "Please file a Bug Report at https://github.com/chef/omnitruck/issues/new" + echo "Alternatively, feel free to open a Support Ticket at https://www.chef.io/support/tickets" + echo "More Chef support resources can be found at https://www.chef.io/support" + echo "" + echo "Please include as many details about the problem as possible i.e., how to reproduce" + echo "the problem (if possible), type of the Operating System and its version, etc.," + echo "and any other relevant details that might help us with troubleshooting." + echo "" +} + +checksum_mismatch() { + echo "Package checksum mismatch!" + report_bug + exit 1 +} + +unable_to_retrieve_package() { + echo "Unable to retrieve a valid package!" + report_bug + echo "Metadata URL: $metadata_url" + if test "x$download_url" != "x"; then + echo "Download URL: $download_url" + fi + if test "x$stderr_results" != "x"; then + echo "\nDEBUG OUTPUT FOLLOWS:\n$stderr_results" + fi + exit 1 +} + +http_404_error() { + echo "Omnitruck artifact does not exist for version $version on platform $platform" + echo "" + echo "Either this means:" + echo " - We do not support $platform" + echo " - We do not have an artifact for $version" + echo "" + echo "This is often the latter case due to running a prerelease or RC version of chef" + echo "or a gem version which was only pushed to rubygems and not omnitruck." + echo "" + echo "You may be able to set your knife[:bootstrap_version] to the most recent stable" + echo "release of Chef to fix this problem (or the most recent stable major version number)." + echo "" + echo "In order to test the version parameter, adventurous users may take the Metadata URL" + echo "below and modify the '&v=' parameter until you successfully get a URL that" + echo "does not 404 (e.g. via curl or wget). You should be able to use '&v=11' or '&v=12'" + echo "succesfully." + echo "" + echo "If you cannot fix this problem by setting the bootstrap_version, it probably means" + echo "that $platform is not supported." + echo "" + # deliberately do not call report_bug to suppress bug report noise. + echo "Metadata URL: $metadata_url" + if test "x$download_url" != "x"; then + echo "Download URL: $download_url" + fi + if test "x$stderr_results" != "x"; then + echo "\nDEBUG OUTPUT FOLLOWS:\n$stderr_results" + fi + exit 1 +} + +capture_tmp_stderr() { + # spool up /tmp/stderr from all the commands we called + if test -f "$tmp_dir/stderr"; then + output=`cat $tmp_dir/stderr` + stderr_results="${stderr_results}\nSTDERR from $1:\n\n$output\n" + rm $tmp_dir/stderr + fi +} + +# do_wget URL FILENAME +do_wget() { + echo "trying wget..." + wget --user-agent="User-Agent: mixlib-install/2.1.8" -O "$2" "$1" 2>$tmp_dir/stderr + rc=$? + # check for 404 + grep "ERROR 404" $tmp_dir/stderr 2>&1 >/dev/null + if test $? -eq 0; then + echo "ERROR 404" + http_404_error + fi + + # check for bad return status or empty output + if test $rc -ne 0 || test ! -s "$2"; then + capture_tmp_stderr "wget" + return 1 + fi + + return 0 +} + +# do_curl URL FILENAME +do_curl() { + echo "trying curl..." + curl -A "User-Agent: mixlib-install/2.1.8" --retry 5 -sL -D $tmp_dir/stderr "$1" > "$2" + rc=$? + # check for 404 + grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null + if test $? -eq 0; then + echo "ERROR 404" + http_404_error + fi + + # check for bad return status or empty output + if test $rc -ne 0 || test ! -s "$2"; then + capture_tmp_stderr "curl" + return 1 + fi + + return 0 +} + +# do_fetch URL FILENAME +do_fetch() { + echo "trying fetch..." + fetch --user-agent="User-Agent: mixlib-install/2.1.8" -o "$2" "$1" 2>$tmp_dir/stderr + # check for bad return status + test $? -ne 0 && return 1 + return 0 +} + +# do_perl URL FILENAME +do_perl() { + echo "trying perl..." + perl -e 'use LWP::Simple; getprint($ARGV[0]);' "$1" > "$2" 2>$tmp_dir/stderr + rc=$? + # check for 404 + grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null + if test $? -eq 0; then + echo "ERROR 404" + http_404_error + fi + + # check for bad return status or empty output + if test $rc -ne 0 || test ! -s "$2"; then + capture_tmp_stderr "perl" + return 1 + fi + + return 0 +} + +# do_python URL FILENAME +do_python() { + echo "trying python..." + python -c "import sys,urllib2; sys.stdout.write(urllib2.urlopen(urllib2.Request(sys.argv[1], headers={ 'User-Agent': 'mixlib-install/2.1.8' })).read())" "$1" > "$2" 2>$tmp_dir/stderr + rc=$? + # check for 404 + grep "HTTP Error 404" $tmp_dir/stderr 2>&1 >/dev/null + if test $? -eq 0; then + echo "ERROR 404" + http_404_error + fi + + # check for bad return status or empty output + if test $rc -ne 0 || test ! -s "$2"; then + capture_tmp_stderr "python" + return 1 + fi + return 0 +} + +# returns 0 if checksums match +do_checksum() { + if exists sha256sum; then + echo "Comparing checksum with sha256sum..." + checksum=`sha256sum $1 | awk '{ print $1 }'` + return `test "x$checksum" = "x$2"` + elif exists shasum; then + echo "Comparing checksum with shasum..." + checksum=`shasum -a 256 $1 | awk '{ print $1 }'` + return `test "x$checksum" = "x$2"` + else + echo "WARNING: could not find a valid checksum program, pre-install shasum or sha256sum in your O/S image to get valdation..." + return 0 + fi +} + +# do_download URL FILENAME +do_download() { + echo "downloading $1" + echo " to file $2" + + url=`echo $1` + if test "x$platform" = "xsolaris2"; then + if test "x$platform_version" = "x5.9" -o "x$platform_version" = "x5.10"; then + # solaris 9 lacks openssl, solaris 10 lacks recent enough credentials - your base O/S is completely insecure, please upgrade + url=`echo $url | sed -e 's/https/http/'` + fi + fi + + # we try all of these until we get success. + # perl, in particular may be present but LWP::Simple may not be installed + + if exists wget; then + do_wget $url $2 && return 0 + fi + + if exists curl; then + do_curl $url $2 && return 0 + fi + + if exists fetch; then + do_fetch $url $2 && return 0 + fi + + if exists perl; then + do_perl $url $2 && return 0 + fi + + if exists python; then + do_python $url $2 && return 0 + fi + + unable_to_retrieve_package +} + +# install_file TYPE FILENAME +# TYPE is "rpm", "deb", "solaris", "sh", etc. +install_file() { + echo "Installing $project $version" + case "$1" in + "rpm") + if test "x$platform" = "xnexus" || test "x$platform" = "xios_xr"; then + echo "installing with yum..." + yum install -yv "$2" + else + echo "installing with rpm..." + rpm -Uvh --oldpackage --replacepkgs "$2" + fi + ;; + "deb") + echo "installing with dpkg..." + dpkg -i "$2" + ;; + "bff") + echo "installing with installp..." + installp -aXYgd "$2" all + ;; + "solaris") + echo "installing with pkgadd..." + echo "conflict=nocheck" > $tmp_dir/nocheck + echo "action=nocheck" >> $tmp_dir/nocheck + echo "mail=" >> $tmp_dir/nocheck + pkgrm -a $tmp_dir/nocheck -n $project >/dev/null 2>&1 || true + pkgadd -G -n -d "$2" -a $tmp_dir/nocheck $project + ;; + "pkg") + echo "installing with installer..." + cd / && /usr/sbin/installer -pkg "$2" -target / + ;; + "dmg") + echo "installing dmg file..." + hdiutil detach "/Volumes/chef_software" >/dev/null 2>&1 || true + hdiutil attach "$2" -mountpoint "/Volumes/chef_software" + cd / && /usr/sbin/installer -pkg `find "/Volumes/chef_software" -name \*.pkg` -target / + hdiutil detach "/Volumes/chef_software" + ;; + "sh" ) + echo "installing with sh..." + sh "$2" + ;; + "p5p" ) + echo "installing p5p package..." + pkg install -g "$2" $project + ;; + *) + echo "Unknown filetype: $1" + report_bug + exit 1 + ;; + esac + if test $? -ne 0; then + echo "Installation failed" + report_bug + exit 1 + fi +} + +if test "x$TMPDIR" = "x"; then + tmp="/tmp" +else + tmp=$TMPDIR +fi +# secure-ish temp dir creation without having mktemp available (DDoS-able but not expliotable) +tmp_dir="$tmp/install.sh.$$" +(umask 077 && mkdir $tmp_dir) || exit 1 + +############ +# end of helpers.sh +############ + + +# script_cli_parameters.sh +############ +# This section reads the CLI parameters for the install script and translates +# them to the local parameters to be used later by the script. +# +# Outputs: +# $version: Requested version to be installed. +# $channel: Channel to install the product from +# $project: Project to be installed +# $cmdline_filename: Name of the package downloaded on local disk. +# $cmdline_dl_dir: Name of the directory downloaded package will be saved to on local disk. +############ + +# Defaults +channel="stable" +project="chef" + +while getopts pnv:c:f:P:d: opt +do + case "$opt" in + + v) version="$OPTARG";; + c) channel="$OPTARG";; + p) channel="current";; # compat for prerelease option + n) channel="current";; # compat for nightlies option + f) cmdline_filename="$OPTARG";; + P) project="$OPTARG";; + d) cmdline_dl_dir="$OPTARG";; + \?) # unknown flag + echo >&2 \ + "usage: $0 [-P project] [-c release_channel] [-v version] [-f filename | -d download_dir]" + exit 1;; + esac +done + +shift `expr $OPTIND - 1` + + +# platform_detection.sh +############ +# This section makes platform detection compatible with omnitruck on the system +# it runs. +# +# Outputs: +# $platform: Name of the platform. +# $platform_version: Version of the platform. +# $machine: System's architecture. +############ + +# +# Platform and Platform Version detection +# +# NOTE: This should now match ohai platform and platform_version matching. +# do not invented new platform and platform_version schemas, just make this behave +# like what ohai returns as platform and platform_version for the server. +# +# ALSO NOTE: Do not mangle platform or platform_version here. It is less error +# prone and more future-proof to do that in the server, and then all omnitruck clients +# will 'inherit' the changes (install.sh is not the only client of the omnitruck +# endpoint out there). +# + +machine=`uname -m` +os=`uname -s` + +if test -f "/etc/lsb-release" && grep -q DISTRIB_ID /etc/lsb-release && ! grep -q wrlinux /etc/lsb-release; then + platform=`grep DISTRIB_ID /etc/lsb-release | cut -d "=" -f 2 | tr '[A-Z]' '[a-z]'` + platform_version=`grep DISTRIB_RELEASE /etc/lsb-release | cut -d "=" -f 2` + + if test "$platform" = "\"cumulus linux\""; then + platform="cumulus_linux" + elif test "$platform" = "\"cumulus networks\""; then + platform="cumulus_networks" + fi + +elif test -f "/etc/debian_version"; then + platform="debian" + platform_version=`cat /etc/debian_version` +elif test -f "/etc/Eos-release"; then + # EOS may also contain /etc/redhat-release so this check must come first. + platform=arista_eos + platform_version=`awk '{print $4}' /etc/Eos-release` + machine="i386" +elif test -f "/etc/redhat-release"; then + platform=`sed 's/^\(.\+\) release.*/\1/' /etc/redhat-release | tr '[A-Z]' '[a-z]'` + platform_version=`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/redhat-release` + + # If /etc/redhat-release exists, we act like RHEL by default + if test "$platform" = "fedora"; then + # FIXME: stop remapping fedora to el + # FIXME: remove client side platform_version mangling and hard coded yolo + # Change platform version for use below. + platform_version="6.0" + fi + + if test "$platform" = "xenserver"; then + # Current XenServer 6.2 is based on CentOS 5, platform is not reset to "el" server should hanlde response + platform="xenserver" + else + # FIXME: use "redhat" + platform="el" + fi + +elif test -f "/etc/system-release"; then + platform=`sed 's/^\(.\+\) release.\+/\1/' /etc/system-release | tr '[A-Z]' '[a-z]'` + platform_version=`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/system-release | tr '[A-Z]' '[a-z]'` + # amazon is built off of fedora, so act like RHEL + if test "$platform" = "amazon linux ami"; then + # FIXME: remove client side platform_version mangling and hard coded yolo, and remapping to deprecated "el" + platform="el" + platform_version="6.0" + fi +# Apple OS X +elif test -f "/usr/bin/sw_vers"; then + platform="mac_os_x" + # Matching the tab-space with sed is error-prone + platform_version=`sw_vers | awk '/^ProductVersion:/ { print $2 }' | cut -d. -f1,2` + + # x86_64 Apple hardware often runs 32-bit kernels (see OHAI-63) + x86_64=`sysctl -n hw.optional.x86_64` + if test $x86_64 -eq 1; then + machine="x86_64" + fi +elif test -f "/etc/release"; then + machine=`/usr/bin/uname -p` + if grep -q SmartOS /etc/release; then + platform="smartos" + platform_version=`grep ^Image /etc/product | awk '{ print $3 }'` + else + platform="solaris2" + platform_version=`/usr/bin/uname -r` + fi +elif test -f "/etc/SuSE-release"; then + if grep -q 'Enterprise' /etc/SuSE-release; + then + platform="sles" + platform_version=`awk '/^VERSION/ {V = $3}; /^PATCHLEVEL/ {P = $3}; END {print V "." P}' /etc/SuSE-release` + else + platform="suse" + platform_version=`awk '/^VERSION =/ { print $3 }' /etc/SuSE-release` + fi +elif test "x$os" = "xFreeBSD"; then + platform="freebsd" + platform_version=`uname -r | sed 's/-.*//'` +elif test "x$os" = "xAIX"; then + platform="aix" + platform_version="`uname -v`.`uname -r`" + machine="powerpc" +elif test -f "/etc/os-release"; then + . /etc/os-release + if test "x$CISCO_RELEASE_INFO" != "x"; then + . $CISCO_RELEASE_INFO + fi + + platform=$ID + platform_version=$VERSION +fi + +if test "x$platform" = "x"; then + echo "Unable to determine platform version!" + report_bug + exit 1 +fi + +# +# NOTE: platform manging in the install.sh is DEPRECATED +# +# - install.sh should be true to ohai and should not remap +# platform or platform versions. +# +# - remapping platform and mangling platform version numbers is +# now the complete responsibility of the server-side endpoints +# + +major_version=`echo $platform_version | cut -d. -f1` +case $platform in + # FIXME: should remove this case statement completely + "el") + # FIXME: "el" is deprecated, should use "redhat" + platform_version=$major_version + ;; + "debian") + if test "x$major_version" = "x5"; then + # This is here for potential back-compat. + # We do not have 5 in versions we publish for anymore but we + # might have it for earlier versions. + platform_version="6" + else + platform_version=$major_version + fi + ;; + "freebsd") + platform_version=$major_version + ;; + "sles") + platform_version=$major_version + ;; + "suse") + platform_version=$major_version + ;; +esac + +# normalize the architecture we detected +case $machine in + "x86_64"|"amd64"|"x64") + machine="x86_64" + ;; + "i386"|"i86pc"|"x86"|"i686") + machine="i386" + ;; + "sparc"|"sun4u"|"sun4v") + machine="sparc" + ;; +esac + +if test "x$platform_version" = "x"; then + echo "Unable to determine platform version!" + report_bug + exit 1 +fi + +if test "x$platform" = "xsolaris2"; then + # hack up the path on Solaris to find wget, pkgadd + PATH=/usr/sfw/bin:/usr/sbin:$PATH + export PATH +fi + +echo "$platform $platform_version $machine" + +############ +# end of platform_detection.sh +############ + + +# fetch_metadata.sh +############ +# This section calls omnitruck to get the information about the build to be +# installed. +# +# Inputs: +# $channel: +# $project: +# $version: +# $platform: +# $platform_version: +# $machine: +# $tmp_dir: +# +# Outputs: +# $download_url: +# $sha256: +############ + +echo "Getting information for $project $channel $version for $platform..." + +metadata_filename="$tmp_dir/metadata.txt" +metadata_url="https://omnitruck-direct.chef.io/$channel/$project/metadata?v=$version&p=$platform&pv=$platform_version&m=$machine" + +do_download "$metadata_url" "$metadata_filename" + +cat "$metadata_filename" + +echo "" +# check that all the mandatory fields in the downloaded metadata are there +if grep '^url' $metadata_filename > /dev/null && grep '^sha256' $metadata_filename > /dev/null; then + echo "downloaded metadata file looks valid..." +else + echo "downloaded metadata file is corrupted or an uncaught error was encountered in downloading the file..." + # this generally means one of the download methods downloaded a 404 or something like that and then reported a successful exit code, + # and this should be fixed in the function that was doing the download. + report_bug + exit 1 +fi + +download_url=`awk '$1 == "url" { print $2 }' "$metadata_filename"` +sha256=`awk '$1 == "sha256" { print $2 }' "$metadata_filename"` + +############ +# end of fetch_metadata.sh +############ + + +# fetch_package.sh +############ +# This section fetchs a package from $download_url and verifies its metadata. +# +# Inputs: +# $download_url: +# $tmp_dir: +# Optional Inputs: +# $cmdline_filename: Name of the package downloaded on local disk. +# $cmdline_dl_dir: Name of the directory downloaded package will be saved to on local disk. +# +# Outputs: +# $download_filename: Name of the downloaded file on local disk. +# $filetype: Type of the file downloaded. +############ + +filename=`echo $download_url | sed -e 's/^.*\///'` +filetype=`echo $filename | sed -e 's/^.*\.//'` + +# use either $tmp_dir, the provided directory (-d) or the provided filename (-f) +if test "x$cmdline_filename" != "x"; then + download_filename="$cmdline_filename" +elif test "x$cmdline_dl_dir" != "x"; then + download_filename="$cmdline_dl_dir/$filename" +else + download_filename="$tmp_dir/$filename" +fi + +# ensure the parent directory where to download the installer always exists +download_dir=`dirname $download_filename` +(umask 077 && mkdir -p $download_dir) || exit 1 + +# check if we have that file locally available and if so verify the checksum +cached_file_available="false" +if test -f $download_filename; then + echo "$download_filename already exists, verifiying checksum..." + if do_checksum "$download_filename" "$sha256"; then + echo "checksum compare succeeded, using existing file!" + cached_file_available="true" + else + echo "checksum mismatch, downloading latest version of the file" + fi +fi + +# download if no local version of the file available +if test "x$cached_file_available" != "xtrue"; then + do_download "$download_url" "$download_filename" + do_checksum "$download_filename" "$sha256" || checksum_mismatch +fi + +############ +# end of fetch_package.sh +############ + + +# install_package.sh +############ +# Installs a package and removed the temp directory. +# +# Inputs: +# $download_filename: Name of the file to be installed. +# $filetype: Type of the file to be installed. +# $version: The version requested. Used only for warning user if not set. +############ + +if test "x$version" = "x"; then + echo + echo "WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING" + echo + echo "You are installing an omnibus package without a version pin. If you are installing" + echo "on production servers via an automated process this is DANGEROUS and you will" + echo "be upgraded without warning on new releases, even to new major releases." + echo "Letting the version float is only appropriate in desktop, test, development or" + echo "CI/CD environments." + echo + echo "WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING" + echo +fi + +install_file $filetype "$download_filename" + +if test "x$tmp_dir" != "x"; then + rm -r "$tmp_dir" +fi + +############ +# end of install_package.sh +############ diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/attributes/default.rb b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/attributes/default.rb new file mode 100644 index 0000000000..4287ca8617 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/attributes/default.rb @@ -0,0 +1 @@ +# \ No newline at end of file diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/dashboard_BI-Dashboard.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/dashboard_BI-Dashboard.json new file mode 100644 index 0000000000..c740a94f5d --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/dashboard_BI-Dashboard.json @@ -0,0 +1,13 @@ +{ + "title": "BI Dashboard", + "hits": 0, + "description": "", + "panelsJSON": "[{\"col\":1,\"id\":\"Show-all-certified-services-ampersand-resources-(per-day)\",\"panelIndex\":1,\"row\":1,\"size_x\":6,\"size_y\":5,\"type\":\"visualization\"},{\"col\":7,\"id\":\"Show-all-distributed-services\",\"panelIndex\":2,\"row\":1,\"size_x\":6,\"size_y\":5,\"type\":\"visualization\"},{\"id\":\"Show-all-created-Resources-slash-Services-slash-Products\",\"type\":\"visualization\",\"panelIndex\":3,\"size_x\":6,\"size_y\":4,\"col\":1,\"row\":6},{\"id\":\"number-of-user-accesses\",\"type\":\"visualization\",\"panelIndex\":4,\"size_x\":6,\"size_y\":4,\"col\":7,\"row\":6}]", + "optionsJSON": "{\"darkTheme\":false}", + "uiStateJSON": "{}", + "version": 1, + "timeRestore": false, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/dashboard_Monitoring-Dashboared.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/dashboard_Monitoring-Dashboared.json new file mode 100644 index 0000000000..41b9c00c6e --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/dashboard_Monitoring-Dashboared.json @@ -0,0 +1,15 @@ +{ + "title": "Monitoring Dashboared", + "hits": 0, + "description": "", + "panelsJSON": "[{\"id\":\"JVM-used-CPU\",\"type\":\"visualization\",\"panelIndex\":1,\"size_x\":6,\"size_y\":5,\"col\":1,\"row\":5},{\"id\":\"JVM-used-Memory\",\"type\":\"visualization\",\"panelIndex\":2,\"size_x\":6,\"size_y\":4,\"col\":1,\"row\":1},{\"id\":\"JVM-used-Threads-Num\",\"type\":\"visualization\",\"panelIndex\":3,\"size_x\":6,\"size_y\":4,\"col\":7,\"row\":1},{\"id\":\"host-used-CPU\",\"type\":\"visualization\",\"panelIndex\":4,\"size_x\":3,\"size_y\":2,\"col\":7,\"row\":5},{\"id\":\"host-used-Memory\",\"type\":\"visualization\",\"panelIndex\":5,\"size_x\":3,\"size_y\":2,\"col\":10,\"row\":5},{\"id\":\"host-used-Threads-Num\",\"type\":\"visualization\",\"panelIndex\":6,\"size_x\":3,\"size_y\":2,\"col\":7,\"row\":7}]", + "optionsJSON": "{\"darkTheme\":false}", + "uiStateJSON": "{}", + "version": 1, + "timeRestore": true, + "timeTo": "now", + "timeFrom": "now-24h", + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"filter\":[{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}}}]}" + } +} \ No newline at end of file diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-CPU.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-CPU.json new file mode 100644 index 0000000000..45565cf0a4 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-CPU.json @@ -0,0 +1,10 @@ +{ + "title": "JVM used CPU", + "visState": "{\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"avg\",\"schema\":\"metric\",\"params\":{\"field\":\"jvmcpu\"}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"timestamp\",\"interval\":\"h\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"jvmid\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}},{\"id\":\"4\",\"type\":\"terms\",\"schema\":\"split\",\"params\":{\"field\":\"hostid\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"row\":true}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"monitoring_events-*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" + } +} \ No newline at end of file diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-Memory.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-Memory.json new file mode 100644 index 0000000000..c030df4655 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-Memory.json @@ -0,0 +1,10 @@ +{ + "title": "JVM used Memory", + "visState": "{\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"avg\",\"schema\":\"metric\",\"params\":{\"field\":\"jvmmem\"}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"timestamp\",\"interval\":\"h\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"jvmid\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}},{\"id\":\"4\",\"type\":\"terms\",\"schema\":\"split\",\"params\":{\"field\":\"hostid\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"row\":true}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"monitoring_events-*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-Threads-Num.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-Threads-Num.json new file mode 100644 index 0000000000..28d0468e9d --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_JVM-used-Threads-Num.json @@ -0,0 +1,10 @@ +{ + "title": "JVM used Threads Num", + "visState": "{\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"avg\",\"schema\":\"metric\",\"params\":{\"field\":\"jvmtnum\"}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"timestamp\",\"interval\":\"h\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"jvmid\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}},{\"id\":\"4\",\"type\":\"terms\",\"schema\":\"split\",\"params\":{\"field\":\"hostid\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"row\":true}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"monitoring_events-*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-certified-services-ampersand-resources-(per-day).json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-certified-services-ampersand-resources-(per-day).json new file mode 100644 index 0000000000..7d7ce6e4d4 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-certified-services-ampersand-resources-(per-day).json @@ -0,0 +1,10 @@ +{ + "title": "Show all certified services & resources (per day)", + "visState": "{\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"TIMESTAMP\",\"interval\":\"d\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"auditingevents-*\",\"query\":{\"query_string\":{\"query\":\"ACTION:\\\"CertificationSuccess\\\" AND (RESOURCE_TYPE:\\\"Resource\\\" OR RESOURCE_TYPE:\\\"Service\\\")\",\"analyze_wildcard\":true}},\"filter\":[]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-created-Resources-slash-Services-slash-Products.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-created-Resources-slash-Services-slash-Products.json new file mode 100644 index 0000000000..37e06ca3ca --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-created-Resources-slash-Services-slash-Products.json @@ -0,0 +1,10 @@ +{ + "title": "Show all created Resources/Services/Products", + "visState": "{\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"TIMESTAMP\",\"interval\":\"d\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"RESOURCE_TYPE\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"auditingevents-*\",\"query\":{\"query_string\":{\"query\":\"ACTION:\\\"Create\\\"\",\"analyze_wildcard\":true}},\"filter\":[]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-distributed-services.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-distributed-services.json new file mode 100644 index 0000000000..5d375733f5 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_Show-all-distributed-services.json @@ -0,0 +1,10 @@ +{ + "title": "Show all distributed services", + "visState": "{\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"TIMESTAMP\",\"interval\":\"d\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"auditingevents-*\",\"query\":{\"query_string\":{\"query\":\"ACTION:\\\"DResult\\\"\",\"analyze_wildcard\":true}},\"filter\":[]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_host-used-CPU.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_host-used-CPU.json new file mode 100644 index 0000000000..3c9f7d5425 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_host-used-CPU.json @@ -0,0 +1,10 @@ +{ + "title": "host used CPU", + "visState": "{\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"avg\",\"schema\":\"metric\",\"params\":{\"field\":\"hostcpu\"}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"timestamp\",\"interval\":\"h\",\"customInterval\":\"24h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"hostid\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"monitoring_events-*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_host-used-Threads-Num.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_host-used-Threads-Num.json new file mode 100644 index 0000000000..a6a7c09395 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_host-used-Threads-Num.json @@ -0,0 +1,10 @@ +{ + "title": "host used Threads Num", + "visState": "{\"type\":\"line\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"showCircles\":true,\"smoothLines\":false,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"avg\",\"schema\":\"metric\",\"params\":{\"field\":\"jvmtnum\"}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"timestamp\",\"interval\":\"h\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"hostid\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"monitoring_events-*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_number-of-user-accesses.json b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_number-of-user-accesses.json new file mode 100644 index 0000000000..fdcd88c16f --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/files/default/visualization_number-of-user-accesses.json @@ -0,0 +1,10 @@ +{ + "title": "number of user accesses", + "visState": "{\"type\":\"line\",\"params\":{\"addLegend\":true,\"addTimeMarker\":false,\"addTooltip\":true,\"defaultYExtents\":false,\"drawLinesBetweenPoints\":true,\"interpolate\":\"linear\",\"radiusRatio\":9,\"scale\":\"linear\",\"setYExtents\":false,\"shareYAxis\":true,\"showCircles\":true,\"smoothLines\":false,\"times\":[],\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"TIMESTAMP\",\"interval\":\"d\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}}],\"listeners\":{}}", + "uiStateJSON": "{}", + "description": "", + "version": 1, + "kibanaSavedObjectMeta": { + "searchSourceJSON": "{\"index\":\"auditingevents-*\",\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"ACTION:\\\"Access\\\"\"}},\"filter\":[]}" + } +} diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_1_create_audit_template.rb b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_1_create_audit_template.rb new file mode 100644 index 0000000000..35bf49fb6d --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_1_create_audit_template.rb @@ -0,0 +1,245 @@ +ruby_block "check_ElasticSearch_Cluster_Health" do + block do + #tricky way to load this Chef::Mixin::ShellOut utilities + Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) + curl_command = "http://#{node['Nodes']['ES']}:9200/_cluster/health?pretty=true" + resp = Net::HTTP.get_response URI.parse(curl_command) + stat = JSON.parse(resp.read_body)['status'] + + case stat + when "green" + printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.") + when "yellow" + printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...") + when "red" + printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!") + break; + end + end + retries 50 + retry_delay 2 +end + + +bash "create audit mapping" do + code <<-EOH + curl -i -X PUT -d '{ "order": 1, "template": "auditingevents-*", "settings": {}, "mappings": + { + "distributiondownloadevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "RESOURCE_URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } + }, + "_all": { "enabled": true } + }, + "auditinggetuebclusterevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } + }, + "_all": { "enabled": true } + }, + "distributionstatusevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "RESOURCE_URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } + }, + "_all": { "enabled": true } + }, + "distributionengineevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ROLE": { "include_in_all": true, "type": "string" }, + "API_KEY": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "D_ENV": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } + }, + "_all": { "enabled": true } + }, + "useraccessevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "USER": { "include_in_all": true, "type": "string" } + }, + "_all": { "enabled": true } + }, + "resourceadminevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "INVARIANT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CURR_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "MODIFIER": { "include_in_all": true, "type": "string" }, + "PREV_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "PREV_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "RESOURCE_NAME": { "include_in_all": true, "type": "string" }, + "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DPREV_STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DCURR_STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TOSCA_NODE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "COMMENT": { "include_in_all": true, "type": "string" }, + "ARTIFACT_DATA": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "PREV_ARTIFACT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CURR_ARTIFACT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } + }, + "_all": { "enabled": true } + }, + "useradminevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "USER_AFTER": { "include_in_all": true, "type": "string" }, + "USER_BEFORE": { "include_in_all": true, "type": "string" }, + "MODIFIER": { "include_in_all": true, "type": "string" } + }, + "_all": { "enabled": true } + }, + "distributionnotificationevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CURR_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "MODIFIER": { "include_in_all": true, "type": "string" }, + "RESOURCE_NAME": { "include_in_all": true, "type": "string" }, + "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" } + }, + "_all": { "enabled": true } + }, + "categoryevent": { + "properties": { + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "MODIFIER": { "include_in_all": true, "type": "string" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CATEGORY_NAME": { "include_in_all": true, "type": "string" }, + "SUB_CATEGORY_NAME": { "include_in_all": true, "type": "string" }, + "GROUPING_NAME": { "include_in_all": true, "type": "string" }, + "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } + }, + "_all": { "enabled": true } + }, + "authevent": { + "properties": { + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }, + "DESC": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "USER": { "include_in_all": true, "type": "string" }, + "AUTH_STATUS": { "include_in_all": true, "index": "not_analyzed","type": "string" } , + "REALM": { "include_in_all": true, "index": "not_analyzed","type": "string" } + }, + "_all": { "enabled": true } + }, + "consumerevent": { + "properties": { + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "MODIFIER": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "ECOMP_USER": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } + }, + "_all": { "enabled": true } + }, + "getuserslistevent": { + "properties": { + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "MODIFIER": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DETAILS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } + }, + "_all": { "enabled": true } + }, + "getcategoryhierarchyevent": { + "properties": { + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "MODIFIER": { "include_in_all": true, "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DETAILS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } + }, + "_all": { "enabled": true } + }, + "distributiondeployevent": { + "properties": { + "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "DESC": { "include_in_all": true, "type": "string" }, + "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "MODIFIER": { "include_in_all": true, "type": "string" }, + "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "RESOURCE_NAME": { "include_in_all": true, "type": "string" }, + "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } + }, + "_all": { "enabled": true } } + }, + "aliases": { "last_3_months": {}}}' http://#{node['Nodes']['ES']}:9200/_template/audit_template + EOH +end + +bash "set default index for Kibana" do + code <<-EOH + curl -XPUT http://#{node['Nodes']['ES']}:9200/.kibana/index-pattern/auditingevents-* -d '{"title" : "events-*", "timeFieldName": "TIMESTAMP"}' + curl -XPUT http://#{node['Nodes']['ES']}:9200/.kibana/config/4.3.3 -d '{"defaultIndex" : "auditingevents-*"}' + EOH +end diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_2_create_resources_template.rb b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_2_create_resources_template.rb new file mode 100644 index 0000000000..d35b81293e --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_2_create_resources_template.rb @@ -0,0 +1,37 @@ +ruby_block "check_ElasticSearch_Cluster_Health" do + block do + #tricky way to load this Chef::Mixin::ShellOut utilities + Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) + curl_command = "http://#{node['Nodes']['ES']}:9200/_cluster/health?pretty=true" + resp = Net::HTTP.get_response URI.parse(curl_command) + stat = JSON.parse(resp.read_body)['status'] + + case stat + when "green" + printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.") + when "yellow" + printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...") + when "red" + printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!") + break; + end + end + retries 10 + retry_delay 2 +end + +bash "create resources mapping" do + code <<-EOH + curl -i -X PUT -d '{ "order": 1, "template": "resources", "settings": {}, "mappings": + { + "esartifactdata": { + "properties": { + "id": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "data": { "include_in_all": false, "type": "string" } + }, + "_all": { "enabled": true } + } + } + }' http://#{node['Nodes']['ES']}:9200/_template/resources_template + EOH +end \ No newline at end of file diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb new file mode 100644 index 0000000000..02b20f8cce --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_3_create_monitoring_template.rb @@ -0,0 +1,53 @@ +ruby_block "check_ElasticSearch_Cluster_Health" do + block do + #tricky way to load this Chef::Mixin::ShellOut utilities + Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) + curl_command = "http://#{node['Nodes']['ES']}:9200/_cluster/health?pretty=true" + resp = Net::HTTP.get_response URI.parse(curl_command) + stat = JSON.parse(resp.read_body)['status'] + + case stat + when "green" + printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.") + when "yellow" + printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...") + when "red" + printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!") + break; + end + end + retries 10 + retry_delay 2 +end + +bash "echo status" do + code <<-EOH + echo "DOCKER STARTED" + EOH +end + +bash "create monitoring mapping" do + code <<-EOH + curl -i -X PUT -d '{ "order": 1, "template": "monitoring_events-*", "settings": {}, "mappings": + { + "monitoringevent": { + "properties": { + "hostid": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "hostcpu": { "include_in_all": true, "type": "long" }, + "hostmem": { "include_in_all": true, "type": "double" }, + "hostdisk": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "jvmid": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "jvmcpu": { "include_in_all": true,"type": "long" }, + "jvmmem": { "include_in_all": true, "type": "long" }, + "jvmtnum": { "include_in_all": true, "type": "integer" }, + "appid": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "appstat": { "include_in_all": true, "index": "not_analyzed", "type": "string" }, + "timestamp": { "include_in_all": true, "index": "not_analyzed", "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" } + }, + "_all": { "enabled": true } + } + }, + "aliases": { "last_3_months": {} } + }' http://#{node['Nodes']['ES']}:9200/_template/monitoring_template + EOH +end diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_4_create_kibana_dashboard_virtualization.rb b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_4_create_kibana_dashboard_virtualization.rb new file mode 100644 index 0000000000..08c3fac613 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-repo/cookbooks/init-sdc-elasticsearch/recipes/ES_4_create_kibana_dashboard_virtualization.rb @@ -0,0 +1,49 @@ +ruby_block "check_ElasticSearch_Cluster_Health" do + block do + #tricky way to load this Chef::Mixin::ShellOut utilities + Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) + curl_command = "http://#{node['Nodes']['ES']}:9200/_cluster/health?pretty=true" + resp = Net::HTTP.get_response URI.parse(curl_command) + stat = JSON.parse(resp.read_body)['status'] + + case stat + when "green" + printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.") + when "yellow" + printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...") + when "red" + printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!") + break; + end + end + retries 10 + retry_delay 2 +end + +bash "create Kibana dashboard" do + code <<-EOH + for file in /root/chef-solo/cookbooks/sdc-init-elasticsearch/files/default/dashboard_*.json; do + name=`basename $file .json | awk -F"_" '{print $2}'` + echo "Loading dashboard $name:" + curl -XPUT http://#{node['Nodes']['ES']}:9200/.kibana/dashboard/$name -d @$file || exit 1 + echo + done + EOH +end + +bash "create Kibana visualization" do + code <<-EOH + for file in /root/chef-solo/cookbooks/sdc-init-elasticsearch/files/default/visualization_*.json; do + name=`basename $file .json | awk -F"_" '{print $2}'` + echo "Loading visualization $name:" + curl -XPUT http://#{node['Nodes']['ES']}:9200/.kibana/visualization/$name -d @$file || exit 1 + echo + done + EOH +end + +bash "echo status" do + code <<-EOH + echo "DOCKER STARTED" + EOH +end \ No newline at end of file diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/LICENSE b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/LICENSE new file mode 100644 index 0000000000..11069edd79 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/README.md b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/README.md new file mode 100644 index 0000000000..ddb0fda830 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/README.md @@ -0,0 +1,37 @@ +Deprecated +========== + +Use of this repository is deprecated. We recommend using the `chef generate repo` command that comes with [ChefDK](http://downloads.chef.io/chef-dk/). + +Overview +======== + +Every Chef installation needs a Chef Repository. This is the place where cookbooks, roles, config files and other artifacts for managing systems with Chef will live. We strongly recommend storing this repository in a version control system such as Git and treat it like source code. + +While we prefer Git, and make this repository available via GitHub, you are welcome to download a tar or zip archive and use your favorite version control system to manage the code. + +Repository Directories +====================== + +This repository contains several directories, and each directory contains a README file that describes what it is for in greater detail, and how to use it for managing your systems with Chef. + +* `cookbooks/` - Cookbooks you download or create. +* `data_bags/` - Store data bags and items in .json in the repository. +* `roles/` - Store roles in .rb or .json in the repository. +* `environments/` - Store environments in .rb or .json in the repository. + +Configuration +============= + +The repository contains a knife configuration file. + +* .chef/knife.rb + +The knife configuration file `.chef/knife.rb` is a repository specific configuration file for knife. If you're using Hosted Chef, you can download one for your organization from the management console. If you're using the Open Source Chef Server, you can generate a new one with `knife configure`. For more information about configuring Knife, see the Knife documentation. + +https://docs.chef.io/knife.html + +Next Steps +========== + +Read the README file in each of the subdirectories for more information about what goes in those directories. diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/chefignore b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/chefignore new file mode 100644 index 0000000000..ba30af6cff --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/chefignore @@ -0,0 +1,11 @@ +# Put files/directories that should be ignored in this file. +# Lines that start with '# ' are comments. + +# emacs +*~ + +# vim +*.sw[a-z] + +# subversion +*/.svn/* diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/cookbooks/README.md b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/cookbooks/README.md new file mode 100644 index 0000000000..86ea46bfbb --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/cookbooks/README.md @@ -0,0 +1,54 @@ +This directory contains the cookbooks used to configure systems in your infrastructure with Chef. + +Knife needs to be configured to know where the cookbooks are located with the `cookbook_path` setting. If this is not set, then several cookbook operations will fail to work properly. + + cookbook_path ["./cookbooks"] + +This setting tells knife to look for the cookbooks directory in the present working directory. This means the knife cookbook subcommands need to be run in the `chef-repo` directory itself. To make sure that the cookbooks can be found elsewhere inside the repository, use an absolute path. This is a Ruby file, so something like the following can be used: + + current_dir = File.dirname(__FILE__) + cookbook_path ["#{current_dir}/../cookbooks"] + +Which will set `current_dir` to the location of the knife.rb file itself (e.g. `~/chef-repo/.chef/knife.rb`). + +Configure knife to use your preferred copyright holder, email contact and license. Add the following lines to `.chef/knife.rb`. + + cookbook_copyright "Example, Com." + cookbook_email "cookbooks@example.com" + cookbook_license "apachev2" + +Supported values for `cookbook_license` are "apachev2", "mit","gplv2","gplv3", or "none". These settings are used to prefill comments in the default recipe, and the corresponding values in the metadata.rb. You are free to change the the comments in those files. + +Create new cookbooks in this directory with Knife. + + knife cookbook create COOKBOOK + +This will create all the cookbook directory components. You don't need to use them all, and can delete the ones you don't need. It also creates a README file, metadata.rb and default recipe. + +You can also download cookbooks directly from the Opscode Cookbook Site. There are two subcommands to help with this depending on what your preference is. + +The first and recommended method is to use a vendor branch if you're using Git. This is automatically handled with Knife. + + knife cookbook site install COOKBOOK + +This will: + +* Download the cookbook tarball from cookbooks.opscode.com. +* Ensure its on the git master branch. +* Checks for an existing vendor branch, and creates if it doesn't. +* Checks out the vendor branch (chef-vendor-COOKBOOK). +* Removes the existing (old) version. +* Untars the cookbook tarball it downloaded in the first step. +* Adds the cookbook files to the git index and commits. +* Creates a tag for the version downloaded. +* Checks out the master branch again. +* Merges the cookbook into master. +* Repeats the above for all the cookbooks dependencies, downloading them from the community site + +The last step will ensure that any local changes or modifications you have made to the cookbook are preserved, so you can keep your changes through upstream updates. + +If you're not using Git, use the site download subcommand to download the tarball. + + knife cookbook site download COOKBOOK + +This creates the COOKBOOK.tar.gz from in the current directory (e.g., `~/chef-repo`). We recommend following a workflow similar to the above for your version control tool. diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/data_bags/README.md b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/data_bags/README.md new file mode 100644 index 0000000000..0c15a391fa --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/data_bags/README.md @@ -0,0 +1,63 @@ +Data Bags +--------- + +This directory contains directories of the various data bags you create for your infrastructure. Each subdirectory corresponds to a data bag on the Chef Server, and contains JSON files of the items that go in the bag. + +First, create a directory for the data bag. + + mkdir data_bags/BAG + +Then create the JSON files for items that will go into that bag. + + $EDITOR data_bags/BAG/ITEM.json + +The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM". For example, + + { + "id": "foo" + } + +Next, create the data bag on the Chef Server. + + knife data bag create BAG + +Then upload the items in the data bag's directory to the Chef Server. + + knife data bag from file BAG ITEM.json + + +Encrypted Data Bags +------------------- + +Added in Chef 0.10, encrypted data bags allow you to encrypt the contents of your data bags. The content of attributes will no longer be searchable. To use encrypted data bags, first you must have or create a secret key. + + openssl rand -base64 512 > secret_key + +You may use this secret_key to add items to a data bag during a create. + + knife data bag create --secret-file secret_key passwords mysql + +You may also use it when adding ITEMs from files, + + knife data bag create passwords + knife data bag from file passwords data_bags/passwords/mysql.json --secret-file secret_key + +The JSON for the ITEM must contain a key named "id" with a value equal to "ITEM" and the contents will be encrypted when uploaded. For example, + + { + "id": "mysql", + "password": "abc123" + } + +Without the secret_key, the contents are encrypted. + + knife data bag show passwords mysql + id: mysql + password: 2I0XUUve1TXEojEyeGsjhw== + +Use the secret_key to view the contents. + + knife data bag show passwords mysql --secret-file secret_key + id: mysql + password: abc123 + diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/environments/README.md b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/environments/README.md new file mode 100644 index 0000000000..50ac48db2b --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/environments/README.md @@ -0,0 +1,5 @@ +Requires Chef 0.10.0+. + +This directory is for Ruby DSL and JSON files for environments. For more information see the Chef wiki page: + +http://docs.chef.io/environments.html diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/roles/README.md b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/roles/README.md new file mode 100644 index 0000000000..b0ee0b4d21 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/roles/README.md @@ -0,0 +1,16 @@ +Create roles here, in either the Role Ruby DSL (.rb) or JSON (.json) files. To install roles on the server, use knife. + +For example, create `roles/base_example.rb`: + + name "base_example" + description "Example base role applied to all nodes." + # List of recipes and roles to apply. Requires Chef 0.8, earlier versions use 'recipes()'. + #run_list() + # Attributes applied if the node doesn't have it set already. + #default_attributes() + # Attributes applied no matter what the node has set already. + #override_attributes() + +Then upload it to the Chef Server: + + knife role from file roles/base_example.rb diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/roles/init-elasticsearch.json b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/roles/init-elasticsearch.json new file mode 100644 index 0000000000..d43918475d --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/roles/init-elasticsearch.json @@ -0,0 +1,21 @@ +{ + "name": "init-elasticsearch", + "description": "Initialization of application - elasticsearch", + "json_class": "Chef::Role", + "default_attributes": { + + }, + "override_attributes": { + + }, + "chef_type": "role", + "run_list": [ + "recipe[init-sdc-elasticsearch::ES_1_create_audit_template]", + "recipe[init-sdc-elasticsearch::ES_2_create_resources_template]", + "recipe[init-sdc-elasticsearch::ES_3_create_monitoring_template]", + "recipe[init-sdc-elasticsearch::ES_4_create_kibana_dashboard_virtualization]" + ], + "env_run_lists": { + } +} + diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/solo.json b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/solo.json new file mode 100644 index 0000000000..74979fabcb --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/solo.json @@ -0,0 +1,4 @@ +{ + "run_list": [ "role[init-elasticsearch]" ] +} + diff --git a/sdc-os-chef/sdc-init-elasticsearch/chef-solo/solo.rb b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/solo.rb new file mode 100644 index 0000000000..06c1af4592 --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/chef-solo/solo.rb @@ -0,0 +1,16 @@ +root = File.absolute_path(File.dirname(__FILE__)) +file_cache_path root +cookbook_path root + '/cookbooks' +json_attribs root + '/solo.json' +checksum_path root + '/checksums' +data_bag_path root + '/data_bags' +environment_path root + '/environments' +file_backup_path root + '/backup' +file_cache_path root + '/cache' +log_level :info +log_location STDOUT +rest_timeout 300 +role_path root + '/roles' +syntax_check_cache_path +umask 0022 +verbose_logging nil diff --git a/sdc-os-chef/sdc-init-elasticsearch/startup.sh b/sdc-os-chef/sdc-init-elasticsearch/startup.sh new file mode 100644 index 0000000000..f705b039ac --- /dev/null +++ b/sdc-os-chef/sdc-init-elasticsearch/startup.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +cd /root/chef-solo/ +chef-solo -c solo.rb -E ${ENVNAME} + +#for debug purposes keeps the docker alive +#while true; do sleep 2; done \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/startup.sh b/sdc-os-chef/sdc-sanity/startup.sh index e4edfc67e6..3a56a302f6 100644 --- a/sdc-os-chef/sdc-sanity/startup.sh +++ b/sdc-os-chef/sdc-sanity/startup.sh @@ -2,19 +2,4 @@ export CHEFNAME=${ENVNAME} cd /root/chef-solo -chef-solo -c solo.rb -E ${CHEFNAME} - -rc=$? - -#if [[ $rc != 0 ]]; then -# echo "Sanity failed !!!" -# exit $rc -#else -# echo "completed successfully :-)" -# exit 0 -#fi - -#while true; do sleep 2; done - -##/docker-entrypoint.sh - +chef-solo -c solo.rb -E ${CHEFNAME} \ No newline at end of file -- cgit 1.2.3-korg