diff --git a/README.md b/README.md new file mode 100644 index 0000000..d149e57 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# emailnotifyd +Plugin to install emailnotifyd component + diff --git a/deployment_scripts/puppet/manifests/emailnotifyd.pp b/deployment_scripts/puppet/manifests/emailnotifyd.pp new file mode 100644 index 0000000..b48cb18 --- /dev/null +++ b/deployment_scripts/puppet/manifests/emailnotifyd.pp @@ -0,0 +1,3 @@ +notice('MODULAR: emailnotifyd/emailnotifyd.pp') + +include emailnotifyd diff --git a/deployment_scripts/puppet/manifests/haproxy.pp b/deployment_scripts/puppet/manifests/haproxy.pp new file mode 100644 index 0000000..70c160a --- /dev/null +++ b/deployment_scripts/puppet/manifests/haproxy.pp @@ -0,0 +1,33 @@ +notice('fuel-plugin-emailnotifyd: haproxy.pp') + +$plugin_hash = hiera('fuel-plugin-emailnotifyd') +$emailnotifyd_vip = $plugin_hash['emailnotifyd_vip'] +$emailnotifyd_port = $plugin_hash['emailnotifyd_port'] +$hiera_dir = '/etc/hiera/plugins' +$plugin_name = 'fuel-plugin-emailnotifyd' +$plugin_yaml = "${plugin_name}.yaml" +$nodes_ips = hiera('emailnotifyd_nodes') +$nodes_names = prefix(range(1, size($nodes_ips)), 'server_') + +Openstack::Ha::Haproxy_service { + internal_virtual_ip => $internal_virtual_ip, + server_names => $nodes_names, + ipaddresses => $ipaddresses, + public => true, + public_ssl => false, + internal => false, + public_virtual_ip => $emailnotifyd_vip, +} + +openstack::ha::haproxy_service { 'emailnotifyd': + order => '777', + listen_port => $emailnotifyd_port, + ipaddresses => $nodes_ips, + balancermember_port => $emailnotifyd_port, + balancermember_options => 'check inter 10s fastinter 2s downinter 3s rise 3 fall 3', + haproxy_config_options => { + 'option' => ['httplog', 'http-keep-alive', 'prefer-last-server', 'dontlog-normal'], + 'balance' => 'roundrobin', + 'mode' => 'http', + } +} diff --git a/deployment_scripts/puppet/manifests/hiera_override.pp b/deployment_scripts/puppet/manifests/hiera_override.pp new file mode 100644 index 0000000..28d3b73 --- /dev/null +++ b/deployment_scripts/puppet/manifests/hiera_override.pp @@ -0,0 +1,43 @@ +notice('fuel-plugin-emailnotifyd: hiera_override.pp') +$plugin_hash = hiera('fuel-plugin-emailnotifyd') +$emailnotifyd_vip = $plugin_hash['emailnotifyd_vip'] +$hiera_dir = '/etc/hiera/plugins' +$plugin_name = 'fuel-plugin-emailnotifyd' +$plugin_yaml = "${plugin_name}.yaml" +$network_scheme = hiera_hash('network_scheme') +$network_metadata = hiera_hash('network_metadata') +prepare_network_config($network_scheme) +$emailnotifyd_nodes = get_nodes_hash_by_roles($network_metadata, ['emailnotifyd']) +$nodes_array = values($emailnotifyd_nodes) +$emailnotifyd_nodes_map = get_node_to_ipaddr_map_by_network_role($emailnotifyd_nodes, 'emailnotifyd_public_vip') +$ip_nodes =sort(values($emailnotifyd_nodes_map)) + +$calculated_content = inline_template(' +emailnotifyd_nodes: +<% @ip_nodes.each do |x| -%> + - "<%= x %>" +<% end -%> + +vip__emailnotifyd: $emailnotifyd_vip + +network_metadata: + vips: + emailnotifyd: + ipaddr: <%= @emailnotifyd_vip%> + is_user_defined: false + namespace: haproxy + network_role: kibana + node_roles: + - Emailnotifyd + vendor_specific: null +') + + file { "${hiera_dir}/${plugin_yaml}": + ensure => file, + content => "${calculated_content}", + } + + package { 'ruby-deep-merge': + ensure => 'installed', + } + diff --git a/deployment_scripts/puppet/manifests/hosts.pp b/deployment_scripts/puppet/manifests/hosts.pp new file mode 100644 index 0000000..50f7c59 --- /dev/null +++ b/deployment_scripts/puppet/manifests/hosts.pp @@ -0,0 +1,18 @@ +notice('fp-emailnotifyd: hosts.pp') +$network_metadata = hiera_hash('network_metadata') +$host_resources = network_metadata_to_hosts($network_metadata,'ex','') +$host_keys=keys($host_resources) + +define updateHostsfile { +$network_metadata = hiera_hash('network_metadata') +$host_resources = network_metadata_to_hosts($network_metadata,'ex','') +$node_hash=$host_resources[$name] +$node_values=values($node_hash) +$node_name=$node_values[1] +$node_ip=$node_values[0] +file_line {"$name": + path => "/etc/hosts", + line => "$node_ip $name $node_name", +} +} +updateHostsfile{$host_keys:} diff --git a/deployment_scripts/puppet/manifests/wsgi_configure.pp b/deployment_scripts/puppet/manifests/wsgi_configure.pp new file mode 100644 index 0000000..5b7ff71 --- /dev/null +++ b/deployment_scripts/puppet/manifests/wsgi_configure.pp @@ -0,0 +1,41 @@ +notice('fp-emailnotifyd: wsgi_configure') +Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' } +file_line {"delete default port": + path => '/etc/apache2/sites-enabled/wsgi-emailnotifyd.conf', + line => "Listen 10088", + ensure => absent, +} +file_line {"replace default virtual host": + ensure => present, + path => '/etc/apache2/sites-enabled/wsgi-emailnotifyd.conf', + line => "", + match => '^', +} +file_line {"adding ServerName": + ensure => present, + path => '/etc/apache2/sites-enabled/wsgi-emailnotifyd.conf', + line => " ServerName $fqdn", + after => "^.*", +} +exec {"removing Locations": + command => "sed -i -e '/.*Location.*/d' -e '/.*Require all granted.*/d' /etc/apache2/sites-enabled/wsgi-emailnotifyd.conf", + path => '/bin/' +} +file_line {"adding port to apache": + ensure => present, + path => '/etc/apache2/ports.conf', + line => "Listen $ipaddress:80", +} +file_line {"removing default 80 port from apache": + ensure => absent, + path => '/etc/apache2/ports.conf', + line => "Listen 80", +} +exec { "Restart apache if present": + command => "service apache2 restart", + onlyif => "test -f /etc/init.d/apache2", + } + +File_line['delete default port'] -> File_line['replace default virtual host'] -> +File_line['adding ServerName'] -> Exec['removing Locations'] -> +File_line['adding port to apache'] -> File_line['removing default 80 port from apache']->Exec['Restart apache if present'] diff --git a/deployment_scripts/puppet/modules/emailnotifyd/manifests/init.pp b/deployment_scripts/puppet/modules/emailnotifyd/manifests/init.pp new file mode 100644 index 0000000..f041459 --- /dev/null +++ b/deployment_scripts/puppet/modules/emailnotifyd/manifests/init.pp @@ -0,0 +1,31 @@ +class emailnotifyd { + + Exec { path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' } + notice('MODULAR: emailnotifyd/init.pp') + + package { 'emailnotifyd': + ensure => 'latest', + } + package { 'libapache2-mod-wsgi': + ensure => 'latest', + } + + $plugin_hash = hiera('fuel-plugin-emailnotifyd') + $cc_checkbox = pick($plugin_hash['cc_checkbox']) + $subject = pick($plugin_hash['subject'], 'VM {vmname} feels bad') + $body = pick($plugin_hash['body'], 'Alarm') + $host = pick($plugin_hash['host'], '') + $user = pick($plugin_hash['user'], '') + $port = pick($plugin_hash['port'], '') + $passwd = pick($plugin_hash['passwd'], '') + $from_addr = pick($plugin_hash['from_addr'], 'default@domain.com') + if cc_checkbox == true { + $cc_addr = pick($plugin_hash['cc_addr'], '') + } + + file { '/etc/emailnotifyd/emailnotifyd.conf': + content => template('emailnotifyd/emailnotifyd.conf.erb') + } + + Package['libapache2-mod-wsgi'] -> Package['emailnotifyd'] -> File['/etc/emailnotifyd/emailnotifyd.conf'] +} diff --git a/deployment_scripts/puppet/modules/emailnotifyd/templates/emailnotifyd.conf.erb b/deployment_scripts/puppet/modules/emailnotifyd/templates/emailnotifyd.conf.erb new file mode 100644 index 0000000..ae52bab --- /dev/null +++ b/deployment_scripts/puppet/modules/emailnotifyd/templates/emailnotifyd.conf.erb @@ -0,0 +1,162 @@ +[DEFAULT] + +# +# From oslo.log +# + +# If set to true, the logging level will be set to DEBUG instead of the default +# INFO level. (boolean value) +# Note: This option can be changed without restarting. +#debug = false + +# DEPRECATED: If set to false, the logging level will be set to WARNING instead +# of the default INFO level. (boolean value) +# This option is deprecated for removal. +# Its value may be silently ignored in the future. +#verbose = true + +# The name of a logging configuration file. This file is appended to any +# existing logging configuration files. For details about logging configuration +# files, see the Python logging module documentation. Note that when logging +# configuration files are used then all logging configuration is set in the +# configuration file and other logging configuration options are ignored (for +# example, logging_context_format_string). (string value) +# Note: This option can be changed without restarting. +# Deprecated group/name - [DEFAULT]/log_config +#log_config_append = + +# Defines the format string for %%(asctime)s in log records. Default: +# %(default)s . This option is ignored if log_config_append is set. (string +# value) +#log_date_format = %Y-%m-%d %H:%M:%S + +# (Optional) Name of log file to send logging output to. If no default is set, +# logging will go to stderr as defined by use_stderr. This option is ignored if +# log_config_append is set. (string value) +# Deprecated group/name - [DEFAULT]/logfile +#log_file = + +# (Optional) The base directory used for relative log_file paths. This option +# is ignored if log_config_append is set. (string value) +# Deprecated group/name - [DEFAULT]/logdir +#log_dir = + +# Uses logging handler designed to watch file system. When log file is moved or +# removed this handler will open a new log file with specified path +# instantaneously. It makes sense only if log_file option is specified and +# Linux platform is used. This option is ignored if log_config_append is set. +# (boolean value) +#watch_log_file = false + +# Use syslog for logging. Existing syslog format is DEPRECATED and will be +# changed later to honor RFC5424. This option is ignored if log_config_append +# is set. (boolean value) +#use_syslog = false + +# Syslog facility to receive log lines. This option is ignored if +# log_config_append is set. (string value) +#syslog_log_facility = LOG_USER + +# Log output to standard error. This option is ignored if log_config_append is +# set. (boolean value) +#use_stderr = false + +# Format string to use for log messages with context. (string value) +#logging_context_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s + +# Format string to use for log messages when context is undefined. (string +# value) +#logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s + +# Additional data to append to log message when logging level for the message +# is DEBUG. (string value) +#logging_debug_format_suffix = %(funcName)s %(pathname)s:%(lineno)d + +# Prefix each line of exception output with this format. (string value) +#logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d ERROR %(name)s %(instance)s + +# Defines the format string for %(user_identity)s that is used in +# logging_context_format_string. (string value) +#logging_user_identity_format = %(user)s %(tenant)s %(domain)s %(user_domain)s %(project_domain)s + +# List of package logging levels in logger=LEVEL pairs. This option is ignored +# if log_config_append is set. (list value) +#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN,taskflow=WARN,keystoneauth=WARN,oslo.cache=INFO,dogpile.core.dogpile=INFO + +# Enables or disables publication of error events. (boolean value) +#publish_errors = false + +# The format for an instance that is passed with the log message. (string +# value) +#instance_format = "[instance: %(uuid)s] " + +# The format for an instance UUID that is passed with the log message. (string +# value) +#instance_uuid_format = "[instance: %(uuid)s] " + +# Interval, number of seconds, of log rate limiting. (integer value) +#rate_limit_interval = 0 + +# Maximum number of logged messages per rate_limit_interval. (integer value) +#rate_limit_burst = 0 + +# Log level name used by rate limiting: CRITICAL, ERROR, INFO, WARNING, DEBUG +# or empty string. Logs with level greater or equal to rate_limit_except_level +# are not filtered. An empty string means that all levels are filtered. (string +# value) +#rate_limit_except_level = CRITICAL + +# Enables or disables fatal status of deprecations. (boolean value) +#fatal_deprecations = false + + +[message] + +# +# From emailnotifyd +# + +# Subject line template (string value) +subject = <%= @subject %> + +# Body template (string value) +body = <%= @body %> + + +[paste_deploy] + +# +# From emailnotifyd +# + +# Name of the paste configuration file that defines the available pipelines. +# (string value) +#config_file = emailnotify-paste.ini + + +[smtp] + +# +# From emailnotifyd +# + +# SMTP server hostname (string value) +host = <%= @host %> + +# SMTP server port (integer value) +port = <%= @port %> + +# SMTP server user (string value) +user = <%= @user %> + +# STMP server password (string value) +passwd = <%= @passwd %> + +# Address to use for the From field (string value) +from_addr = <%= @from_addr %> + +# Optional address for CC field (string value) +cc_addr = <%= @cc_addr %> + +# Whether to issue the starttls command (boolean value) +#starttls = true \ No newline at end of file diff --git a/deployment_tasks.yaml b/deployment_tasks.yaml new file mode 100644 index 0000000..1ae71a6 --- /dev/null +++ b/deployment_tasks.yaml @@ -0,0 +1,66 @@ +- id: fp-emailnotifyd-hiera + role: "emailnotifyd" + type: puppet + version: 2.0.0 + requires: [post_deployment_start] + required_for: ['fp-emailnotifyd-vip'] + parameters: + puppet_manifest: "puppet/manifests/hiera_override.pp" + puppet_modules: puppet/modules:/etc/puppet/modules + timeout: 120 + reexecute_on: + - deploy_changes +- id: fp-emailnotifyd-hosts + role: "emailnotifyd" + type: puppet + version: 2.0.0 + requires: [post_deployment_start] + required_for: ['fp-emailnotifyd-vip'] + parameters: + puppet_manifest: "puppet/manifests/hosts.pp" + puppet_modules: puppet/modules:/etc/puppet/modules + timeout: 120 + reexecute_on: + - deploy_changes +- id: fp-emailnotifyd-install + role: "emailnotifyd" + type: puppet + version: 2.0.0 + required_for: [post_deployment_end] + requires: [fp-emailnotifyd-hiera] + parameters: + puppet_manifest: "puppet/manifests/emailnotifyd.pp" + puppet_modules: "puppet/modules:/etc/puppet/modules" + timeout: 1200 +- id: fp-emailnotifyd-wsgi-configure + role: "emailnotifyd" + type: puppet + version: 2.0.0 + required_for: [post_deployment_end] + requires: [fp-emailnotifyd-hiera,fp-emailnotifyd-install] + parameters: + puppet_manifest: "puppet/manifests/wsgi_configure.pp" + puppet_modules: "puppet/modules:/etc/puppet/modules" + timeout: 1200 +- id: fp-emailnotifyd-vip + role: "emailnotifyd" + type: puppet + version: 2.0.0 + requires: [fp-emailnotifyd-install] + required_for: [post_deployment_end] + parameters: + puppet_manifest: "/etc/puppet/modules/osnailyfacter/modular/virtual_ips/virtual_ips.pp" + puppet_modules: /etc/puppet/modules + timeout: 3600 +- id: fp-emailnotifyd-haproxy + role: "emailnotifyd" + type: puppet + version: 2.0.0 + requires: [fp-emailnotifyd-vip] + required_for: [post_deployment_end] + parameters: + puppet_manifest: "puppet/manifests/haproxy.pp" + puppet_modules: puppet/modules:/etc/puppet/modules + timeout: 120 + reexecute_on: + - deploy_changes diff --git a/environment_config.yaml b/environment_config.yaml new file mode 100644 index 0000000..8b165f1 --- /dev/null +++ b/environment_config.yaml @@ -0,0 +1,62 @@ +attributes: + metadata: + label: "Install emailnotifyd" + weight: 12 + emailnotifyd_vip: + type: "text" + weight: 13 + value: "xx.xx.xx.xx" + label: "emailnotify vip" + emailnotifyd_port: + type: "text" + weight: 14 + value: "80" + label: "emailnotify port" + subject: + type: "text" + weight: 20 + value: "VM feels bad" + label: "Subject" + body: + type: "text" + weight: 21 + value: "Alarm" + label: "Body" + host: + type: "text" + weight: 22 + value: "" + label: "Host" + port: + type: "text" + weight: 23 + value: "25" + label: "Smtp Port" + user: + type: "text" + weight: 24 + value: "" + label: "User" + passwd: + type: "password" + weight: 25 + value: "" + label: "Password" + from_addr: + type: "text" + weight: 26 + value: "default@domain.com" + label: "From addr" + cc_checkbox: + type: "checkbox" + weight: 27 + label: "(optional) CC address" + value: false + cc_addr: + type: "text" + weight: 28 + value: "" + label: "CC addr" + restrictions: + - condition: "settings:fuel-plugin-emailnotifyd.cc_checkbox.value == false" + action: disable diff --git a/metadata.yaml b/metadata.yaml new file mode 100644 index 0000000..1ae0abd --- /dev/null +++ b/metadata.yaml @@ -0,0 +1,21 @@ +name: fuel-plugin-emailnotifyd +title: Install emailnotifyd +version: '1.2.2' +description: Installs emailnotifyd component +fuel_version: ['9.0'] +licenses: ['Some'] +licenses: ['Apache License, Version 2.0'] +homepage: https://github.com/sbrf-clouddev/fuel-plugin-emailnotifyd +authors: + - Ilya Popov +groups: [network] +is_hotpluggable: true + +releases: + - os: ubuntu + version: mitaka-9.0 + mode: ['ha'] + deployment_scripts_path: deployment_scripts/ + repository_path: repositories/ubuntu + +package_version: '4.0.0' diff --git a/network_roles.yaml b/network_roles.yaml new file mode 100644 index 0000000..889caaa --- /dev/null +++ b/network_roles.yaml @@ -0,0 +1,11 @@ +- id: 'emailnotifyd_public_vip' + default_mapping: 'public' + properties: + subnet: true + gateway: false + vip: + - name: 'vip__emailnotifyd' + namespace: 'haproxy' + alias: 'vip__emailnotifyd' + node_roles: + - 'emailnotifyd' diff --git a/node_roles.yaml b/node_roles.yaml new file mode 100644 index 0000000..6a13d3c --- /dev/null +++ b/node_roles.yaml @@ -0,0 +1,10 @@ +emailnotifyd: + name: 'emailnotifyd' + description: 'Email notify service' + has_primary: false + public_ip_required: true + weight: 100 + conflicts: [] + update_required: + - emailnotifyd + diff --git a/repositories/.DS_Store b/repositories/.DS_Store new file mode 100644 index 0000000..8ecd0bc Binary files /dev/null and b/repositories/.DS_Store differ diff --git a/repositories/centos/.gitkeep b/repositories/centos/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/repositories/ubuntu/.gitkeep b/repositories/ubuntu/.gitkeep new file mode 100644 index 0000000..e69de29