def configure_riemann(): riemann_config_path = '/etc/riemann' ctx.logger.info('Deploying Riemann manager.config...') utils.move( '/tmp/plugins/riemann-controller/riemann_controller/resources/manager.config', # NOQA '{0}/conf.d/manager.config'.format(riemann_config_path)) ctx.logger.info('Deploying Riemann conf...') utils.deploy_blueprint_resource( '{0}/main.clj'.format(CONFIG_PATH), '{0}/main.clj'.format(riemann_config_path), RIEMANN_SERVICE_NAME) # our riemann configuration will (by default) try to read these environment # variables. If they don't exist, it will assume # that they're found at "localhost" # export REST_HOST="" # export RABBITMQ_HOST="" # we inject the management_ip for both of these to Riemann's systemd # config. # These should be potentially different # if the manager and rabbitmq are running on different hosts. utils.systemd.configure(RIEMANN_SERVICE_NAME) utils.clean_var_log_dir(RIEMANN_SERVICE_NAME)
def configure_riemann(): ctx.logger.info('Deploying Riemann conf...') utils.deploy_blueprint_resource( '{0}/main.clj'.format(CONFIG_PATH), '{0}/main.clj'.format(RIEMANN_CONFIG_PATH), SERVICE_NAME) utils.chown( runtime_props['service_user'], runtime_props['service_group'], RIEMANN_CONFIG_PATH ) # our riemann configuration will (by default) try to read these environment # variables. If they don't exist, it will assume # that they're found at "localhost" # export REST_HOST="" # export RABBITMQ_HOST="" # we inject the management_ip for both of these to Riemann's systemd # config. # These should be potentially different # if the manager and rabbitmq are running on different hosts. utils.systemd.configure(SERVICE_NAME) utils.clean_var_log_dir(SERVICE_NAME)
def main(): es_endpoint_ip = ctx.node.properties['es_endpoint_ip'] es_endpoint_port = ctx.node.properties['es_endpoint_port'] if not es_endpoint_ip: es_endpoint_ip = ctx.instance.host_ip _install_elasticsearch() utils.systemd.start('elasticsearch') utils.wait_for_port(es_endpoint_port, es_endpoint_ip) _configure_elasticsearch(host=es_endpoint_ip, port=es_endpoint_port) utils.systemd.stop('elasticsearch') utils.clean_var_log_dir('elasticsearch') else: ctx.logger.info('External Elasticsearch Endpoint provided: ' '{0}:{1}...'.format(es_endpoint_ip, es_endpoint_port)) time.sleep(5) utils.wait_for_port(es_endpoint_port, es_endpoint_ip) ctx.logger.info('Checking if \'cloudify_storage\' ' 'index already exists...') if http_request('http://{0}:{1}/cloudify_storage'.format( es_endpoint_ip, es_endpoint_port), method='HEAD'): utils.error_exit('\'cloudify_storage\' index already exists on ' '{0}, terminating bootstrap...'.format( es_endpoint_ip)) _configure_elasticsearch(host=es_endpoint_ip, port=es_endpoint_port) ctx.instance.runtime_properties['es_endpoint_ip'] = es_endpoint_ip
def main(): es_endpoint_ip = ctx.node.properties['es_endpoint_ip'] es_endpoint_port = ctx.node.properties['es_endpoint_port'] if not es_endpoint_ip: es_endpoint_ip = ctx.instance.host_ip _install_elasticsearch() utils.systemd.start('elasticsearch') utils.wait_for_port(es_endpoint_port, es_endpoint_ip) _configure_elasticsearch(host=es_endpoint_ip, port=es_endpoint_port) utils.systemd.stop('elasticsearch') utils.clean_var_log_dir('elasticsearch') else: ctx.logger.info('External Elasticsearch Endpoint provided: ' '{0}:{1}...'.format(es_endpoint_ip, es_endpoint_port)) time.sleep(5) utils.wait_for_port(es_endpoint_port, es_endpoint_ip) ctx.logger.info('Checking if \'cloudify_storage\' ' 'index already exists...') if http_request('http://{0}:{1}/cloudify_storage'.format( es_endpoint_ip, es_endpoint_port), method='HEAD'): utils.error_exit( '\'cloudify_storage\' index already exists on ' '{0}, terminating bootstrap...'.format(es_endpoint_ip)) _configure_elasticsearch(host=es_endpoint_ip, port=es_endpoint_port) ctx.instance.runtime_properties['es_endpoint_ip'] = es_endpoint_ip
def install_logstash(): logstash_unit_override = '/etc/systemd/system/logstash.service.d' logstash_source_url = ctx_properties['logstash_rpm_source_url'] rabbitmq_username = ctx_properties['rabbitmq_username'] rabbitmq_password = ctx_properties['rabbitmq_password'] logstash_log_path = '/var/log/cloudify/logstash' logstash_conf_path = '/etc/logstash/conf.d' # injected as an input to the script ctx.instance.runtime_properties['es_endpoint_ip'] = \ os.environ.get('ES_ENDPOINT_IP') ctx.instance.runtime_properties['rabbitmq_endpoint_ip'] = \ utils.get_rabbitmq_endpoint_ip( ctx_properties.get('rabbitmq_endpoint_ip')) # Confirm username and password have been supplied for broker before # continuing. # Components other than logstash and riemann have this handled in code. # Note that these are not directly used in this script, but are used by the # deployed resources, hence the check here. if not rabbitmq_username or not rabbitmq_password: utils.error_exit( 'Both rabbitmq_username and rabbitmq_password must be supplied ' 'and at least 1 character long in the manager blueprint inputs.') ctx.logger.info('Installing Logstash...') utils.set_selinux_permissive() utils.copy_notice(LOGSTASH_SERVICE_NAME) utils.yum_install(logstash_source_url, service_name=LOGSTASH_SERVICE_NAME) utils.mkdir(logstash_log_path) utils.chown('logstash', 'logstash', logstash_log_path) ctx.logger.info('Creating systemd unit override...') utils.mkdir(logstash_unit_override) utils.deploy_blueprint_resource( '{0}/restart.conf'.format(CONFIG_PATH), '{0}/restart.conf'.format(logstash_unit_override), LOGSTASH_SERVICE_NAME) ctx.logger.info('Deploying Logstash conf...') utils.deploy_blueprint_resource( '{0}/logstash.conf'.format(CONFIG_PATH), '{0}/logstash.conf'.format(logstash_conf_path), LOGSTASH_SERVICE_NAME) ctx.logger.info('Deploying Logstash sysconfig...') utils.deploy_blueprint_resource('{0}/logstash'.format(CONFIG_PATH), '/etc/sysconfig/logstash', LOGSTASH_SERVICE_NAME) utils.logrotate(LOGSTASH_SERVICE_NAME) utils.sudo(['/sbin/chkconfig', 'logstash', 'on']) utils.clean_var_log_dir(LOGSTASH_SERVICE_NAME)
def install_logstash(): logstash_unit_override = '/etc/systemd/system/logstash.service.d' logstash_source_url = ctx.node.properties['logstash_rpm_source_url'] rabbitmq_username = ctx.node.properties['rabbitmq_username'] rabbitmq_password = ctx.node.properties['rabbitmq_password'] logstash_log_path = '/var/log/cloudify/logstash' logstash_conf_path = '/etc/logstash/conf.d' # injected as an input to the script ctx.instance.runtime_properties['es_endpoint_ip'] = \ os.environ.get('ES_ENDPOINT_IP') ctx.instance.runtime_properties['rabbitmq_endpoint_ip'] = \ utils.get_rabbitmq_endpoint_ip() # Confirm username and password have been supplied for broker before # continuing. # Components other than logstash and riemann have this handled in code. # Note that these are not directly used in this script, but are used by the # deployed resources, hence the check here. if not rabbitmq_username or not rabbitmq_password: utils.error_exit( 'Both rabbitmq_username and rabbitmq_password must be supplied ' 'and at least 1 character long in the manager blueprint inputs.') ctx.logger.info('Installing Logstash...') utils.set_selinux_permissive() utils.copy_notice('logstash') utils.yum_install(logstash_source_url) utils.mkdir(logstash_log_path) utils.chown('logstash', 'logstash', logstash_log_path) ctx.logger.info('Creating systemd unit override...') utils.mkdir(logstash_unit_override) utils.deploy_blueprint_resource( '{0}/restart.conf'.format(CONFIG_PATH), '{0}/restart.conf'.format(logstash_unit_override)) ctx.logger.info('Deploying Logstash conf...') utils.deploy_blueprint_resource( '{0}/logstash.conf'.format(CONFIG_PATH), '{0}/logstash.conf'.format(logstash_conf_path)) ctx.logger.info('Deploying Logstash sysconfig...') utils.deploy_blueprint_resource( '{0}/logstash'.format(CONFIG_PATH), '/etc/sysconfig/logstash') utils.logrotate('logstash') utils.sudo(['/sbin/chkconfig', 'logstash', 'on']) utils.clean_var_log_dir('logstash')
def install_nginx(): nginx_source_url = ctx_properties['nginx_rpm_source_url'] # this is a bit tricky. the rest_service_source_url contains files that # should be deployed in the fileserver. the thing is, that since the # rest service and nginx cannot be distributed between vms right now # anyway, these resources are deployed by the rest service node instead. # rest_service_source_url = \ # ctx.node.properties['rest_service_module_source_url'] nginx_log_path = '/var/log/cloudify/nginx' manager_resources_home = utils.MANAGER_RESOURCES_HOME manager_agents_path = utils.AGENT_ARCHIVES_PATH # TODO: check if can remove these two (should come with the agent package) manager_scripts_path = '{0}/packages/scripts'.format( manager_resources_home) manager_templates_path = '{0}/packages/templates'.format( manager_resources_home) nginx_unit_override = '/etc/systemd/system/nginx.service.d' # this is propagated to the agent retrieval script later on so that it's # not defined twice. ctx.instance.runtime_properties['agent_packages_path'] = \ manager_agents_path # TODO: can we use static (not runtime) attributes for some of these? # how to set them? ctx.instance.runtime_properties['default_rest_service_port'] = '8100' ctx.instance.runtime_properties['internal_rest_service_port'] = '8101' ctx.logger.info('Installing Nginx...') utils.set_selinux_permissive() utils.copy_notice(NGINX_SERVICE_NAME) utils.mkdir(nginx_log_path) utils.mkdir(manager_resources_home) utils.mkdir(manager_agents_path) # TODO: check if can remove these two (should come with the agent package) utils.mkdir(manager_scripts_path) utils.mkdir(manager_templates_path) utils.mkdir(nginx_unit_override) utils.yum_install(nginx_source_url, service_name=NGINX_SERVICE_NAME) ctx.logger.info('Creating systemd unit override...') utils.deploy_blueprint_resource( '{0}/restart.conf'.format(CONFIG_PATH), '{0}/restart.conf'.format(nginx_unit_override), NGINX_SERVICE_NAME) utils.logrotate(NGINX_SERVICE_NAME) utils.clean_var_log_dir(NGINX_SERVICE_NAME)
def install_nginx(): nginx_source_url = ctx.node.properties['nginx_rpm_source_url'] # this is a bit tricky. the rest_service_source_url contains files that # should be deployed in the fileserver. the thing is, that since the # rest service and nginx cannot be distributed between vms right now # anyway, these resources are deployed by the rest service node instead. # rest_service_source_url = \ # ctx.node.properties['rest_service_module_source_url'] nginx_log_path = '/var/log/cloudify/nginx' manager_resources_home = '/opt/manager/resources' manager_agents_path = '{0}/packages/agents'.format(manager_resources_home) # TODO: check if can remove these two (should come with the agent package) manager_scripts_path = '{0}/packages/scripts'.format( manager_resources_home) manager_templates_path = '{0}/packages/templates'.format( manager_resources_home) nginx_unit_override = '/etc/systemd/system/nginx.service.d' # this is propagated to the agent retrieval script later on so that it's # not defined twice. ctx.instance.runtime_properties['agent_packages_path'] = \ manager_agents_path # TODO: can we use static (not runtime) attributes for some of these? # how to set them? ctx.instance.runtime_properties['default_rest_service_port'] = '8100' ctx.instance.runtime_properties['internal_rest_service_port'] = '8101' ctx.logger.info('Installing Nginx...') utils.set_selinux_permissive() utils.copy_notice('nginx') utils.mkdir(nginx_log_path) utils.mkdir(manager_resources_home) utils.mkdir(manager_agents_path) # TODO: check if can remove these two (should come with the agent package) utils.mkdir(manager_scripts_path) utils.mkdir(manager_templates_path) utils.mkdir(nginx_unit_override) utils.yum_install(nginx_source_url) ctx.logger.info('Creating systemd unit override...') utils.deploy_blueprint_resource( '{0}/restart.conf'.format(CONFIG_PATH), '{0}/restart.conf'.format(nginx_unit_override)) utils.logrotate('nginx') utils.clean_var_log_dir('nginx')
def install_nginx(): nginx_source_url = ctx_properties['nginx_rpm_source_url'] # this is a bit tricky. the rest_service_source_url contains files that # should be deployed in the fileserver. the thing is, that since the # rest service and nginx cannot be distributed between vms right now # anyway, these resources are deployed by the rest service node instead. # rest_service_source_url = \ # ctx.node.properties['rest_service_module_source_url'] manager_resources_home = utils.MANAGER_RESOURCES_HOME manager_agents_path = utils.AGENT_ARCHIVES_PATH # TODO: check if can remove these two (should come with the agent package) manager_scripts_path = '{0}/packages/scripts'.format( manager_resources_home) manager_templates_path = '{0}/packages/templates'.format( manager_resources_home) # this is propagated to the agent retrieval script later on so that it's # not defined twice. ctx.instance.runtime_properties['agent_packages_path'] = \ manager_agents_path # TODO: can we use static (not runtime) attributes for some of these? # how to set them? ctx.instance.runtime_properties['default_rest_service_port'] = '8100' ctx.logger.info('Installing Nginx...') utils.set_selinux_permissive() utils.copy_notice(SERVICE_NAME) utils.mkdir(LOG_DIR) utils.mkdir(manager_resources_home) utils.mkdir(manager_agents_path) # TODO: check if can remove these two (should come with the agent package) utils.mkdir(manager_scripts_path) utils.mkdir(manager_templates_path) utils.mkdir(UNIT_OVERRIDE_PATH) utils.yum_install(nginx_source_url, service_name=SERVICE_NAME) ctx.logger.info('Creating systemd unit override...') utils.deploy_blueprint_resource( '{0}/restart.conf'.format(CONFIG_PATH), '{0}/restart.conf'.format(UNIT_OVERRIDE_PATH), SERVICE_NAME) utils.logrotate(SERVICE_NAME) utils.clean_var_log_dir(SERVICE_NAME)
def configure_logstash(): logstash_conf_path = '/etc/logstash/conf.d' runtime_properties = ctx.instance.runtime_properties rabbitmq_username = runtime_properties.get('rabbitmq_username') rabbitmq_password = runtime_properties.get('rabbitmq_password') # Confirm username and password have been supplied for broker before # continuing. # Components other than logstash and riemann have this handled in code. # Note that these are not directly used in this script, but are used by the # deployed resources, hence the check here. if not rabbitmq_username or not rabbitmq_password: ctx.abort_operation( 'Both rabbitmq_username and rabbitmq_password must be supplied ' 'and at least 1 character long in the manager blueprint inputs.') ctx.logger.info('Deploying Logstash configuration...') utils.deploy_blueprint_resource( '{0}/logstash.conf'.format(CONFIG_PATH), '{0}/logstash.conf'.format(logstash_conf_path), LOGSTASH_SERVICE_NAME) # Due to a bug in the handling of configuration files, # configuration files with the same name cannot be deployed. # Since the logrotate config file is called `logstash`, # we change the name of the logstash env vars config file # from logstash to cloudify-logstash to be consistent with # other service env var files. init_file = '/etc/init.d/logstash' utils.replace_in_file( 'sysconfig/\$name', 'sysconfig/cloudify-$name', init_file) utils.chmod('755', init_file) utils.chown('root', 'root', init_file) ctx.logger.debug('Deploying Logstash sysconfig...') utils.deploy_blueprint_resource( '{0}/cloudify-logstash'.format(CONFIG_PATH), '/etc/sysconfig/cloudify-logstash', LOGSTASH_SERVICE_NAME) utils.logrotate(LOGSTASH_SERVICE_NAME) utils.sudo(['/sbin/chkconfig', 'logstash', 'on']) utils.clean_var_log_dir(LOGSTASH_SERVICE_NAME)
def main(): es_endpoint_ip = ctx_properties['es_endpoint_ip'] es_endpoint_port = ctx_properties['es_endpoint_port'] if utils.is_upgrade: dump_upgrade_data() if not es_endpoint_ip: es_endpoint_ip = ctx.instance.host_ip _install_elasticsearch() utils.systemd.restart(ES_SERVICE_NAME, append_prefix=False) utils.wait_for_port(es_endpoint_port, es_endpoint_ip) _configure_elasticsearch(host=es_endpoint_ip, port=es_endpoint_port) _wait_for_shards(es_endpoint_port, es_endpoint_ip) utils.clean_var_log_dir('elasticsearch') else: ctx.logger.info('External Elasticsearch Endpoint provided: ' '{0}:{1}...'.format(es_endpoint_ip, es_endpoint_port)) time.sleep(5) utils.wait_for_port(es_endpoint_port, es_endpoint_ip) ctx.logger.info('Checking if \'cloudify_storage\' ' 'index already exists...') if http_request('http://{0}:{1}/cloudify_storage'.format( es_endpoint_ip, es_endpoint_port), method='HEAD').code == 200: ctx.abort_operation( '\'cloudify_storage\' index already exists on ' '{0}, terminating bootstrap...'.format(es_endpoint_ip)) _configure_elasticsearch(host=es_endpoint_ip, port=es_endpoint_port) if utils.is_upgrade or utils.is_rollback: restore_upgrade_data(es_endpoint_ip, es_endpoint_port) if not es_endpoint_port: utils.systemd.stop(ES_SERVICE_NAME, append_prefix=False) ctx.instance.runtime_properties['es_endpoint_ip'] = es_endpoint_ip
def main(): es_endpoint_ip = ctx_properties['es_endpoint_ip'] es_endpoint_port = ctx_properties['es_endpoint_port'] if utils.is_upgrade: dump_upgrade_data() if not es_endpoint_ip: es_endpoint_ip = ctx.instance.host_ip _install_elasticsearch() utils.systemd.restart(ES_SERVICE_NAME, append_prefix=False) utils.wait_for_port(es_endpoint_port, es_endpoint_ip) _configure_elasticsearch(host=es_endpoint_ip, port=es_endpoint_port) _wait_for_shards(es_endpoint_port, es_endpoint_ip) utils.clean_var_log_dir('elasticsearch') else: ctx.logger.info('External Elasticsearch Endpoint provided: ' '{0}:{1}...'.format(es_endpoint_ip, es_endpoint_port)) time.sleep(5) utils.wait_for_port(es_endpoint_port, es_endpoint_ip) ctx.logger.info('Checking if \'cloudify_storage\' ' 'index already exists...') if http_request('http://{0}:{1}/cloudify_storage'.format( es_endpoint_ip, es_endpoint_port), method='HEAD').code == 200: ctx.abort_operation('\'cloudify_storage\' index already exists on ' '{0}, terminating bootstrap...'.format( es_endpoint_ip)) _configure_elasticsearch(host=es_endpoint_ip, port=es_endpoint_port) if utils.is_upgrade or utils.is_rollback: restore_upgrade_data(es_endpoint_ip, es_endpoint_port) if not es_endpoint_port: utils.systemd.stop(ES_SERVICE_NAME, append_prefix=False) ctx.instance.runtime_properties['es_endpoint_ip'] = es_endpoint_ip
def install_nginx(): nginx_source_url = ctx_properties['nginx_rpm_source_url'] # this is a bit tricky. the rest_service_source_url contains files that # should be deployed in the fileserver. the thing is, that since the # rest service and nginx cannot be distributed between vms right now # anyway, these resources are deployed by the rest service node instead. # rest_service_source_url = \ # ctx.node.properties['rest_service_module_source_url'] nginx_log_path = '/var/log/cloudify/nginx' manager_resources_home = utils.MANAGER_RESOURCES_HOME manager_agents_path = utils.AGENT_ARCHIVES_PATH # TODO: check if can remove these two (should come with the agent package) manager_scripts_path = '{0}/packages/scripts'.format( manager_resources_home) manager_templates_path = '{0}/packages/templates'.format( manager_resources_home) nginx_unit_override = '/etc/systemd/system/nginx.service.d' # this is propagated to the agent retrieval script later on so that it's # not defined twice. ctx.instance.runtime_properties['agent_packages_path'] = \ manager_agents_path # TODO: can we use static (not runtime) attributes for some of these? # how to set them? ctx.instance.runtime_properties['default_rest_service_port'] = '8100' ctx.instance.runtime_properties['internal_rest_service_port'] = '8101' if utils.is_upgrade: ctx.logger.info('Nginx is in upgrade state.') if os.path.exists(manager_agents_path): backup_agent_resources(manager_agents_path) ctx.logger.info('Removing existing agents from {0}' .format(manager_agents_path)) utils.remove(manager_agents_path) if os.path.exists(manager_scripts_path): ctx.logger.info('Removing agent scripts from {0}' .format(manager_scripts_path)) utils.remove(manager_scripts_path) if os.path.exists(manager_templates_path): ctx.logger.info('Removing agent templates from {0}' .format(manager_templates_path)) utils.remove(manager_templates_path) if os.path.exists(nginx_unit_override): ctx.logger.info('Removing nginx systemd file from {0}' .format(nginx_unit_override)) utils.remove(nginx_unit_override) ctx.logger.info('Installing Nginx...') utils.set_selinux_permissive() utils.copy_notice(NGINX_SERVICE_NAME) utils.mkdir(nginx_log_path) utils.mkdir(manager_resources_home) utils.mkdir(manager_agents_path) # TODO: check if can remove these two (should come with the agent package) utils.mkdir(manager_scripts_path) utils.mkdir(manager_templates_path) utils.mkdir(nginx_unit_override) utils.yum_install(nginx_source_url, service_name=NGINX_SERVICE_NAME) ctx.logger.info('Creating systemd unit override...') utils.deploy_blueprint_resource( '{0}/restart.conf'.format(CONFIG_PATH), '{0}/restart.conf'.format(nginx_unit_override), NGINX_SERVICE_NAME) utils.logrotate(NGINX_SERVICE_NAME) utils.clean_var_log_dir(NGINX_SERVICE_NAME)
def install_riemann(): langohr_source_url = ctx_properties['langohr_jar_source_url'] daemonize_source_url = ctx_properties['daemonize_rpm_source_url'] riemann_source_url = ctx_properties['riemann_rpm_source_url'] # Needed for Riemann's config cloudify_resources_url = ctx_properties['cloudify_resources_url'] rabbitmq_username = ctx_properties['rabbitmq_username'] rabbitmq_password = ctx_properties['rabbitmq_password'] riemann_config_path = '/etc/riemann' riemann_log_path = '/var/log/cloudify/riemann' langohr_home = '/opt/lib' extra_classpath = '{0}/langohr.jar'.format(langohr_home) # Confirm username and password have been supplied for broker before # continuing. # Components other than logstash and riemann have this handled in code. # Note that these are not directly used in this script, but are used by the # deployed resources, hence the check here. if not rabbitmq_username or not rabbitmq_password: ctx.abort_operation( 'Both rabbitmq_username and rabbitmq_password must be supplied ' 'and at least 1 character long in the manager blueprint inputs.') rabbit_props = utils.ctx_factory.get('rabbitmq') ctx.instance.runtime_properties['rabbitmq_endpoint_ip'] = \ utils.get_rabbitmq_endpoint_ip( rabbit_props.get('rabbitmq_endpoint_ip')) ctx.instance.runtime_properties['rabbitmq_username'] = \ rabbit_props.get('rabbitmq_username') ctx.instance.runtime_properties['rabbitmq_password'] = \ rabbit_props.get('rabbitmq_password') ctx.logger.info('Installing Riemann...') utils.set_selinux_permissive() utils.copy_notice(RIEMANN_SERVICE_NAME) utils.mkdir(riemann_log_path) utils.mkdir(langohr_home) utils.mkdir(riemann_config_path) utils.mkdir('{0}/conf.d'.format(riemann_config_path)) langohr = utils.download_cloudify_resource(langohr_source_url, RIEMANN_SERVICE_NAME) utils.sudo(['cp', langohr, extra_classpath]) ctx.logger.info('Applying Langohr permissions...') utils.sudo(['chmod', '644', extra_classpath]) utils.yum_install(daemonize_source_url, service_name=RIEMANN_SERVICE_NAME) utils.yum_install(riemann_source_url, service_name=RIEMANN_SERVICE_NAME) utils.logrotate(RIEMANN_SERVICE_NAME) ctx.logger.info('Downloading cloudify-manager Repository...') manager_repo = utils.download_cloudify_resource(cloudify_resources_url, RIEMANN_SERVICE_NAME) ctx.logger.info('Extracting Manager Repository...') utils.untar(manager_repo, '/tmp') ctx.logger.info('Deploying Riemann manager.config...') utils.move( '/tmp/plugins/riemann-controller/riemann_controller/resources/manager.config', # NOQA '{0}/conf.d/manager.config'.format(riemann_config_path)) ctx.logger.info('Deploying Riemann conf...') utils.deploy_blueprint_resource( '{0}/main.clj'.format(CONFIG_PATH), '{0}/main.clj'.format(riemann_config_path), RIEMANN_SERVICE_NAME) # our riemann configuration will (by default) try to read these environment # variables. If they don't exist, it will assume # that they're found at "localhost" # export MANAGEMENT_IP="" # export RABBITMQ_HOST="" # we inject the management_ip for both of these to Riemann's systemd # config. # These should be potentially different # if the manager and rabbitmq are running on different hosts. utils.systemd.configure(RIEMANN_SERVICE_NAME) utils.clean_var_log_dir(RIEMANN_SERVICE_NAME)
def install_logstash(): logstash_unit_override = '/etc/systemd/system/logstash.service.d' logstash_source_url = ctx_properties['logstash_rpm_source_url'] rabbitmq_username = ctx_properties['rabbitmq_username'] rabbitmq_password = ctx_properties['rabbitmq_password'] logstash_log_path = '/var/log/cloudify/logstash' logstash_conf_path = '/etc/logstash/conf.d' # injected as an input to the script ctx.instance.runtime_properties['es_endpoint_ip'] = \ os.environ['ES_ENDPOINT_IP'] elasticsearch_props = utils.ctx_factory.get('elasticsearch') ctx.instance.runtime_properties['es_endpoint_port'] = \ elasticsearch_props['es_endpoint_port'] rabbit_props = utils.ctx_factory.get('rabbitmq') ctx.instance.runtime_properties['rabbitmq_endpoint_ip'] = \ utils.get_rabbitmq_endpoint_ip( rabbit_props.get('rabbitmq_endpoint_ip')) ctx.instance.runtime_properties['rabbitmq_username'] = \ rabbit_props['rabbitmq_username'] ctx.instance.runtime_properties['rabbitmq_password'] = \ rabbit_props['rabbitmq_password'] # Confirm username and password have been supplied for broker before # continuing. # Components other than logstash and riemann have this handled in code. # Note that these are not directly used in this script, but are used by the # deployed resources, hence the check here. if not rabbitmq_username or not rabbitmq_password: ctx.abort_operation( 'Both rabbitmq_username and rabbitmq_password must be supplied ' 'and at least 1 character long in the manager blueprint inputs.') ctx.logger.info('Installing Logstash...') utils.set_selinux_permissive() utils.copy_notice(LOGSTASH_SERVICE_NAME) utils.yum_install(logstash_source_url, service_name=LOGSTASH_SERVICE_NAME) utils.mkdir(logstash_log_path) utils.chown('logstash', 'logstash', logstash_log_path) ctx.logger.info('Creating systemd unit override...') utils.mkdir(logstash_unit_override) utils.deploy_blueprint_resource( '{0}/restart.conf'.format(CONFIG_PATH), '{0}/restart.conf'.format(logstash_unit_override), LOGSTASH_SERVICE_NAME) ctx.logger.info('Deploying Logstash conf...') utils.deploy_blueprint_resource( '{0}/logstash.conf'.format(CONFIG_PATH), '{0}/logstash.conf'.format(logstash_conf_path), LOGSTASH_SERVICE_NAME) # Due to a bug in the handling of configuration files, # configuration files with the same name cannot be deployed. # Since the logrotate config file is called `logstash`, # we change the name of the logstash env vars config file # from logstash to cloudify-logstash to be consistent with # other service env var files. init_file = '/etc/init.d/logstash' utils.replace_in_file( 'sysconfig/\$name', 'sysconfig/cloudify-$name', init_file) utils.chmod('755', init_file) utils.chown('root', 'root', init_file) ctx.logger.info('Deploying Logstash sysconfig...') utils.deploy_blueprint_resource( '{0}/cloudify-logstash'.format(CONFIG_PATH), '/etc/sysconfig/cloudify-logstash', LOGSTASH_SERVICE_NAME) utils.logrotate(LOGSTASH_SERVICE_NAME) utils.sudo(['/sbin/chkconfig', 'logstash', 'on']) utils.clean_var_log_dir(LOGSTASH_SERVICE_NAME)
def install_riemann(): langohr_source_url = ctx_properties['langohr_jar_source_url'] daemonize_source_url = ctx_properties['daemonize_rpm_source_url'] riemann_source_url = ctx_properties['riemann_rpm_source_url'] # Needed for Riemann's config cloudify_resources_url = ctx_properties['cloudify_resources_url'] rabbitmq_username = ctx_properties['rabbitmq_username'] rabbitmq_password = ctx_properties['rabbitmq_password'] riemann_config_path = '/etc/riemann' riemann_log_path = '/var/log/cloudify/riemann' langohr_home = '/opt/lib' extra_classpath = '{0}/langohr.jar'.format(langohr_home) # Confirm username and password have been supplied for broker before # continuing. # Components other than logstash and riemann have this handled in code. # Note that these are not directly used in this script, but are used by the # deployed resources, hence the check here. if not rabbitmq_username or not rabbitmq_password: ctx.abort_operation( 'Both rabbitmq_username and rabbitmq_password must be supplied ' 'and at least 1 character long in the manager blueprint inputs.') rabbit_props = utils.ctx_factory.get('rabbitmq') ctx.instance.runtime_properties['rabbitmq_endpoint_ip'] = \ utils.get_rabbitmq_endpoint_ip( rabbit_props.get('rabbitmq_endpoint_ip')) ctx.instance.runtime_properties['rabbitmq_username'] = \ rabbit_props.get('rabbitmq_username') ctx.instance.runtime_properties['rabbitmq_password'] = \ rabbit_props.get('rabbitmq_password') ctx.logger.info('Installing Riemann...') utils.set_selinux_permissive() utils.copy_notice(RIEMANN_SERVICE_NAME) utils.mkdir(riemann_log_path) utils.mkdir(langohr_home) utils.mkdir(riemann_config_path) utils.mkdir('{0}/conf.d'.format(riemann_config_path)) langohr = utils.download_cloudify_resource(langohr_source_url, RIEMANN_SERVICE_NAME) utils.sudo(['cp', langohr, extra_classpath]) ctx.logger.info('Applying Langohr permissions...') utils.sudo(['chmod', '644', extra_classpath]) utils.yum_install(daemonize_source_url, service_name=RIEMANN_SERVICE_NAME) utils.yum_install(riemann_source_url, service_name=RIEMANN_SERVICE_NAME) utils.logrotate(RIEMANN_SERVICE_NAME) ctx.logger.info('Downloading cloudify-manager Repository...') manager_repo = utils.download_cloudify_resource(cloudify_resources_url, RIEMANN_SERVICE_NAME) ctx.logger.info('Extracting Manager Repository...') utils.untar(manager_repo, '/tmp') ctx.logger.info('Deploying Riemann manager.config...') utils.move( '/tmp/plugins/riemann-controller/riemann_controller/resources/manager.config', # NOQA '{0}/conf.d/manager.config'.format(riemann_config_path)) ctx.logger.info('Deploying Riemann conf...') utils.deploy_blueprint_resource('{0}/main.clj'.format(CONFIG_PATH), '{0}/main.clj'.format(riemann_config_path), RIEMANN_SERVICE_NAME) # our riemann configuration will (by default) try to read these environment # variables. If they don't exist, it will assume # that they're found at "localhost" # export MANAGEMENT_IP="" # export RABBITMQ_HOST="" # we inject the management_ip for both of these to Riemann's systemd # config. # These should be potentially different # if the manager and rabbitmq are running on different hosts. utils.systemd.configure(RIEMANN_SERVICE_NAME) utils.clean_var_log_dir(RIEMANN_SERVICE_NAME)
def install_logstash(): logstash_unit_override = '/etc/systemd/system/logstash.service.d' logstash_source_url = ctx_properties['logstash_rpm_source_url'] rabbitmq_username = ctx_properties['rabbitmq_username'] rabbitmq_password = ctx_properties['rabbitmq_password'] logstash_log_path = '/var/log/cloudify/logstash' logstash_conf_path = '/etc/logstash/conf.d' # injected as an input to the script ctx.instance.runtime_properties['es_endpoint_ip'] = \ os.environ['ES_ENDPOINT_IP'] elasticsearch_props = utils.ctx_factory.get('elasticsearch') ctx.instance.runtime_properties['es_endpoint_port'] = \ elasticsearch_props['es_endpoint_port'] rabbit_props = utils.ctx_factory.get('rabbitmq') ctx.instance.runtime_properties['rabbitmq_endpoint_ip'] = \ utils.get_rabbitmq_endpoint_ip( rabbit_props.get('rabbitmq_endpoint_ip')) ctx.instance.runtime_properties['rabbitmq_username'] = \ rabbit_props['rabbitmq_username'] ctx.instance.runtime_properties['rabbitmq_password'] = \ rabbit_props['rabbitmq_password'] # Confirm username and password have been supplied for broker before # continuing. # Components other than logstash and riemann have this handled in code. # Note that these are not directly used in this script, but are used by the # deployed resources, hence the check here. if not rabbitmq_username or not rabbitmq_password: ctx.abort_operation( 'Both rabbitmq_username and rabbitmq_password must be supplied ' 'and at least 1 character long in the manager blueprint inputs.') ctx.logger.info('Installing Logstash...') utils.set_selinux_permissive() utils.copy_notice(LOGSTASH_SERVICE_NAME) utils.yum_install(logstash_source_url, service_name=LOGSTASH_SERVICE_NAME) utils.mkdir(logstash_log_path) utils.chown('logstash', 'logstash', logstash_log_path) ctx.logger.debug('Creating systemd unit override...') utils.mkdir(logstash_unit_override) utils.deploy_blueprint_resource( '{0}/restart.conf'.format(CONFIG_PATH), '{0}/restart.conf'.format(logstash_unit_override), LOGSTASH_SERVICE_NAME) ctx.logger.info('Deploying Logstash configuration...') utils.deploy_blueprint_resource( '{0}/logstash.conf'.format(CONFIG_PATH), '{0}/logstash.conf'.format(logstash_conf_path), LOGSTASH_SERVICE_NAME) # Due to a bug in the handling of configuration files, # configuration files with the same name cannot be deployed. # Since the logrotate config file is called `logstash`, # we change the name of the logstash env vars config file # from logstash to cloudify-logstash to be consistent with # other service env var files. init_file = '/etc/init.d/logstash' utils.replace_in_file('sysconfig/\$name', 'sysconfig/cloudify-$name', init_file) utils.chmod('755', init_file) utils.chown('root', 'root', init_file) ctx.logger.debug('Deploying Logstash sysconfig...') utils.deploy_blueprint_resource( '{0}/cloudify-logstash'.format(CONFIG_PATH), '/etc/sysconfig/cloudify-logstash', LOGSTASH_SERVICE_NAME) utils.logrotate(LOGSTASH_SERVICE_NAME) utils.sudo(['/sbin/chkconfig', 'logstash', 'on']) utils.clean_var_log_dir(LOGSTASH_SERVICE_NAME)