summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Popov <ilya_p@hotmail.com>2017-07-13 22:36:25 +0300
committerIlya Popov <ilya_p@hotmail.com>2017-07-17 23:09:08 +0300
commitdb629270fe192b4027b3fb600aa9d68fbd88933e (patch)
treec0e690bf9cc1dbac9462c8c773746a4312bdcb6a
parent62fa14b4acb517124ac32841c91daa203caa8055 (diff)
Import plugin's codeHEADmaster
Notes
Notes (review): Code-Review+1: Artem Tiumentcev <AITyumentsev.SBT@sberbank.ru> Code-Review+1: Margarita Shakhova <shakhova.margarita@gmail.com> Code-Review+1: Ivan Zinoviev <zinoviev.ii@gmail.com> Code-Review+2: Valeriy Ponomaryov <vponomaryov@mirantis.com> Workflow+1: Valeriy Ponomaryov <vponomaryov@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 31 Jul 2017 18:16:08 +0000 Reviewed-on: https://review.openstack.org/483526 Project: openstack/fuel-plugin-watcher Branch: refs/heads/master
-rw-r--r--README.md2
-rw-r--r--deployment_scripts/manifests/watcher.pp141
-rw-r--r--deployment_scripts/manifests/watcher_db.pp45
-rw-r--r--deployment_scripts/manifests/watcher_haproxy.pp39
-rw-r--r--deployment_scripts/manifests/watcher_hiera_override.pp66
-rw-r--r--deployment_scripts/manifests/watcher_keystone.pp33
-rw-r--r--deployment_scripts/manifests/watcher_logging.pp13
-rw-r--r--deployment_scripts/manifests/watcher_pin_plugin_repo.pp15
-rw-r--r--deployment_scripts/manifests/watcher_timezone.pp6
-rw-r--r--deployment_scripts/modules/watcher/Gemfile21
-rw-r--r--deployment_scripts/modules/watcher/LICENSE14
-rw-r--r--deployment_scripts/modules/watcher/README.md85
-rw-r--r--deployment_scripts/modules/watcher/Rakefile1
-rw-r--r--deployment_scripts/modules/watcher/lib/puppet/provider/watcher_config/ini_setting.rb10
-rw-r--r--deployment_scripts/modules/watcher/lib/puppet/type/watcher_config.rb53
-rw-r--r--deployment_scripts/modules/watcher/manifests/api.pp241
-rw-r--r--deployment_scripts/modules/watcher/manifests/applier.pp84
-rw-r--r--deployment_scripts/modules/watcher/manifests/config.pp32
-rw-r--r--deployment_scripts/modules/watcher/manifests/db.pp75
-rw-r--r--deployment_scripts/modules/watcher/manifests/db/create_schema.pp30
-rw-r--r--deployment_scripts/modules/watcher/manifests/db/mysql.pp74
-rw-r--r--deployment_scripts/modules/watcher/manifests/db/postgresql.pp57
-rw-r--r--deployment_scripts/modules/watcher/manifests/db/upgrade.pp32
-rw-r--r--deployment_scripts/modules/watcher/manifests/decision_engine.pp122
-rw-r--r--deployment_scripts/modules/watcher/manifests/deps.pp34
-rw-r--r--deployment_scripts/modules/watcher/manifests/init.pp471
-rw-r--r--deployment_scripts/modules/watcher/manifests/keystone/auth.pp101
-rw-r--r--deployment_scripts/modules/watcher/manifests/keystone/authtoken.pp274
-rw-r--r--deployment_scripts/modules/watcher/manifests/logging.pp118
-rw-r--r--deployment_scripts/modules/watcher/manifests/params.pp29
-rw-r--r--deployment_scripts/modules/watcher/manifests/policy.pp42
-rw-r--r--deployment_scripts/modules/watcher/metadata.json67
-rw-r--r--deployment_scripts/modules/watcher/releasenotes/source/_static/.placeholder0
-rw-r--r--deployment_scripts/modules/watcher/releasenotes/source/conf.py262
-rw-r--r--deployment_scripts/modules/watcher/releasenotes/source/index.rst18
-rw-r--r--deployment_scripts/modules/watcher/releasenotes/source/unreleased.rst5
-rw-r--r--deployment_scripts/modules/watcher/setup.cfg13
-rw-r--r--deployment_scripts/modules/watcher/setup.py22
-rw-r--r--deployment_scripts/modules/watcher/spec/acceptance/nodesets/centos-70-x64.yml11
-rw-r--r--deployment_scripts/modules/watcher/spec/acceptance/nodesets/default.yml10
-rw-r--r--deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-centos7.yml10
-rw-r--r--deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-trusty.yml10
-rw-r--r--deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-xenial.yml10
-rw-r--r--deployment_scripts/modules/watcher/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml11
-rw-r--r--deployment_scripts/modules/watcher/spec/acceptance/watcher_spec.rb77
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_api_spec.rb161
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_applier_spec.rb93
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_db_create_schema_spec.rb58
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_db_mysql_spec.rb73
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_db_postgresql_spec.rb37
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_db_spec.rb117
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_db_upgrade_spec.rb60
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_decision_engine_spec.rb101
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_init_spec.rb299
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_keystone_auth_spec.rb128
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_keystone_authtoken_spec.rb151
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_logging_spec.rb139
-rw-r--r--deployment_scripts/modules/watcher/spec/classes/watcher_policy_spec.rb37
-rw-r--r--deployment_scripts/modules/watcher/spec/shared_examples.rb5
-rw-r--r--deployment_scripts/modules/watcher/spec/spec_helper.rb10
-rw-r--r--deployment_scripts/modules/watcher/spec/spec_helper_acceptance.rb1
-rw-r--r--deployment_scripts/modules/watcher/spec/unit/provider/watcher_config/ini_setting_spec.rb68
-rw-r--r--deployment_scripts/modules/watcher/spec/unit/type/watcher_config_spec.rb64
-rw-r--r--deployment_scripts/modules/watcher/test-requirements.txt5
-rw-r--r--deployment_scripts/modules/watcher/tests/init.pp12
-rw-r--r--deployment_scripts/modules/watcher/tox.ini8
-rw-r--r--deployment_tasks.yaml129
-rw-r--r--environment_config.yaml10
-rw-r--r--functions.sh64
-rw-r--r--metadata.yaml20
-rw-r--r--network_roles.yaml12
-rw-r--r--node_roles.yaml6
-rw-r--r--repositories/centos/.gitkeep0
-rw-r--r--repositories/ubuntu/.gitkeep0
-rw-r--r--volumes.yaml4
75 files changed, 4758 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..bb82365
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
1# Detached watcher role
2Plugin to deploy watcher on separate node
diff --git a/deployment_scripts/manifests/watcher.pp b/deployment_scripts/manifests/watcher.pp
new file mode 100644
index 0000000..a685634
--- /dev/null
+++ b/deployment_scripts/manifests/watcher.pp
@@ -0,0 +1,141 @@
1notice('MODULAR: watcher/watcher.pp')
2
3prepare_network_config(hiera_hash('network_scheme', {}))
4
5$watcher_hash = hiera_hash('watcher_plugin', {})
6$watcher_plugins = pick($watcher_hash['plugins'], {})
7$rabbit_hash = hiera_hash('rabbit', {})
8$neutron_config = hiera_hash('neutron_config', {})
9$public_ssl_hash = hiera_hash('public_ssl', {})
10$ssl_hash = hiera_hash('use_ssl', {})
11$external_dns = hiera_hash('external_dns', {})
12$primary_watcher = roles_include(['primary-watcher-node', 'primary-controller'])
13$public_ip = hiera('public_vip')
14$database_ip = hiera('database_vip')
15$management_ip = hiera('management_vip')
16$region = hiera('region', 'RegionOne')
17$use_neutron = hiera('use_neutron', false)
18$service_endpoint = hiera('service_endpoint')
19$syslog_log_facility_watcher = hiera('syslog_log_facility_watcher')
20$debug = pick($watcher_hash['debug'], hiera('debug', false))
21$verbose = pick($watcher_hash['verbose'], hiera('verbose', true))
22$default_log_levels = hiera_hash('default_log_levels', {})
23$use_syslog = hiera('use_syslog', true)
24$use_stderr = hiera('use_stderr', false)
25$rabbit_ha_queues = hiera('rabbit_ha_queues', false)
26$amqp_port = hiera('amqp_port')
27$amqp_hosts = hiera('amqp_hosts')
28
29$internal_auth_protocol = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'protocol', 'http')
30$internal_auth_address = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'hostname', [hiera('keystone_endpoint', ''), $service_endpoint, $management_ip])
31$admin_auth_protocol = get_ssl_property($ssl_hash, {}, 'keystone', 'admin', 'protocol', 'http')
32$admin_auth_address = get_ssl_property($ssl_hash, {}, 'keystone', 'admin', 'hostname', [hiera('keystone_endpoint', ''), $service_endpoint, $management_ip])
33$api_bind_host = get_network_role_property('management', 'ipaddr')
34
35$region_name = pick(hiera('region_name'), 'RegionOne')
36
37$firewall_rule = '214 watcher-api'
38$api_bind_port = '9322'
39
40$watcher_user = pick($watcher_hash['user'], 'watcher')
41$watcher_password = $watcher_hash['user_password']
42
43$mysql_hash = hiera_hash('mysql', {})
44$mysql_root_password = $mysql_hash['root_password']
45
46$db_type = 'mysql'
47$db_user = pick($watcher_hash['db_user'], 'watcher')
48$db_name = pick($watcher_hash['db_name'], 'watcher')
49$db_password = pick($watcher_hash['root_password'], $mysql_root_password)
50$db_host = pick($watcher_hash['db_host'], $database_ip)
51# LP#1526938 - python-mysqldb supports this, python-pymysql does not
52if $::os_package_type == 'debian' {
53 $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 }
54} else {
55 $extra_params = { 'charset' => 'utf8' }
56}
57$db_connection = os_database_connection({
58 'dialect' => $db_type,
59 'host' => $db_host,
60 'database' => $db_name,
61 'username' => $db_user,
62 'password' => $db_password,
63 'extra' => $extra_params
64})
65
66notice($db_connection)
67
68####### Disable upstart startup on install #######
69tweaks::ubuntu_service_override { ['watcher-api', 'watcher-engine']:
70 package_name => 'watcher',
71}
72
73include ::firewall
74firewall { $firewall_rule :
75 dport => $api_bind_port,
76 proto => 'tcp',
77 action => 'accept',
78}
79
80$nova_scheduler_default_filters = 'RetryFilter,AvailabilityZoneFilter,AggregateRamFilter,AggregateCoreFilter,DiskFilter,ComputeFilter,AggregateInstanceExtraSpecsFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,AggregateMetaDataIsolation'
81$nova_ram_allocation_ratio = '1.5'
82$nova_scheduler_driver = 'nova.scheduler.filter_scheduler.FilterScheduler'
83$nova_disk_allocation_ratio = '1.0'
84$nova_cpu_allocation_ratio = '8.0'
85$nova_max_instances_per_host = '50'
86$nova_scheduler_available_filters = 'nova.scheduler.filters.all_filters'
87
88class { '::watcher' :
89 ensure_package => 'latest',
90 database_connection => $db_connection,
91 notification_driver => 'messagingv2',
92 password => $watcher_password,
93 username => $watcher_user,
94 admin_user => $watcher_user,
95 admin_password => $watcher_password,
96 auth_uri => "${internal_auth_protocol}://${internal_auth_address}:5000/",
97 auth_url => "${admin_auth_protocol}://${admin_auth_address}:35357/v3",
98 identity_uri => "${internal_auth_protocol}://${internal_auth_address}:35357/",
99 region_name => $region_name,
100 rabbit_os_host => $amqp_hosts,
101 rabbit_os_user => $rabbit_hash['user'],
102 rabbit_os_password => $rabbit_hash['password'],
103 rabbit_ha_queues => true,
104 nova_scheduler_default_filters => $nova_scheduler_default_filters,
105 nova_ram_allocation_ratio => $nova_ram_allocation_ratio,
106 nova_scheduler_driver => $nova_scheduler_driver,
107 nova_disk_allocation_ratio => $nova_disk_allocation_ratio,
108 nova_cpu_allocation_ratio =>$nova_cpu_allocation_ratio,
109 nova_max_instances_per_host => $nova_max_instances_per_host,
110 nova_scheduler_available_filters => $nova_scheduler_available_filters,
111}
112
113class { '::watcher::api':
114 watcher_client_auth_uri => "${internal_auth_protocol}://${internal_auth_address}:5000/",
115 watcher_client_auth_url => "${admin_auth_protocol}://${admin_auth_address}:35357/",
116 watcher_client_username => $watcher_user,
117 watcher_client_password => $watcher_password,
118 watcher_api_bind_host => $api_bind_host,
119 watcher_api_port => $api_bind_port,
120 package_ensure => 'latest',
121 create_db_schema => true,
122 upgrade_db => true
123}
124
125class { '::watcher::applier' :
126 package_ensure => 'latest',
127}
128
129class { '::watcher::decision_engine' :
130 package_ensure => 'latest',
131 planner => 'forced_order',
132}
133
134#class { '::watcher::policy': }
135
136package { 'python-watcherclient':
137 ensure => 'latest',
138 tag => ['openstack', 'watcher-package'],
139}
140
141Firewall[$firewall_rule] -> Class['watcher::api']
diff --git a/deployment_scripts/manifests/watcher_db.pp b/deployment_scripts/manifests/watcher_db.pp
new file mode 100644
index 0000000..10b07d8
--- /dev/null
+++ b/deployment_scripts/manifests/watcher_db.pp
@@ -0,0 +1,45 @@
1notice('MODULAR: watcher/watcher_db.pp')
2
3$watcher_hash = hiera_hash('watcher_plugin', {})
4$mysql_hash = hiera_hash('mysql', {})
5$management_vip = hiera('management_vip', undef)
6$database_vip = hiera('database_vip')
7
8$mysql_root_user = pick($mysql_hash['root_user'], 'root')
9$mysql_db_create = pick($mysql_hash['db_create'], true)
10$mysql_root_password = $mysql_hash['root_password']
11
12$db_user = pick($watcher_hash['db_user'], 'watcher')
13$db_name = pick($watcher_hash['db_name'], 'watcher')
14$db_password = pick($watcher_hash['db_password'], $mysql_root_password)
15
16$db_host = pick($watcher_hash['db_host'], $database_vip)
17$db_create = pick($watcher_hash['db_create'], $mysql_db_create)
18$db_root_user = pick($watcher_hash['root_user'], $mysql_root_user)
19$db_root_password = pick($watcher_hash['root_password'], $mysql_root_password)
20
21$allowed_hosts = [ 'localhost', '127.0.0.1', '%' ]
22
23class { '::openstack::galera::client':
24 custom_setup_class => hiera('mysql_custom_setup_class', 'galera'),
25}
26
27class { 'watcher::db::mysql':
28 user => $db_user,
29 password => $db_password,
30 dbname => $db_name,
31 allowed_hosts => $allowed_hosts,
32}
33
34class { 'osnailyfacter::mysql_access':
35 db_host => $db_host,
36 db_user => $db_root_user,
37 db_password => $db_root_password,
38}
39
40Class['openstack::galera::client'] ->
41 Class['osnailyfacter::mysql_access'] ->
42 Class['watcher::db::mysql']
43
44class mysql::server {}
45include mysql::server \ No newline at end of file
diff --git a/deployment_scripts/manifests/watcher_haproxy.pp b/deployment_scripts/manifests/watcher_haproxy.pp
new file mode 100644
index 0000000..68f207c
--- /dev/null
+++ b/deployment_scripts/manifests/watcher_haproxy.pp
@@ -0,0 +1,39 @@
1notice('MODULAR: watcher/watcher_haproxy.pp')
2
3$watcher_hash = hiera_hash('watcher_plugin',{})
4$public_ssl_hash = hiera_hash('public_ssl', {})
5$ssl_hash = hiera_hash('use_ssl', {})
6$external_lb = hiera('external_lb', false)
7
8if (!$external_lb) {
9 $public_ssl = get_ssl_property($ssl_hash, $public_ssl_hash, 'watcher', 'public', 'usage', false)
10 $public_ssl_path = get_ssl_property($ssl_hash, $public_ssl_hash, 'watcher', 'public', 'path', [''])
11 $internal_ssl = get_ssl_property($ssl_hash, {}, 'watcher', 'internal', 'usage', false)
12 $internal_ssl_path = get_ssl_property($ssl_hash, {}, 'watcher', 'internal', 'path', [''])
13
14 $server_names = $watcher_hash['watcher_nodes']
15 $ipaddresses = $watcher_hash['watcher_ipaddresses']
16 $public_virtual_ip = hiera('public_vip')
17 $internal_virtual_ip = hiera('management_vip')
18
19 Openstack::Ha::Haproxy_service {
20 internal_virtual_ip => $internal_virtual_ip,
21 ipaddresses => $ipaddresses,
22 public_virtual_ip => $public_virtual_ip,
23 server_names => $server_names,
24 public => true,
25 }
26
27 openstack::ha::haproxy_service { 'watcher-api':
28 order => '214',
29 listen_port => 9322,
30 public_ssl => $public_ssl,
31 public_ssl_path => $public_ssl_path,
32 internal_ssl => $internal_ssl,
33 internal_ssl_path => $internal_ssl_path,
34 require_service => 'watcher_api',
35 haproxy_config_options => {
36 'http-request' => 'set-header X-Forwarded-Proto https if { ssl_fc }',
37 },
38 }
39}
diff --git a/deployment_scripts/manifests/watcher_hiera_override.pp b/deployment_scripts/manifests/watcher_hiera_override.pp
new file mode 100644
index 0000000..5d24551
--- /dev/null
+++ b/deployment_scripts/manifests/watcher_hiera_override.pp
@@ -0,0 +1,66 @@
1notice('MODULAR: watcher/watcher_hiera_override.pp')
2
3$watcher_plugin = hiera('fuel-plugin-watcher', undef)
4$hiera_dir = '/etc/hiera/plugins'
5$plugin_name = 'fuel-plugin-watcher'
6$plugin_yaml = "${plugin_name}.yaml"
7
8if $watcher_plugin {
9 $network_metadata = hiera_hash('network_metadata')
10 $watcher_base_hash = hiera_hash('watcher', {})
11 $user_password = $watcher_plugin['user_password']
12 $watcher_role_exists = empty(nodes_with_roles(['primary-watcher-node'])) ? {
13 true => false,
14 default => true,
15 }
16 if $watcher_role_exists {
17 $watcher_nodes = get_nodes_hash_by_roles($network_metadata, ['primary-watcher-node', 'watcher-node'])
18 $watcher_address_map = get_node_to_ipaddr_map_by_network_role($watcher_nodes, 'management')
19 $watcher_nodes_ips = values($watcher_address_map)
20 $watcher_nodes_names = keys($watcher_address_map)
21 } else {
22 $watcher_nodes = get_nodes_hash_by_roles($network_metadata, ['primary-controller', 'controller'])
23 $watcher_address_map = get_node_to_ipaddr_map_by_network_role($watcher_nodes, 'management')
24 $watcher_nodes_ips = values($watcher_address_map)
25 $watcher_nodes_names = keys($watcher_address_map)
26 }
27
28 $syslog_log_facility_watcher = hiera('syslog_log_facility_watcher', 'LOG_LOCAL0')
29 $default_log_levels = hiera('default_log_levels')
30
31 ###################
32 $calculated_content = inline_template('
33watcher_plugin:
34 user_password: <%= @user_password %>
35 watcher_standalone: <%= @watcher_role_exists %>
36 watcher_ipaddresses:
37<%
38@watcher_nodes_ips.each do |watcherip|
39%> - <%= watcherip %>
40<% end -%>
41 watcher_nodes:
42<%
43@watcher_nodes_names.each do |watchername|
44%> - <%= watchername %>
45<% end -%>
46syslog_log_facility_watcher: <%= @syslog_log_facility_watcher %>
47"watcher::logging::default_log_levels":
48<%
49@default_log_levels.each do |k,v|
50%> <%= k %>: <%= v %>
51<% end -%>
52')
53
54 ###################
55 file {'/etc/hiera/override':
56 ensure => directory,
57 } ->
58 file { "${hiera_dir}/${plugin_yaml}":
59 ensure => file,
60 content => "${calculated_content}",
61 }
62
63 package {'ruby-deep-merge':
64 ensure => 'installed',
65 }
66}
diff --git a/deployment_scripts/manifests/watcher_keystone.pp b/deployment_scripts/manifests/watcher_keystone.pp
new file mode 100644
index 0000000..4d8d65d
--- /dev/null
+++ b/deployment_scripts/manifests/watcher_keystone.pp
@@ -0,0 +1,33 @@
1notice('watcher PLUGIN: watcher_keystone.pp')
2
3$watcher_hash = hiera_hash('watcher_plugin', {})
4$public_ip = hiera('public_vip')
5$management_ip = hiera('management_vip')
6$region = hiera('region', 'RegionOne')
7$public_ssl_hash = hiera('public_ssl')
8$ssl_hash = hiera_hash('use_ssl', {})
9
10$public_protocol = get_ssl_property($ssl_hash, $public_ssl_hash, 'watcher', 'public', 'protocol', 'http')
11$public_address = get_ssl_property($ssl_hash, $public_ssl_hash, 'watcher', 'public', 'hostname', [$public_ip])
12$internal_protocol = get_ssl_property($ssl_hash, {}, 'watcher', 'internal', 'protocol', 'http')
13$internal_address = get_ssl_property($ssl_hash, {}, 'watcher', 'internal', 'hostname', [$management_ip])
14$admin_protocol = get_ssl_property($ssl_hash, {}, 'watcher', 'admin', 'protocol', 'http')
15$admin_address = get_ssl_property($ssl_hash, {}, 'watcher', 'admin', 'hostname', [$management_ip])
16
17$api_bind_port = '9322'
18$tenant = pick($watcher_hash['tenant'], 'services')
19$public_url = "${public_protocol}://${public_address}:${api_bind_port}"
20$internal_url = "${internal_protocol}://${internal_address}:${api_bind_port}"
21$admin_url = "${admin_protocol}://${admin_address}:${api_bind_port}"
22
23class {'::osnailyfacter::wait_for_keystone_backends':}
24class { 'watcher::keystone::auth':
25 password => pick($watcher_hash['user_password'], 'watcher'),
26 region => $region,
27 tenant => $tenant,
28 public_url => $public_url,
29 internal_url => $internal_url,
30 admin_url => $admin_url,
31}
32
33Class['::osnailyfacter::wait_for_keystone_backends'] -> Class['watcher::keystone::auth']
diff --git a/deployment_scripts/manifests/watcher_logging.pp b/deployment_scripts/manifests/watcher_logging.pp
new file mode 100644
index 0000000..733fe15
--- /dev/null
+++ b/deployment_scripts/manifests/watcher_logging.pp
@@ -0,0 +1,13 @@
1notice('MODULAR: watcher/watcher_logging.pp')
2
3$content=':syslogtag, contains, "watcher" -/var/log/watcher-all.log
4### stop further processing for the matched entries
5& ~'
6
7include ::rsyslog::params
8
9::rsyslog::snippet { '57-watcher':
10 content => $content,
11}
12
13Rsyslog::Snippet['57-watcher'] ~> Service[$::rsyslog::params::service_name]
diff --git a/deployment_scripts/manifests/watcher_pin_plugin_repo.pp b/deployment_scripts/manifests/watcher_pin_plugin_repo.pp
new file mode 100644
index 0000000..285a71b
--- /dev/null
+++ b/deployment_scripts/manifests/watcher_pin_plugin_repo.pp
@@ -0,0 +1,15 @@
1notice('MODULAR: watcher/watcher_pin_plugin_repo.pp')
2
3$master_ip = pick(hiera('master_ip'), 'localhost')
4$location = "http://${master_ip}:8080/watcher"
5
6apt::source { 'watcher':
7 location => $location,
8 release => 'mos9.0-watcher',
9 repos => 'main',
10}
11
12apt::pin { 'watcher':
13 release => 'mos9.0-watcher',
14 priority => 1300,
15} \ No newline at end of file
diff --git a/deployment_scripts/manifests/watcher_timezone.pp b/deployment_scripts/manifests/watcher_timezone.pp
new file mode 100644
index 0000000..a8f9bf6
--- /dev/null
+++ b/deployment_scripts/manifests/watcher_timezone.pp
@@ -0,0 +1,6 @@
1notice('MODULAR: watcher/watcher_timezone.pp')
2
3#TODO: customize timezone
4exec {'moscow_timezone':
5 command => '/usr/bin/timedatectl set-timezone Europe/Moscow'
6} ~> service { 'rsyslog': }
diff --git a/deployment_scripts/modules/watcher/Gemfile b/deployment_scripts/modules/watcher/Gemfile
new file mode 100644
index 0000000..a87f006
--- /dev/null
+++ b/deployment_scripts/modules/watcher/Gemfile
@@ -0,0 +1,21 @@
1source ENV['GEM_SOURCE'] || "https://rubygems.org"
2
3group :development, :test, :system_tests do
4 gem 'puppet-openstack_spec_helper',
5 :git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper',
6 :require => 'false'
7end
8
9if facterversion = ENV['FACTER_GEM_VERSION']
10 gem 'facter', facterversion, :require => false
11else
12 gem 'facter', :require => false
13end
14
15if puppetversion = ENV['PUPPET_GEM_VERSION']
16 gem 'puppet', puppetversion, :require => false
17else
18 gem 'puppet', :require => false
19end
20
21# vim:ft=ruby
diff --git a/deployment_scripts/modules/watcher/LICENSE b/deployment_scripts/modules/watcher/LICENSE
new file mode 100644
index 0000000..e7cb8c0
--- /dev/null
+++ b/deployment_scripts/modules/watcher/LICENSE
@@ -0,0 +1,14 @@
1Copyright 2016 OVH Group
2Copyright 2016 OpenStack Foundation
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
diff --git a/deployment_scripts/modules/watcher/README.md b/deployment_scripts/modules/watcher/README.md
new file mode 100644
index 0000000..4cb50a7
--- /dev/null
+++ b/deployment_scripts/modules/watcher/README.md
@@ -0,0 +1,85 @@
1Team and repository tags
2========================
3
4[![Team and repository tags](http://governance.openstack.org/badges/puppet-watcher.svg)](http://governance.openstack.org/reference/tags/index.html)
5
6<!-- Change things from this point on -->
7
8watcher
9=======
10
11#### Table of Contents
12
131. [Overview - What is the watcher module?](#overview)
142. [Module Description - What does the module do?](#module-description)
153. [Setup - The basics of getting started with watcher](#setup)
164. [Implementation - An under-the-hood peek at what the module is doing](#implementation)
175. [Limitations - OS compatibility, etc.](#limitations)
186. [Development - Guide for contributing to the module](#development)
197. [Contributors - Those with commits](#contributors)
20
21Overview
22--------
23
24The watcher module is a part of [OpenStack](https://www.openstack.org), an effort by the OpenStack infrastructure team to provide continuous integration testing and code review for OpenStack and OpenStack community projects not part of the core software. The module its self is used to flexibly configure and manage the Watcher service for OpenStack.
25
26Module Description
27------------------
28
29The watcher module is a thorough attempt to make Puppet capable of managing the entirety of watcher. This includes manifests to provision region specific endpoint and database connections. Types are shipped as part of the watcher module to assist in manipulation of configuration files.
30
31Setup
32-----
33
34**What the watcher module affects**
35
36* [Watcher](https://wiki.openstack.org/wiki/Watcher), the Watcher service for OpenStack.
37
38### Installing watcher
39
40 watcher is not currently in Puppet Forge, but is anticipated to be added soon. Once that happens, you'll be able to install watcher with:
41 puppet module install openstack/watcher
42
43### Beginning with watcher
44
45To utilize the watcher module's functionality you will need to declare multiple resources.
46
47Implementation
48--------------
49
50### watcher
51
52watcher is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers.
53
54Limitations
55------------
56
57* All the watcher types use the CLI tools and so need to be ran on the watcher node.
58
59Beaker-Rspec
60------------
61
62This module has beaker-rspec tests
63
64To run the tests on the default vagrant node:
65
66```shell
67bundle install
68bundle exec rake acceptance
69```
70
71For more information on writing and running beaker-rspec tests visit the documentation:
72
73* https://github.com/puppetlabs/beaker-rspec/blob/master/README.md
74
75Development
76-----------
77
78Developer documentation for the entire puppet-openstack project.
79
80* http://docs.openstack.org/developer/puppet-openstack-guide/
81
82Contributors
83------------
84
85* https://github.com/openstack/puppet-watcher/graphs/contributors
diff --git a/deployment_scripts/modules/watcher/Rakefile b/deployment_scripts/modules/watcher/Rakefile
new file mode 100644
index 0000000..168d108
--- /dev/null
+++ b/deployment_scripts/modules/watcher/Rakefile
@@ -0,0 +1 @@
require 'puppet-openstack_spec_helper/rake_tasks'
diff --git a/deployment_scripts/modules/watcher/lib/puppet/provider/watcher_config/ini_setting.rb b/deployment_scripts/modules/watcher/lib/puppet/provider/watcher_config/ini_setting.rb
new file mode 100644
index 0000000..b2188d4
--- /dev/null
+++ b/deployment_scripts/modules/watcher/lib/puppet/provider/watcher_config/ini_setting.rb
@@ -0,0 +1,10 @@
1Puppet::Type.type(:watcher_config).provide(
2 :ini_setting,
3 :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
4) do
5
6 def self.file_path
7 '/etc/watcher/watcher.conf'
8 end
9
10end
diff --git a/deployment_scripts/modules/watcher/lib/puppet/type/watcher_config.rb b/deployment_scripts/modules/watcher/lib/puppet/type/watcher_config.rb
new file mode 100644
index 0000000..acc57d9
--- /dev/null
+++ b/deployment_scripts/modules/watcher/lib/puppet/type/watcher_config.rb
@@ -0,0 +1,53 @@
1Puppet::Type.newtype(:watcher_config) do
2
3 ensurable
4
5 newparam(:name, :namevar => true) do
6 desc 'Section/setting name to manage from watcher.conf'
7 newvalues(/\S+\/\S+/)
8 end
9
10 newproperty(:value) do
11 desc 'The value of the setting to be defined.'
12 munge do |value|
13 value = value.to_s.strip
14 value.capitalize! if value =~ /^(true|false)$/i
15 value
16 end
17 newvalues(/^[\S ]*$/)
18
19 def is_to_s( currentvalue )
20 if resource.secret?
21 return '[old secret redacted]'
22 else
23 return currentvalue
24 end
25 end
26
27 def should_to_s( newvalue )
28 if resource.secret?
29 return '[new secret redacted]'
30 else
31 return newvalue
32 end
33 end
34 end
35
36 newparam(:secret, :boolean => true) do
37 desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
38
39 newvalues(:true, :false)
40
41 defaultto false
42 end
43
44 newparam(:ensure_absent_val) do
45 desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
46 defaultto('<SERVICE DEFAULT>')
47 end
48
49 autorequire(:package) do
50 'watcher'
51 end
52
53end
diff --git a/deployment_scripts/modules/watcher/manifests/api.pp b/deployment_scripts/modules/watcher/manifests/api.pp
new file mode 100644
index 0000000..481bc5c
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/api.pp
@@ -0,0 +1,241 @@
1# == Class: watcher::api
2#
3# Configure Watcher API service.
4#
5# === Parameters:
6#
7# All options are optional unless specified otherwise.
8# All options defaults to $::os_service_default and
9# the default values from the service are used.
10#
11# === Watcher configuration section: watcher_clients_auth
12#
13# [*watcher_client_password*]
14# (required) User's password
15#
16# [*watcher_client_username*]
17# (optional) The name of the auth user
18# Defaults to watcher.
19#
20# [*watcher_client_auth_uri*]
21# (Optional) Public Identity API endpoint.
22# Defaults to 'http://localhost:5000/'
23#
24# [*watcher_client_auth_url*]
25# Specifies the admin Identity URI for Watcher to use.
26# Default 'http://localhost:35357/'
27#
28# [*package_ensure*]
29# (Optional)Ensure state of the openstackclient package.
30# Defaults to 'present'.
31#
32# [*enabled*]
33# (Optional) Whether the watcher api service will be run
34# Defaults to true
35#
36# [*manage_service*]
37# (Optional) Whether the service should be managed by Puppet.
38# Defaults to true.
39#
40# [*validate*]
41# (Optional) Whether to validate the service is working after any service
42# refreshes
43# Defaults to false
44#
45# [*watcher_api_port*]
46# (Optional) The port on which the watcher API will listen.
47# Defaults to 9322.
48#
49# [*watcher_api_max_limit*]
50# (Optional)The maximum number of items returned in a single response from a
51# collection resource.
52# Defaults to $::os_service_default
53#
54# [*watcher_api_bind_host*]
55# (Optional) Listen IP for the watcher API server.
56# Defaults to '0.0.0.0'.
57#
58# [*watcher_api_workers*]
59# (Optional) Number of worker processors to for the Watcher API service.
60# Defaults to $::os_workers.
61#
62# [*watcher_api_enable_ssl_api*]
63# (Optional) Enable the integrated stand-alone API to service requests via HTTPS instead
64# of HTTP. If there is a front-end service performing HTTPS offloading from the
65# service, this option should be False; note, you will want to change public
66# API endpoint to represent SSL termination URL with 'public_endpoint' option.
67# Defaults to $::os_service_default.
68#
69# [*watcher_client_default_domain_name*]
70# (Optional)domain name to use with v3 API and v2 parameters. It will
71# be used for both the user and project domain in v3 and ignored in v2
72# authentication.
73# Defaults to $::os_service_default
74#
75# [*watcher_client_project_name*]
76# (Optional) Service project name.
77# Defaults to undef
78#
79# [*watcher_client_certfile*]
80# (Optional) PEM encoded client certificate cert file.
81# Defaults to undef
82#
83# [*watcher_client_cafile*]
84# (Optional)PEM encoded Certificate Authority to use when verifying HTTPs
85# connections.
86# Defaults to undef
87#
88# [*watcher_client_project_domain_name*]
89# (Optional) Domain name containing project.
90# Defaults to undef
91#
92# [*watcher_client_insecure*]
93# (Optional) Verify HTTPS connections.
94# Defaults to undef
95#
96# [*watcher_client_keyfile*]
97# (Optional) PEM encoded client certificate key file.
98# Defaults to undef
99#
100# [*watcher_client_auth_type*]
101# (Optional) Authentication type to load.
102# Defaults to undef
103#
104# === Watcher API service validation
105#
106# [*validation_options*]
107# (Optional) Service validation options
108# Should be a hash of options defined in openstacklib::service_validation
109# If empty, defaults values are taken from openstacklib function.
110# Require validate set at True.
111# Defaults to {}
112#
113# === DB managment
114#
115# [*create_db_schema*]
116# (Optional) Run watcher-db-manage create_schema on api nodes after
117# installing the package.
118# Defaults to false
119#
120# [*upgrade_db*]
121# (Optional) Run watcher-db-manage upgrade on api nodes after
122# installing the package.
123# Defaults to false
124#
125# [*auth_strategy*]
126# (optional) Type of authentication to be used.
127# Defaults to 'keystone'
128#
129class watcher::api (
130 $watcher_client_password,
131 $watcher_client_username = 'watcher',
132 $watcher_client_auth_uri = 'http://localhost:5000/',
133 $watcher_client_auth_url = 'http://localhost:35357/',
134 $package_ensure = 'present',
135 $enabled = true,
136 $manage_service = true,
137 $validate = false,
138 $watcher_api_port = '9322',
139 $watcher_api_max_limit = $::os_service_default,
140 $watcher_api_bind_host = '0.0.0.0',
141 $watcher_api_workers = $::os_workers,
142 $watcher_api_enable_ssl_api = $::os_service_default,
143 $watcher_client_default_domain_name = $::os_service_default,
144 $watcher_client_project_name = 'services',
145 $watcher_client_certfile = $::os_service_default,
146 $watcher_client_cafile = $::os_service_default,
147 $watcher_client_project_domain_name = $::os_service_default,
148 $watcher_client_insecure = $::os_service_default,
149 $watcher_client_keyfile = $::os_service_default,
150 $watcher_client_auth_type = 'password',
151 $validation_options = {},
152 $create_db_schema = false,
153 $upgrade_db = false,
154 $auth_strategy = 'keystone',
155) {
156
157 include ::watcher::params
158 include ::watcher::policy
159 include ::watcher::deps
160
161 #if $auth_strategy == 'keystone' {
162 # include ::watcher::keystone::authtoken
163 #}
164
165 validate_string($watcher_client_password)
166
167 package { 'watcher-api':
168 ensure => $package_ensure,
169 name => $::watcher::params::api_package_name,
170 tag => ['openstack', 'watcher-package'],
171 }
172
173 if $manage_service {
174 if $enabled {
175 $service_ensure = 'running'
176 } else {
177 $service_ensure = 'stopped'
178 }
179 }
180
181 if $create_db_schema {
182 include ::watcher::db::create_schema
183 }
184
185 if $upgrade_db {
186 include ::watcher::db::upgrade
187 }
188
189 # NOTE(danpawlik) Watcher doesn't support db_sync command.
190 service { 'watcher-api':
191 ensure => $service_ensure,
192 name => $::watcher::params::api_service_name,
193 enable => $enabled,
194 hasstatus => true,
195 hasrestart => true,
196 tag => [ 'watcher-service',
197 'watcher-db-manage-create_schema',
198 'watcher-db-manage-upgrade'],
199 }
200
201 if $enabled {
202 watcher_config {
203 'api/port': value => $watcher_api_port;
204 'api/max_limit': value => $watcher_api_max_limit;
205 'api/host': value => $watcher_api_bind_host;
206 'api/workers': value => $watcher_api_workers;
207 'api/enable_ssl_api': value => $watcher_api_enable_ssl_api;
208 }
209 }
210
211 # NOTE(danpawlik) Watcher and other core Openstack services are using
212 # keystone_authtoken section and also another similar section used to
213 # configure client auth credentials. So these parameters are similar to
214 # parameters in watcher::keystone::authtoken.
215 watcher_config {
216 'watcher_clients_auth/username': value => $watcher_client_username;
217 'watcher_clients_auth/password': value => $watcher_client_password, secret => true;
218 'watcher_clients_auth/auth_url': value => $watcher_client_auth_url;
219 'watcher_clients_auth/auth_uri': value => $watcher_client_auth_uri;
220 'watcher_clients_auth/project_name': value => $watcher_client_project_name;
221 'watcher_clients_auth/project_domain_name': value => $watcher_client_project_domain_name;
222 'watcher_clients_auth/insecure': value => $watcher_client_insecure;
223 'watcher_clients_auth/auth_type': value => $watcher_client_auth_type;
224 'watcher_clients_auth/cafile': value => $watcher_client_cafile;
225 'watcher_clients_auth/certfile': value => $watcher_client_certfile;
226 'watcher_clients_auth/keyfile': value => $watcher_client_keyfile;
227 }
228
229 if $validate {
230 $defaults = {
231 'watcher-api' => {
232 # lint:ignore:140chars
233 'command' => "watcher --os-auth-url ${watcher_client_auth_url} --os-project-name ${watcher_client_project_name} --os-username ${watcher_client_username} --os-password ${watcher_client_password} goal list",
234 # lint:endignore
235 }
236 }
237 $validation_options_hash = merge($defaults, $validation_options)
238 create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Anchor[watcher::service::end]'})
239 }
240
241}
diff --git a/deployment_scripts/modules/watcher/manifests/applier.pp b/deployment_scripts/modules/watcher/manifests/applier.pp
new file mode 100644
index 0000000..911cdcc
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/applier.pp
@@ -0,0 +1,84 @@
1# == Class: watcher::applier
2#
3# === Parameters
4#
5# [*package_ensure*]
6# (Optional) The state of the package.
7# Defaults to 'present'.
8#
9# [*enabled*]
10# (Optional) The state of the service
11# Defaults to 'true'.
12#
13# [*manage_service*]
14# (Optional) Whether to start/stop the service.
15# Defaults to 'true'.
16#
17# [*applier_workers*]
18# (Optional) Number of workers for watcher applier service.
19# Defaults to $::os_service_default
20#
21# [*applier_conductor_topic*]
22# (Optional) The topic name used forcontrol events, this topic used
23# for rpc call
24# Defaults to $::os_service_default
25#
26# [*applier_status_topic*]
27# (Optional) The topic name used for status events, this topic is used
28# so as to notifythe others components of the system
29# Defaults to $::os_service_default
30#
31# [*applier_publisher_id*]
32# (Optional) The identifier used by watcher module on the message broker
33# Defaults to $::os_service_default
34#
35# [*applier_workflow_engine*]
36# (Optional) Select the engine to use to execute the workflow
37# Defaults to $::os_service_default
38#
39class watcher::applier (
40 $package_ensure = 'present',
41 $enabled = true,
42 $manage_service = true,
43 $applier_workers = $::os_service_default,
44 $applier_conductor_topic = $::os_service_default,
45 $applier_status_topic = $::os_service_default,
46 $applier_publisher_id = $::os_service_default,
47 $applier_workflow_engine = $::os_service_default,
48) {
49
50 include ::watcher::params
51 include ::watcher::deps
52
53 package { 'watcher-applier':
54 ensure => $package_ensure,
55 name => $::watcher::params::applier_package_name,
56 tag => ['openstack', 'watcher-package'],
57 }
58
59 if $manage_service {
60 if $enabled {
61 $service_ensure = 'running'
62 } else {
63 $service_ensure = 'stopped'
64 }
65 }
66
67 service { 'watcher-applier':
68 ensure => $service_ensure,
69 name => $::watcher::params::applier_service_name,
70 enable => $enabled,
71 hasstatus => true,
72 hasrestart => true,
73 tag => ['watcher-service'],
74 }
75
76 watcher_config {
77 'watcher_applier/workers': value => $applier_workers;
78 'watcher_applier/conductor_topic': value => $applier_conductor_topic;
79 'watcher_applier/status_topic': value => $applier_status_topic;
80 'watcher_applier/publisher_id': value => $applier_publisher_id;
81 'watcher_applier/workflow_engine': value => $applier_workflow_engine;
82 }
83
84}
diff --git a/deployment_scripts/modules/watcher/manifests/config.pp b/deployment_scripts/modules/watcher/manifests/config.pp
new file mode 100644
index 0000000..65a07a6
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/config.pp
@@ -0,0 +1,32 @@
1# == Class: watcher::config
2#
3# This class is used to manage arbitrary watcher configurations.
4#
5# === Parameters
6#
7# [*watcher_config*]
8# (optional) Allow configuration of arbitrary watcher configurations.
9# The value is an hash of watcher_config resources. Example:
10# { 'DEFAULT/foo' => { value => 'fooValue'},
11# 'DEFAULT/bar' => { value => 'barValue'}
12# }
13# In yaml format, Example:
14# watcher_config:
15# DEFAULT/foo:
16# value: fooValue
17# DEFAULT/bar:
18# value: barValue
19#
20# NOTE: The configuration MUST NOT be already handled by this module
21# or Puppet catalog compilation will fail with duplicate resources.
22#
23class watcher::config (
24 $watcher_config = {},
25) {
26
27 include ::watcher::deps
28
29 validate_hash($watcher_config)
30
31 create_resources('watcher_config', $watcher_config)
32}
diff --git a/deployment_scripts/modules/watcher/manifests/db.pp b/deployment_scripts/modules/watcher/manifests/db.pp
new file mode 100644
index 0000000..b7e7165
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/db.pp
@@ -0,0 +1,75 @@
1# == Class: watcher::db
2#
3# Configure the watcher database
4#
5# === Parameters
6#
7# [*database_connection*]
8# (Optional) Url used to connect to database.
9# Defaults to "sqlite:////var/lib/watcher/watcher.sqlite".
10#
11# [*database_idle_timeout*]
12# (Optional) Timeout when db connections should be reaped.
13# Defaults to $::os_service_default
14#
15# [*database_db_max_retries*]
16# (optional) Maximum retries in case of connection error or deadlock error
17# before error is raised. Set to -1 to specify an infinite retry count.
18# Defaults to $::os_service_default
19#
20# [*database_max_retries*]
21# (Optional) Maximum number of database connection retries during startup.
22# Setting -1 implies an infinite retry count.
23# Defaults to $::os_service_default
24#
25# [*database_retry_interval*]
26# (Optional) Interval between retries of opening a database connection.
27# Defaults to $::os_service_default
28#
29# [*database_min_pool_size*]
30# (Optional) Minimum number of SQL connections to keep open in a pool.
31# Defaults to $::os_service_default
32#
33# [*database_max_pool_size*]
34# (Optional) Maximum number of SQL connections to keep open in a pool.
35# Defaults to $::os_service_default
36#
37# [*database_max_overflow*]
38# (Optional) If set, use this value for max_overflow with sqlalchemy.
39# Defaults to $::os_service_default
40#
41class watcher::db (
42 $database_connection = 'sqlite://var/lib/watcher/watcher.sqlite',
43 $database_idle_timeout = $::os_service_default,
44 $database_min_pool_size = $::os_service_default,
45 $database_max_pool_size = $::os_service_default,
46 $database_db_max_retries = $::os_service_default,
47 $database_max_retries = $::os_service_default,
48 $database_retry_interval = $::os_service_default,
49 $database_max_overflow = $::os_service_default,
50) {
51 $database_connection_real = pick($::watcher::database_connection, $database_connection)
52 $database_idle_timeout_real = pick($::watcher::database_idle_timeout, $database_idle_timeout)
53 $database_min_pool_size_real = pick($::watcher::database_min_pool_size, $database_min_pool_size)
54 $database_max_pool_size_real = pick($::watcher::database_max_pool_size, $database_max_pool_size)
55 $database_max_retries_real = pick($::watcher::database_max_retries, $database_max_retries)
56 $database_retry_interval_real = pick($::watcher::database_retry_interval, $database_retry_interval)
57 $database_max_overflow_real = pick($::watcher::database_max_overflow, $database_max_overflow)
58
59 include ::watcher::deps
60 notice($database_connection)
61
62 #validate_re($database_connection,
63 # '^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
64
65 watcher_config {
66 'database/connection': value => $database_connection_real;
67 'database/idle_timeout': value => $database_idle_timeout_real;
68 'database/min_pool_size': value => $database_min_pool_size_real;
69 'database/db_max_retries': value => $database_db_max_retries_real;
70 'database/max_retries': value => $database_max_retries_real;
71 'database/retry_interval': value => $database_retry_interval_real;
72 'database/max_pool_size': value => $database_max_pool_size_real;
73 'database/max_overflow': value => $database_max_overflow_real;
74 }
75}
diff --git a/deployment_scripts/modules/watcher/manifests/db/create_schema.pp b/deployment_scripts/modules/watcher/manifests/db/create_schema.pp
new file mode 100644
index 0000000..a592191
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/db/create_schema.pp
@@ -0,0 +1,30 @@
1#
2# Class to execute watcher-db-manage create_schema
3#
4# == Parameters
5#
6# [*extra_params*]
7# (optional) String of extra command line parameters to append
8# to the watcher-db-manage create_schema command.
9# Defaults to '--config-file /etc/watcher/watcher.conf'
10#
11class watcher::db::create_schema(
12 $extra_params = '--config-file /etc/watcher/watcher.conf',
13) {
14
15 include ::watcher::deps
16
17 exec { 'watcher-db-manage-create_schema':
18 command => "watcher-db-manage ${extra_params} create_schema",
19 path => '/usr/bin',
20 user => 'watcher',
21 refreshonly => true,
22 subscribe => [
23 Anchor['watcher::install::end'],
24 Anchor['watcher::config::end'],
25 Anchor['watcher::db::create_schema::begin']
26 ],
27 notify => Anchor['watcher::db::create_schema::end'],
28 }
29
30}
diff --git a/deployment_scripts/modules/watcher/manifests/db/mysql.pp b/deployment_scripts/modules/watcher/manifests/db/mysql.pp
new file mode 100644
index 0000000..6503fcc
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/db/mysql.pp
@@ -0,0 +1,74 @@
1# The watcher::db::mysql class implements mysql backend for watcher
2#
3# This class can be used to create tables, users and grant
4# privilege for a mysql watcher database.
5#
6# == parameters
7#
8# [*password*]
9# (Mandatory) Password to connect to the database.
10# Defaults to 'false'.
11#
12# [*dbname*]
13# (Optional) Name of the database.
14# Defaults to 'watcher'.
15#
16# [*user*]
17# (Optional) User to connect to the database.
18# Defaults to 'watcher'.
19#
20# [*host*]
21# (Optional) The default source host user is allowed to connect from.
22# Defaults to '127.0.0.1'
23#
24# [*allowed_hosts*]
25# (Optional) Other hosts the user is allowed to connect from.
26# Defaults to 'undef'.
27#
28# [*charset*]
29# (Optional) The database charset.
30# Defaults to 'utf8'
31#
32# [*collate*]
33# (Optional) The database collate.
34# Only used with mysql modules >= 2.2.
35# Defaults to 'utf8_general_ci'
36#
37# == Dependencies
38# Class['mysql::server']
39#
40# == Examples
41#
42# == Authors
43#
44# == Copyright
45#
46class watcher::db::mysql(
47 $password,
48 $dbname = 'watcher',
49 $user = 'watcher',
50 $host = '127.0.0.1',
51 $charset = 'utf8',
52 $collate = 'utf8_general_ci',
53 $allowed_hosts = undef
54) {
55
56 include ::watcher::deps
57
58 validate_string($password)
59
60 ::openstacklib::db::mysql { 'watcher':
61 user => $user,
62 password_hash => mysql_password($password),
63 dbname => $dbname,
64 host => $host,
65 charset => $charset,
66 collate => $collate,
67 allowed_hosts => $allowed_hosts,
68 }
69
70 Anchor['watcher::db::begin']
71 ~> Class['watcher::db::mysql']
72 ~> Anchor['watcher::db::end']
73
74}
diff --git a/deployment_scripts/modules/watcher/manifests/db/postgresql.pp b/deployment_scripts/modules/watcher/manifests/db/postgresql.pp
new file mode 100644
index 0000000..44f81b4
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/db/postgresql.pp
@@ -0,0 +1,57 @@
1# == Class: watcher::db::postgresql
2#
3# Class that configures postgresql for watcher
4# Requires the Puppetlabs postgresql module.
5#
6# === Parameters
7#
8# [*password*]
9# (Required) Password to connect to the database.
10#
11# [*dbname*]
12# (Optional) Name of the database.
13# Defaults to 'watcher'.
14#
15# [*user*]
16# (Optional) User to connect to the database.
17# Defaults to 'watcher'.
18#
19# [*encoding*]
20# (Optional) The charset to use for the database.
21# Default to undef.
22#
23# [*privileges*]
24# (Optional) Privileges given to the database user.
25# Default to 'ALL'
26#
27# == Dependencies
28#
29# == Examples
30#
31# == Authors
32#
33# == Copyright
34#
35class watcher::db::postgresql(
36 $password,
37 $dbname = 'watcher',
38 $user = 'watcher',
39 $encoding = undef,
40 $privileges = 'ALL',
41) {
42
43 include ::watcher::deps
44
45 ::openstacklib::db::postgresql { 'watcher':
46 password_hash => postgresql_password($user, $password),
47 dbname => $dbname,
48 user => $user,
49 encoding => $encoding,
50 privileges => $privileges,
51 }
52
53 Anchor['watcher::db::begin']
54 ~> Class['watcher::db::postgresql']
55 ~> Anchor['watcher::db::end']
56
57}
diff --git a/deployment_scripts/modules/watcher/manifests/db/upgrade.pp b/deployment_scripts/modules/watcher/manifests/db/upgrade.pp
new file mode 100644
index 0000000..89bc7df
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/db/upgrade.pp
@@ -0,0 +1,32 @@
1#
2# Class to execute watcher-db-manage upgrade
3# It's because watcher-db-manage doesn't support sync db.
4#
5# == Parameters
6#
7# [*extra_params*]
8# (optional) String of extra command line parameters to append
9# to the watcher-db-manage upgrade command.
10# Defaults to '--config-file /etc/watcher/watcher.conf'
11#
12class watcher::db::upgrade(
13 $extra_params = '--config-file /etc/watcher/watcher.conf',
14) {
15
16 include ::watcher::deps
17
18 exec { 'watcher-db-manage-upgrade':
19 command => "watcher-db-manage ${extra_params} upgrade",
20 path => '/usr/bin',
21 user => 'watcher',
22 refreshonly => true,
23 subscribe => [
24 Anchor['watcher::install::end'],
25 Anchor['watcher::config::end'],
26 Anchor['watcher::db::create_schema::end'],
27 Anchor['watcher::db::upgrade::begin']
28 ],
29 notify => Anchor['watcher::db::upgrade::end'],
30 }
31
32}
diff --git a/deployment_scripts/modules/watcher/manifests/decision_engine.pp b/deployment_scripts/modules/watcher/manifests/decision_engine.pp
new file mode 100644
index 0000000..c7e1189
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/decision_engine.pp
@@ -0,0 +1,122 @@
1# == Class: watcher::decision_engine
2#
3# === Parameters
4#
5# [*package_ensure*]
6# (Optional) The state of the package.
7# Defaults to 'present'.
8#
9# [*enabled*]
10# (Optional) The state of the service
11# Defaults to 'true'.
12#
13# [*manage_service*]
14# (Optional) Whether to start/stop the service.
15# Defaults to 'true'.
16#
17# [*decision_engine_conductor_topic*]
18# (Optional) The topic name used forcontrol events, this topic used
19# for rpc call
20# Defaults to $::os_service_default
21#
22# [*decision_engine_status_topic*]
23# (Optional) The topic name used for status events, this topic is used
24# so as to notifythe others components of the system
25# Defaults to $::os_service_default
26#
27# [*decision_engine_notification_topics*]
28# (Optional) The topic names from which notification events will be
29# listened to (list value)
30# Defaults to $::os_service_default
31#
32# [*decision_engine_publisher_id*]
33# (Optional) The identifier used by watcher module on the message broker
34# Defaults to $::os_service_default
35#
36# [*decision_engine_workers*]
37# (Optional) The maximum number of threads that can be used to execute
38# strategies
39# Defaults to $::os_service_default
40#
41# [*planner*]
42# (Optional) The selected planner used to schedule the actions (string value)
43# Defaults to $::os_service_default
44#
45# [*weights*]
46# (Optional) Hash of weights used to schedule the actions (dict value).
47# The key is an action, value is an order number.
48# Defaults to $::os_service_default
49# Example:
50# { 'change_nova_service_state' => '2',
51# 'migrate' => '3', 'nop' => '0', 'sleep' => '1' }
52#
53#
54class watcher::decision_engine (
55 $package_ensure = 'present',
56 $enabled = true,
57 $manage_service = true,
58 $decision_engine_conductor_topic = $::os_service_default,
59 $decision_engine_status_topic = $::os_service_default,
60 $decision_engine_notification_topics = $::os_service_default,
61 $decision_engine_publisher_id = $::os_service_default,
62 $decision_engine_workers = $::os_service_default,
63 $planner = $::os_service_default,
64 $weights = $::os_service_default,
65) {
66
67 include ::watcher::params
68 include ::watcher::deps
69
70 if !is_service_default($weights) {
71 validate_hash($weights)
72 $weights_real = join(sort(join_keys_to_values($weights, ':')), ',')
73 } else {
74 $weights_real = $weights
75 }
76
77 if !is_service_default($decision_engine_notification_topics) or
78 empty($decision_engine_notification_topics) {
79 warning('$decision_engine_notification_topics needs to be an array')
80 $decision_engine_notification_topics_real = any2array($decision_engine_notification_topics)
81 } else {
82 $decision_engine_notification_topics_real = $decision_engine_notification_topics
83 }
84
85 package { 'watcher-decision-engine':
86 ensure => $package_ensure,
87 name => $::watcher::params::decision_engine_package_name,
88 tag => ['openstack', 'watcher-package'],
89 }
90
91 if $manage_service {
92 if $enabled {
93 $service_ensure = 'running'
94 } else {
95 $service_ensure = 'stopped'
96 }
97 }
98
99 service { 'watcher-decision-engine':
100 ensure => $service_ensure,
101 name => $::watcher::params::decision_engine_service_name,
102 enable => $enabled,
103 hasstatus => true,
104 hasrestart => true,
105 tag => ['watcher-service'],
106 }
107
108 watcher_config {
109 'watcher_decision_engine/conductor_topic': value => $decision_engine_conductor_topic;
110 'watcher_decision_engine/status_topic': value => $decision_engine_status_topic;
111 'watcher_decision_engine/notification_topics': value => $decision_engine_notification_topics_real;
112 'watcher_decision_engine/publisher_id': value => $decision_engine_publisher_id;
113 'watcher_decision_engine/max_workers': value => $decision_engine_workers;
114 'watcher_decision_engine/continuous_audit_interval': value => 30;
115 }
116
117 watcher_config {
118 'watcher_planner/planner': value => $planner;
119 'watcher_planners.default/weights': value => $weights_real;
120 }
121
122}
diff --git a/deployment_scripts/modules/watcher/manifests/deps.pp b/deployment_scripts/modules/watcher/manifests/deps.pp
new file mode 100644
index 0000000..07ea460
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/deps.pp
@@ -0,0 +1,34 @@
1# == Class: watcher::deps
2#
3# watcher anchors and dependency management
4#
5class watcher::deps {
6 anchor { 'watcher::install::begin': }
7 -> Package<| tag == 'watcher-package'|>
8 ~> anchor { 'watcher::install::end': }
9 -> anchor { 'watcher::config::begin': }
10 -> Watcher_config<||>
11 ~> anchor { 'watcher::config::end': }
12 ~> anchor { 'watcher::db::begin': }
13 ~> anchor { 'watcher::db::end': }
14 ~> anchor { 'watcher::db::create_schema::begin': }
15 ~> anchor { 'watcher::db::create_schema::end': }
16 ~> anchor { 'watcher::db::upgrade::begin': }
17 ~> anchor { 'watcher::db::upgrade::end': }
18 ~> anchor { 'watcher::service::begin': }
19 ~> Service<| tag == 'watcher-service' |>
20 ~> anchor { 'watcher::service::end': }
21
22 # policy config should occur in the config block also.
23 Anchor['watcher::config::begin']
24 -> Openstacklib::Policy::Base<||>
25 ~> Anchor['watcher::config::end']
26
27 Anchor['watcher::install::end'] ~> Anchor['watcher::service::begin']
28 Anchor['watcher::config::end'] ~> Anchor['watcher::service::begin']
29
30 anchor { 'watcher-start':
31 require => Anchor['watcher::install::end'],
32 before => Anchor['watcher::config::begin'],
33 }
34}
diff --git a/deployment_scripts/modules/watcher/manifests/init.pp b/deployment_scripts/modules/watcher/manifests/init.pp
new file mode 100644
index 0000000..93fa57b
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/init.pp
@@ -0,0 +1,471 @@
1# == Class: watcher
2#
3# Full description of class watcher here.
4#
5# === Parameters:
6#
7# [*use_ssl*]
8# (required) Enable SSL on the API server.
9# Defaults to false.
10#
11# [*ceilometer_client_api_version*]
12# (required) Version of Ceilometer API to use in ceilometerclient.
13# Default is 2.
14#
15# [*cinder_client_api_version*]
16# (required) Version of Cinder API to use in cinderclient.
17# Default is 2.
18#
19# [*glance_client_api_version*]
20# (required) Version of Glance API to use in glanceclient.
21# Default is 2.
22#
23# [*neutron_client_api_version*]
24# (required) Version of Neutron API to use in neutronclient.
25# Default is 2.
26#
27# [*nova_client_api_version*]
28# (required) Version of Nova API to use in novaclient.
29# Default is 2.
30#
31# [*rpc_backend*]
32# (optional) The messaging driver to use, defaults to rabbit. Other drivers
33# include amqp and zmq.
34# Defaults to 'rabbit'.
35#
36# [*ensure_package*]
37# (optional) Whether the watcher api package will be installed
38# Defaults to 'present'
39#
40# [*rabbit_login_method*]
41# (optional) The RabbitMQ login method. (string value)
42# Defaults to $::os_service_default
43#
44# [*rabbit_retry_interval*]
45# (Optional) How frequently to retry connecting with RabbitMQ.
46# (integer value)
47# Defaults to $::os_service_default
48#
49# [*rabbit_retry_backoff*]
50# (Optional) How long to backoff for between retries when connecting
51# to RabbitMQ. (integer value)
52# Defaults to $::os_service_default
53#
54# [*rabbit_interval_max*]
55# (Optional) Maximum interval of RabbitMQ connection retries. (integer value)
56# Defaults to $::os_service_default
57#
58# [*rabbit_max_retries*]
59# (Optional) Maximum number of RabbitMQ connection retries. (integer value)
60# Defaults to $::os_service_default
61#
62# [*rabbit_use_ssl*]
63# (optional) Connect over SSL for RabbitMQ.
64# Defaults to $::os_service_default
65#
66# [*rabbit_heartbeat_rate*]
67# (optional) ow often times during the heartbeat_timeout_threshold we
68# check the heartbeat.
69# Defaults to $::os_service_default
70#
71# [*rabbit_ha_queues*]
72# (optional) Use HA queues in RabbitMQ (x-ha-policy: all). If you change this
73# option, you must wipe the RabbitMQ database.
74# Defaults to $::os_service_default
75#
76# [*rabbit_transient_queues_ttl*]
77# (Optional) Positive integer representing duration in seconds for
78# queue TTL (x-expires). Queues which are unused for the duration
79# of the TTL are automatically deleted.
80# The parameter affects only reply and fanout queues. (integer value)
81# Min to 1
82# Defaults to $::os_service_default
83#
84# [*rabbit_heartbeat_timeout_threshold*]
85# (Optional) Number of seconds after which the Rabbit broker is
86# considered down if heartbeat's keep-alive fails
87# (0 disable the heartbeat). EXPERIMENTAL. (integer value)
88# Defaults to $::os_service_default
89#
90# [*kombu_ssl_ca_certs*]
91# (optional) SSL certification authority file (valid only if SSL enabled).
92# Defaults to $::os_service_default
93#
94# [*kombu_ssl_certfile*]
95# (optional) SSL cert file (valid only if SSL enabled).
96# Defaults to $::os_service_default
97#
98# [*kombu_ssl_keyfile*]
99# (optional) SSL key file (valid only if SSL enabled).
100# Defaults to $::os_service_default
101#
102# [*kombu_ssl_version*]
103# (optional) SSL version to use (valid only if SSL enabled). Valid values are
104# TLSv1 and SSLv23. SSLv2, SSLv3, TLSv1_1, and TLSv1_2 may be
105# available on some distributions.
106# Defaults to $::os_service_default
107#
108# [*kombu_reconnect_delay*]
109# (optional) How long to wait before reconnecting in response to an AMQP
110# consumer cancel notification.
111# Defaults to $::os_service_default
112#
113# [*kombu_missing_consumer_retry_timeout*]
114# (optional)How long to wait a missing client beforce abandoning to send it
115# its replies. This value should not be longer than rpc_response_timeout.
116# Defaults to $::os_service_default
117#
118# [*kombu_failover_strategy*]
119# (Optional) Determines how the next RabbitMQ node is chosen in case the one
120# we are currently connected to becomes unavailable. Takes effect only if
121# more than one RabbitMQ node is provided in config. (string value)
122# Defaults to $::os_service_default
123#
124# [*kombu_compression*]
125# (optional) Possible values are: gzip, bz2. If not set compression will not
126# be used. This option may notbe available in future versions. EXPERIMENTAL.
127# (string value)
128# Defaults to $::os_service_default
129#
130# [*amqp_durable_queues*]
131# (optional) Use durable queues in AMQP.
132# Defaults to $::os_service_default
133#
134# [*default_transport_url*]
135# (Optional) A URL representing the messaging driver to use and its full
136# configuration. If not set, we fall back to the rpc_backend option
137# and driver specific configuration.
138# Defaults to $::os_service_default
139#
140# [*rpc_response_timeout*]
141# (Optional) Seconds to wait for a response from a call.
142# Defaults to $::os_service_default
143#
144# [*control_exchange*]
145# (Optional) The default exchange under which topics are scoped. May be
146# overridden by an exchange name specified in the transport_url
147# option.
148# Defaults to $::os_service_default
149#
150# [*amqp_password*]
151# (Optional) Password for message broker authentication.
152# Defaults to $::os_service_default
153#
154# [*amqp_username*]
155# (Optional) User name for message broker authentication.
156# Defaults to $::os_service_default
157#
158# [*amqp_ssl_ca_file*]
159# (Optional) CA certificate PEM file to verify server certificate.
160# Defaults to $::os_service_default
161#
162# [*amqp_ssl_key_file*]
163# (Optional) Private key PEM file used to sign cert_file certificate.
164# Defaults to $::os_service_default
165#
166# [*amqp_container_name*]
167# (Optional) Name for the AMQP container.
168# Defaults to $::os_service_default
169#
170# [*amqp_sasl_mechanisms*]
171# (Optional) Space separated list of acceptable SASL mechanisms.
172# Defaults to $::os_service_default
173#
174# [*amqp_server_request_prefix*]
175# (Optional) Address prefix used when sending to a specific server.
176# Defaults to $::os_service_default
177#
178# [*amqp_ssl_key_password*]
179# (Optional) Password for decrypting ssl_key_file (if encrypted).
180# Defaults to $::os_service_default
181#
182# [*amqp_idle_timeout*]
183# (Optional) Timeout for inactive connections (in seconds).
184# Defaults to $::os_service_default
185#
186# [*amqp_ssl_cert_file*]
187# (Optional) Identifying certificate PEM file to present to clients.
188# Defaults to $::os_service_default
189#
190# [*amqp_broadcast_prefix*]
191# (Optional) Address prefix used when broadcasting to all servers.
192# Defaults to $::os_service_default
193#
194# [*amqp_trace*]
195# (Optional) Debug: dump AMQP frames to stdout.
196# Defaults to $::os_service_default
197#
198# [*amqp_allow_insecure_clients*]
199# (Optional) Accept clients using either SSL or plain TCP.
200# Defaults to $::os_service_default
201#
202# [*amqp_sasl_config_name*]
203# (Optional) Name of configuration file (without .conf suffix).
204# Defaults to $::os_service_default
205#
206# [*amqp_sasl_config_dir*]
207# (Optional) Path to directory that contains the SASL configuration.
208# Defaults to $::os_service_default
209#
210# [*amqp_group_request_prefix*]
211# (Optional) Address prefix when sending to any server in group.
212# Defaults to $::os_service_default
213#
214# [*rpc_cast_timeout*]
215# (optional) Seconds to wait before a cast expires (TTL).
216# The default value of -1 specifies an infinite linger
217# period. The value of 0 specifies no linger period.
218# Pending messages shall be discarded immediately
219# when the socket is closed. Only supported by impl_zmq.
220# Defaults to $::os_service_default.
221#
222# [*rpc_poll_timeout*]
223# (optional) The default number of seconds that poll should wait.
224# Poll raises timeout exception when timeout expired.
225# Defaults to $::os_service_default.
226#
227# [*rpc_zmq_bind_address*]
228# (optional) ZeroMQ bind address.
229# Should be a wildcard (*), an ethernet interface, or IP.
230# The "host" option should point or resolve to this address.
231# Defaults to $::os_service_default.
232#
233# [*rpc_zmq_bind_port_retries*]
234# (optional) Number of retries to find free port number
235# before fail with ZMQBindError.
236# Defaults to $::os_service_default.
237#
238# [*rpc_zmq_concurrency*]
239# (optional) Type of concurrency used.
240# Either "native" or "eventlet".
241# Defaults to $::os_service_default.
242#
243# [*rpc_zmq_contexts*]
244# (optional) Number of ZeroMQ contexts.
245# Defaults to $::os_service_default.
246#
247# [*rpc_zmq_host*]
248# (optional) Name of this node.
249# Must be a valid hostname, FQDN, or IP address.
250# Must match "host" option, if running Nova.
251# Defaults to $::os_service_default.
252#
253# [*rpc_zmq_ipc_dir*]
254# (optional) Directory for holding IPC sockets.
255# Defaults to $::os_service_default.
256#
257# [*rpc_zmq_matchmaker*]
258# (optional) MatchMaker driver.
259# Defaults to $::os_service_default.
260#
261# [*rpc_zmq_max_port*]
262# (optional) Maximal port number for random ports range.
263# Defaults to $::os_service_default.
264#
265# [*rpc_zmq_min_port*]
266# (optional) Minimal port number for random ports range.
267# Defaults to $::os_service_default.
268#
269# [*rpc_zmq_topic_backlog*]
270# (optional) Maximum number of ingress messages to locally buffer per topic.
271# Defaults to $::os_service_default.
272#
273# [*use_pub_sub*]
274# (optional) Use PUB/SUB pattern for fanout methods.
275# PUB/SUB always uses proxy.
276# Defaults to $::os_service_default.
277#
278# [*zmq_target_expire*]
279# (optional) Expiration timeout in seconds of a name service
280# record about existing target ( < 0 means no timeout).
281# Defaults to $::os_service_default.
282#
283# [*notification_transport_url*]
284# (optional) A URL representing the messaging driver to use for notifications
285# and its full configuration. Transport URLs take the form:
286# transport://user:pass@host1:port[,hostN:portN]/virtual_host
287# Defaults to $::os_service_default
288#
289# [*notification_driver*]
290# (optional) Driver or drivers to handle sending notifications.
291# Value can be a string or a list.
292# Defaults to $::os_service_default
293#
294# [*notification_topics*]
295# (optional) AMQP topic used for OpenStack notifications
296# Defaults to $::os_service_default
297#
298# [*purge_config*]
299# (optional) Whether to set only the specified config options
300# in the watcher config.
301# Defaults to false.
302#
303# === Authors
304#
305# Daniel Pawlik <daniel.pawlik@corp.ovh.com>
306#
307class watcher (
308 $purge_config = false,
309 $use_ssl = false,
310 $ceilometer_client_api_version = '2',
311 $cinder_client_api_version = '2',
312 $glance_client_api_version = '2',
313 $neutron_client_api_version = '2',
314 $nova_client_api_version = '2',
315 $rpc_backend = 'rabbit',
316 $ensure_package = 'present',
317 $database_connection = undef,
318 $database_idle_timeout = undef,
319 $database_min_pool_size = undef,
320 $database_max_pool_size = undef,
321 $database_max_retries = undef,
322 $database_retry_interval = undef,
323 $database_max_overflow = undef,
324 $rabbit_os_user,
325 $rabbit_os_password,
326 $rabbit_os_host,
327 $rabbit_login_method = $::os_service_default,
328 $rabbit_retry_interval = $::os_service_default,
329 $rabbit_retry_backoff = $::os_service_default,
330 $rabbit_interval_max = $::os_service_default,
331 $rabbit_max_retries = $::os_service_default,
332 $rabbit_use_ssl = $::os_service_default,
333 $rabbit_heartbeat_rate = $::os_service_default,
334 $rabbit_ha_queues = $::os_service_default,
335 $rabbit_transient_queues_ttl = $::os_service_default,
336 $rabbit_heartbeat_timeout_threshold = $::os_service_default,
337 $kombu_ssl_ca_certs = $::os_service_default,
338 $kombu_ssl_certfile = $::os_service_default,
339 $kombu_ssl_keyfile = $::os_service_default,
340 $kombu_ssl_version = $::os_service_default,
341 $kombu_reconnect_delay = $::os_service_default,
342 $kombu_missing_consumer_retry_timeout = $::os_service_default,
343 $kombu_failover_strategy = $::os_service_default,
344 $kombu_compression = $::os_service_default,
345 $amqp_durable_queues = $::os_service_default,
346 $default_transport_url = $::os_service_default,
347 $rpc_response_timeout = $::os_service_default,
348 $control_exchange = $::os_service_default,
349 # amqp
350 $amqp_username = $::os_service_default,
351 $amqp_password = $::os_service_default,
352 $amqp_ssl_ca_file = $::os_service_default,
353 $amqp_ssl_key_file = $::os_service_default,
354 $amqp_container_name = $::os_service_default,
355 $amqp_sasl_mechanisms = $::os_service_default,
356 $amqp_server_request_prefix = $::os_service_default,
357 $amqp_ssl_key_password = $::os_service_default,
358 $amqp_idle_timeout = $::os_service_default,
359 $amqp_ssl_cert_file = $::os_service_default,
360 $amqp_broadcast_prefix = $::os_service_default,
361 $amqp_trace = $::os_service_default,
362 $amqp_allow_insecure_clients = $::os_service_default,
363 $amqp_sasl_config_name = $::os_service_default,
364 $amqp_sasl_config_dir = $::os_service_default,
365 $amqp_group_request_prefix = $::os_service_default,
366 # zmq
367 $rpc_cast_timeout = $::os_service_default,
368 $rpc_poll_timeout = $::os_service_default,
369 $rpc_zmq_bind_address = $::os_service_default,
370 $rpc_zmq_bind_port_retries = $::os_service_default,
371 $rpc_zmq_concurrency = $::os_service_default,
372 $rpc_zmq_contexts = $::os_service_default,
373 $rpc_zmq_host = $::os_service_default,
374 $rpc_zmq_ipc_dir = $::os_service_default,
375 $rpc_zmq_matchmaker = $::os_service_default,
376 $rpc_zmq_max_port = $::os_service_default,
377 $rpc_zmq_min_port = $::os_service_default,
378 $rpc_zmq_topic_backlog = $::os_service_default,
379 $use_pub_sub = $::os_service_default,
380 $zmq_target_expire = $::os_service_default,
381 # messaging
382 $notification_transport_url = $::os_service_default,
383 $notification_driver = $::os_service_default,
384 $notification_topics = $::os_service_default,
385 $auth_uri = $::os_service_default,
386 $auth_url = $::os_service_default,
387 $identity_uri = $::os_service_default,
388 $admin_user = 'watcher',
389 $admin_password = $::os_service_default,
390 $username = $::os_service_default,
391 $password = $::os_service_default,
392 $admin_tenant_name = 'services',
393 $user_domain_name = 'Default',
394 $project_domain_name = 'Default',
395 $region_name = $::os_service_default,
396 $nova_scheduler_default_filters = $::os_service_default,
397 $nova_ram_allocation_ratio = $::os_service_default,
398 $nova_scheduler_driver = $::os_service_default,
399 $nova_disk_allocation_ratio = $::os_service_default,
400 $nova_cpu_allocation_ratio = $::os_service_default,
401 $nova_max_instances_per_host = $::os_service_default,
402 $nova_scheduler_available_filters = $::os_service_default,
403) {
404
405 include ::openstacklib::openstackclient
406
407 include ::watcher::deps
408 include ::watcher::params
409 include ::watcher::policy
410 include ::watcher::db
411 include ::watcher::logging
412
413 package { 'watcher':
414 ensure => $ensure_package,
415 name => $::watcher::params::common_package_name,
416 tag => ['openstack', 'watcher-package'],
417 }
418
419 resources { 'watcher_config':
420 purge => $purge_config,
421 }
422
423 if $rpc_backend == 'rabbit' {
424
425 watcher_config {
426 'oslo_messaging_rabbit/rabbit_userid' : value => $rabbit_os_user;
427 'oslo_messaging_rabbit/rabbit_password' : value => $rabbit_os_password;
428 'oslo_messaging_rabbit/rabbit_hosts' : value => $rabbit_os_host;
429 'oslo_messaging_rabbit/rabbit_ha_queues': value => $rabbit_ha_queues;
430 }
431 } else {
432 watcher_config { 'DEFAULT/rpc_backend': value => $rpc_backend }
433 }
434
435
436 watcher_config {
437 'DEFAULT/scheduler_default_filters': value => $nova_scheduler_default_filters;
438 'DEFAULT/ram_allocation_ratio': value => $nova_ram_allocation_ratio;
439 'DEFAULT/scheduler_driver': value => $nova_scheduler_driver;
440 'DEFAULT/disk_allocation_ratio': value => $nova_disk_allocation_ratio;
441 'DEFAULT/cpu_allocation_ratio': value => $nova_cpu_allocation_ratio;
442 'DEFAULT/max_instances_per_host': value => $nova_max_instances_per_host;
443 'DEFAULT/scheduler_available_filters': value => $nova_scheduler_available_filters;
444 'keystone_authtoken/region_name': value => $region_name;
445 'keystone_authtoken/auth_uri' : value => $auth_uri;
446 'keystone_authtoken/auth_url' : value => $auth_url;
447 'keystone_authtoken/identity_uri' : value => $identity_uri;
448 'keystone_authtoken/admin_user' : value => $admin_user;
449 'keystone_authtoken/admin_password' : value => $admin_password;
450 'keystone_authtoken/username' : value => $username;
451 'keystone_authtoken/project_name' : value => $admin_tenant_name;
452 'keystone_authtoken/admin_tenant_name' : value => $admin_tenant_name;
453 'keystone_authtoken/password' : value => $password;
454 'keystone_authtoken/user_domain_name' : value => $user_domain_name;
455 'keystone_authtoken/project_domain_name' : value => $project_domain_name;
456 }
457
458
459 watcher_config {
460 'oslo_messaging_default/transport_url': value => $default_transport_url;
461 'oslo_messaging_default/rpc_response_timeout': value => $rpc_response_timeout;
462 'oslo_messaging_default/control_exchange': value => $control_exchange;
463 }
464
465 watcher_config {
466 'oslo_messaging_notification/transport_url': value => $notification_transport_url;
467 'oslo_messaging_notification/driver': value => $notification_driver;
468 'oslo_messaging_notification/topics': value => $notification_topics;
469 }
470}
471
diff --git a/deployment_scripts/modules/watcher/manifests/keystone/auth.pp b/deployment_scripts/modules/watcher/manifests/keystone/auth.pp
new file mode 100644
index 0000000..94a6667
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/keystone/auth.pp
@@ -0,0 +1,101 @@
1# == Class: watcher::keystone::auth
2#
3# Configures watcher user, service and endpoint in Keystone.
4#
5# === Parameters
6#
7# [*password*]
8# (required) Password for watcher user.
9#
10# [*auth_name*]
11# Username for watcher service. Defaults to 'watcher'.
12#
13# [*email*]
14# Email for watcher user. Defaults to 'watcher@localhost'.
15#
16# [*tenant*]
17# Tenant for watcher user. Defaults to 'services'.
18#
19# [*configure_endpoint*]
20# Should watcher endpoint be configured? Defaults to 'true'.
21#
22# [*configure_user*]
23# (Optional) Should the service user be configured?
24# Defaults to 'true'.
25#
26# [*configure_user_role*]
27# (Optional) Should the admin role be configured for the service user?
28# Defaults to 'true'.
29#
30# [*service_type*]
31# Type of service. Defaults to 'key-manager'.
32#
33# [*region*]
34# Region for endpoint. Defaults to 'RegionOne'.
35#
36# [*service_name*]
37# (optional) Name of the service.
38# Defaults to the value of auth_name.
39#
40# [*service_description*]
41# (optional) Description of the service.
42# Default to 'watcher API Service'
43#
44# [*public_url*]
45# (optional) The endpoint's public url. (Defaults to 'http://127.0.0.1:9322')
46# This url should *not* contain any trailing '/'.
47#
48# [*admin_url*]
49# (optional) The endpoint's admin url. (Defaults to 'http://127.0.0.1:9322')
50# This url should *not* contain any trailing '/'.
51#
52# [*internal_url*]
53# (optional) The endpoint's internal url. (Defaults to 'http://127.0.0.1:9322')
54#
55class watcher::keystone::auth (
56 $password,
57 $auth_name = 'watcher',
58 $email = 'watcher@localhost',
59 $tenant = 'services',
60 $configure_endpoint = true,
61 $configure_user = true,
62 $configure_user_role = true,
63 $service_name = undef,
64 $service_description = 'Infrastructure Optimization service',
65 $service_type = 'infra-optim',
66 $region = 'RegionOne',
67 $public_url = 'http://127.0.0.1:9322',
68 $admin_url = 'http://127.0.0.1:9322',
69 $internal_url = 'http://127.0.0.1:9322',
70) {
71
72 include ::watcher::deps
73
74 $real_service_name = pick($service_name, $auth_name)
75
76 if $configure_user_role {
77 Keystone_user_role["${auth_name}@${tenant}"] ~> Anchor['watcher::service::end']
78 }
79
80 if $configure_endpoint {
81 Keystone_endpoint["${region}/${real_service_name}::${service_type}"] ~> Anchor['watcher::service::end']
82 }
83
84 keystone::resource::service_identity { 'watcher':
85 configure_user => $configure_user,
86 configure_user_role => $configure_user_role,
87 configure_endpoint => $configure_endpoint,
88 service_name => $real_service_name,
89 service_type => $service_type,
90 service_description => $service_description,
91 region => $region,
92 auth_name => $auth_name,
93 password => $password,
94 email => $email,
95 tenant => $tenant,
96 public_url => $public_url,
97 internal_url => $internal_url,
98 admin_url => $admin_url,
99 }
100
101}
diff --git a/deployment_scripts/modules/watcher/manifests/keystone/authtoken.pp b/deployment_scripts/modules/watcher/manifests/keystone/authtoken.pp
new file mode 100644
index 0000000..2d7d1aa
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/keystone/authtoken.pp
@@ -0,0 +1,274 @@
1# == Class: watcher::keystone::authtoken
2#
3# Configure the keystone_authtoken section in the configuration file
4#
5# === Parameters:
6#
7# [*password*]
8# (Optional) Password to create for the service user
9# Defaults to $::os_service_default
10#
11# [*username*]
12# (Optional) The name of the service user
13# Defaults to 'watcher'
14#
15# [*auth_url*]
16# (Optional) The URL to use for authentication.
17# Defaults to 'http://localhost:35357'
18#
19# [*project_name*]
20# (Optional) Service project name
21# Defaults to 'services'
22#
23# [*user_domain_name*]
24# (Optional) Name of domain for $username
25# Defaults to $::os_service_default
26#
27# [*project_domain_name*]
28# (Optional) Name of domain for $project_name
29# Defaults to $::os_service_default
30#
31# [*insecure*]
32# (Optional) If true, explicitly allow TLS without checking server cert
33# against any certificate authorities. WARNING: not recommended. Use with
34# caution.
35# Defaults to $:os_service_default
36#
37# [*auth_section*]
38# (Optional) Config Section from which to load plugin specific options
39# Defaults to $::os_service_default.
40#
41# [*auth_type*]
42# (Optional) Authentication type to load
43# Defaults to 'password'
44#
45# [*auth_uri*]
46# (Optional) Complete public Identity API endpoint.
47# Defaults to 'http://localhost:5000'
48#
49# [*auth_version*]
50# (Optional) API version of the admin Identity API endpoint.
51# Defaults to $::os_service_default.
52#
53# [*cache*]
54# (Optional) Env key for the swift cache.
55# Defaults to $::os_service_default.
56#
57# [*cafile*]
58# (Optional) A PEM encoded Certificate Authority to use when verifying HTTPs
59# connections.
60# Defaults to $::os_service_default.
61#
62# [*certfile*]
63# (Optional) Required if identity server requires client certificate
64# Defaults to $::os_service_default.
65#
66# [*check_revocations_for_cached*]
67# (Optional) If true, the revocation list will be checked for cached tokens.
68# This requires that PKI tokens are configured on the identity server.
69# boolean value.
70# Defaults to $::os_service_default.
71#
72# [*delay_auth_decision*]
73# (Optional) Do not handle authorization requests within the middleware, but
74# delegate the authorization decision to downstream WSGI components. Boolean
75# value
76# Defaults to $::os_service_default.
77#
78# [*enforce_token_bind*]
79# (Optional) Used to control the use and type of token binding. Can be set
80# to: "disabled" to not check token binding. "permissive" (default) to
81# validate binding information if the bind type is of a form known to the
82# server and ignore it if not. "strict" like "permissive" but if the bind
83# type is unknown the token will be rejected. "required" any form of token
84# binding is needed to be allowed. Finally the name of a binding method that
85# must be present in tokens. String value.
86# Defaults to $::os_service_default.
87#
88# [*hash_algorithms*]
89# (Optional) Hash algorithms to use for hashing PKI tokens. This may be a
90# single algorithm or multiple. The algorithms are those supported by Python
91# standard hashlib.new(). The hashes will be tried in the order given, so put
92# the preferred one first for performance. The result of the first hash will
93# be stored in the cache. This will typically be set to multiple values only
94# while migrating from a less secure algorithm to a more secure one. Once all
95# the old tokens are expired this option should be set to a single value for
96# better performance. List value.
97# Defaults to $::os_service_default.
98#
99# [*http_connect_timeout*]
100# (Optional) Request timeout value for communicating with Identity API
101# server.
102# Defaults to $::os_service_default.
103#
104# [*http_request_max_retries*]
105# (Optional) How many times are we trying to reconnect when communicating
106# with Identity API Server. Integer value
107# Defaults to $::os_service_default.
108#
109# [*include_service_catalog*]
110# (Optional) Indicate whether to set the X-Service-Catalog header. If False,
111# middleware will not ask for service catalog on token validation and will
112# not set the X-Service-Catalog header. Boolean value.
113# Defaults to $::os_service_default.
114#
115# [*keyfile*]
116# (Optional) Required if identity server requires client certificate
117# Defaults to $::os_service_default.
118#
119# [*memcache_pool_conn_get_timeout*]
120# (Optional) Number of seconds that an operation will wait to get a memcached
121# client connection from the pool. Integer value
122# Defaults to $::os_service_default.
123#
124# [*memcache_pool_dead_retry*]
125# (Optional) Number of seconds memcached server is considered dead before it
126# is tried again. Integer value
127# Defaults to $::os_service_default.
128#
129# [*memcache_pool_maxsize*]
130# (Optional) Maximum total number of open connections to every memcached
131# server. Integer value
132# Defaults to $::os_service_default.
133#
134# [*memcache_pool_socket_timeout*]
135# (Optional) Number of seconds a connection to memcached is held unused in
136# the
137# pool before it is closed. Integer value
138# Defaults to $::os_service_default.
139#
140# [*memcache_pool_unused_timeout*]
141# (Optional) Number of seconds a connection to memcached is held unused in
142# the
143# pool before it is closed. Integer value
144# Defaults to $::os_service_default.
145#
146# [*memcache_secret_key*]
147# (Optional, mandatory if memcache_security_strategy is defined) This string
148# is used for key derivation.
149# Defaults to $::os_service_default.
150#
151# [*memcache_security_strategy*]
152# (Optional) If defined, indicate whether token data should be authenticated
153# or authenticated and encrypted. If MAC, token data is authenticated (with
154# HMAC) in the cache. If ENCRYPT, token data is encrypted and authenticated
155# in the cache. If the value is not one of these options or empty,
156# auth_token will raise an exception on initialization.
157# Defaults to $::os_service_default.
158#
159# [*memcache_use_advanced_pool*]
160# (Optional) Use the advanced (eventlet safe) memcached client pool. The
161# advanced pool will only work under python 2.x Boolean value
162# Defaults to $::os_service_default.
163#
164# [*memcached_servers*]
165# (Optional) Optionally specify a list of memcached server(s) to use for
166# caching. If left undefined, tokens will instead be cached in-process.
167# Defaults to $::os_service_default.
168#
169# [*manage_memcache_package*]
170# (Optional) Whether to install the python-memcache package.
171# Defaults to false.
172#
173# [*region_name*]
174# (Optional) The region in which the identity server can be found.
175# Defaults to $::os_service_default.
176#
177# [*revocation_cache_time*]
178# (Optional) Determines the frequency at which the list of revoked tokens is
179# retrieved from the Identity service (in seconds). A high number of
180# revocation events combined with a low cache duration may significantly
181# reduce performance. Only valid for PKI tokens. Integer value
182# Defaults to $::os_service_default.
183#
184# [*token_cache_time*]
185# (Optional) In order to prevent excessive effort spent validating tokens,
186# the middleware caches previously-seen tokens for a configurable duration
187# (in seconds). Set to -1 to disable caching completely. Integer value
188# Defaults to $::os_service_default.
189#
190class watcher::keystone::authtoken (
191 $password = $::os_service_default,
192 $username = 'watcher',
193 $auth_url = 'http://localhost:35357',
194 $project_name = 'services',
195 $user_domain_name = $::os_service_default,
196 $project_domain_name = $::os_service_default,
197 $insecure = $::os_service_default,
198 $auth_section = $::os_service_default,
199 $auth_type = 'password',
200 $auth_uri = 'http://localhost:5000',
201 $auth_version = $::os_service_default,
202 $cache = $::os_service_default,
203 $cafile = $::os_service_default,
204 $certfile = $::os_service_default,
205 $check_revocations_for_cached = $::os_service_default,
206 $delay_auth_decision = $::os_service_default,
207 $enforce_token_bind = $::os_service_default,
208 $hash_algorithms = $::os_service_default,
209 $http_connect_timeout = $::os_service_default,
210 $http_request_max_retries = $::os_service_default,
211 $include_service_catalog = $::os_service_default,
212 $keyfile = $::os_service_default,
213 $memcache_pool_conn_get_timeout = $::os_service_default,
214 $memcache_pool_dead_retry = $::os_service_default,
215 $memcache_pool_maxsize = $::os_service_default,
216 $memcache_pool_socket_timeout = $::os_service_default,
217 $memcache_secret_key = $::os_service_default,
218 $memcache_security_strategy = $::os_service_default,
219 $memcache_use_advanced_pool = $::os_service_default,
220 $memcache_pool_unused_timeout = $::os_service_default,
221 $memcached_servers = $::os_service_default,
222 $manage_memcache_package = false,
223 $region_name = $::os_service_default,
224 $revocation_cache_time = $::os_service_default,
225 $token_cache_time = $::os_service_default,
226) {
227
228 include ::watcher::deps
229
230 if is_service_default($password) and ! $::watcher::api::watcher_client_password {
231 fail('Please set password for watcher service user')
232 }
233
234 validate_string($password)
235
236 keystone::resource::authtoken { 'watcher_config':
237 password => $password,
238 username => $username,
239 project_name => $project_name,
240 auth_url => $auth_url,
241 auth_uri => $auth_uri,
242 auth_version => $auth_version,
243 auth_type => $auth_type,
244 auth_section => $auth_section,
245 user_domain_name => $user_domain_name,
246 project_domain_name => $project_domain_name,
247 insecure => $insecure,
248 cache => $cache,
249 cafile => $cafile,
250 certfile => $certfile,
251 check_revocations_for_cached => $check_revocations_for_cached,
252 delay_auth_decision => $delay_auth_decision,
253 enforce_token_bind => $enforce_token_bind,
254 hash_algorithms => $hash_algorithms,
255 http_connect_timeout => $http_connect_timeout,
256 http_request_max_retries => $http_request_max_retries,
257 include_service_catalog => $include_service_catalog,
258 keyfile => $keyfile,
259 memcache_pool_conn_get_timeout => $memcache_pool_conn_get_timeout,
260 memcache_pool_dead_retry => $memcache_pool_dead_retry,
261 memcache_pool_maxsize => $memcache_pool_maxsize,
262 memcache_pool_socket_timeout => $memcache_pool_socket_timeout,
263 memcache_secret_key => $memcache_secret_key,
264 memcache_security_strategy => $memcache_security_strategy,
265 memcache_use_advanced_pool => $memcache_use_advanced_pool,
266 memcache_pool_unused_timeout => $memcache_pool_unused_timeout,
267 memcached_servers => $memcached_servers,
268 manage_memcache_package => $manage_memcache_package,
269 region_name => $region_name,
270 revocation_cache_time => $revocation_cache_time,
271 token_cache_time => $token_cache_time,
272 }
273
274}
diff --git a/deployment_scripts/modules/watcher/manifests/logging.pp b/deployment_scripts/modules/watcher/manifests/logging.pp
new file mode 100644
index 0000000..ca34a18
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/logging.pp
@@ -0,0 +1,118 @@
1# Class watcher::logging
2#
3# watcher logging configuration
4#
5# == parameters
6#
7# [*debug*]
8# (Optional) Should the daemons log debug messages
9# Defaults to $::os_service_default
10#
11# [*use_syslog*]
12# (Optional) Use syslog for logging.
13# Defaults to $::os_service_default
14#
15# [*use_stderr*]
16# (optional) Use stderr for logging
17# Defaults to $::os_service_default
18#
19# [*syslog_log_facility*]
20# (Optional) Syslog facility to receive log lines.
21# Defaults to $::os_service_default
22#
23# [*log_dir*]
24# (optional) Directory where logs should be stored.
25# If set to $::os_service_default, it will not log to any directory.
26# Defaults to '/var/log/watcher'.
27#
28# [*log_file*]
29# (optional) File where logs should be stored.
30# Defaults to '/var/log/watcher/watcher.log'
31#
32# [*logging_context_format_string*]
33# (optional) Format string to use for log messages with context.
34# Defaults to $::os_service_default
35# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
36# [%(request_id)s %(user_identity)s] %(instance)s%(message)s'
37#
38# [*logging_default_format_string*]
39# (optional) Format string to use for log messages without context.
40# Defaults to $::os_service_default
41# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
42# [-] %(instance)s%(message)s'
43#
44# [*logging_debug_format_suffix*]
45# (optional) Formatted data to append to log format when level is DEBUG.
46# Defaults to $::os_service_default
47# Example: '%(funcName)s %(pathname)s:%(lineno)d'
48#
49# [*logging_exception_prefix*]
50# (optional) Prefix each line of exception output with this format.
51# Defaults to $::os_service_default
52# Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s'
53#
54# [*log_config_append*]
55# (optional) The name of an additional logging configuration file.
56# Defaults to $::os_service_default
57# See https://docs.python.org/2/howto/logging.html
58#
59# [*default_log_levels*]
60# (optional) Hash of logger (keys) and level (values) pairs.
61# Defaults to $::os_service_default
62# Example:
63# { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
64# 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
65# 'oslo.messaging' => 'INFO', 'iso8601' => 'WARN',
66# 'requests.packages.urllib3.connectionpool' => 'WARN',
67# 'urllib3.connectionpool' => 'WARN',
68# 'websocket' => 'WARN', 'watchermiddleware' => 'WARN',
69# 'routes.middleware' => 'WARN', stevedore => 'WARN' }
70#
71# [*publish_errors*]
72# (optional) Publish error events (boolean value).
73# Defaults to $::os_service_default
74#
75# [*fatal_deprecations*]
76# (optional) Make deprecations fatal (boolean value)
77# Defaults to $::os_service_default
78#
79# [*instance_format*]
80# (optional) If an instance is passed with the log message, format it
81# like this (string value).
82# Defaults to undef.
83# Example: '[instance: %(uuid)s] '
84#
85# [*instance_uuid_format*]
86# (optional) If an instance UUID is passed with the log message, format
87# it like this (string value).
88# Defaults to $::os_service_default
89# Example: instance_uuid_format='[instance: %(uuid)s] '
90#
91# [*log_date_format*]
92# (optional) Format string for %%(asctime)s in log records.
93# Defaults to $::os_service_default
94# Example: 'Y-%m-%d %H:%M:%S'
95
96class watcher::logging(
97 $use_syslog = $::os_service_default,
98 $use_stderr = $::os_service_default,
99 $syslog_log_facility = $::os_service_default,
100 $log_dir = '/var/log/watcher',
101 $log_file = '/var/log/watcher/watcher.log',
102 $debug = $::os_service_default,
103 $logging_context_format_string = $::os_service_default,
104 $logging_default_format_string = $::os_service_default,
105 $logging_debug_format_suffix = $::os_service_default,
106 $logging_exception_prefix = $::os_service_default,
107 $log_config_append = $::os_service_default,
108 $default_log_levels = $::os_service_default,
109 $publish_errors = $::os_service_default,
110 $fatal_deprecations = $::os_service_default,
111 $instance_format = $::os_service_default,
112 $instance_uuid_format = $::os_service_default,
113 $log_date_format = $::os_service_default,
114) {
115
116 include ::watcher::deps
117
118}
diff --git a/deployment_scripts/modules/watcher/manifests/params.pp b/deployment_scripts/modules/watcher/manifests/params.pp
new file mode 100644
index 0000000..8d1ac98
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/params.pp
@@ -0,0 +1,29 @@
1# Parameters for puppet-watcher
2#
3class watcher::params {
4
5 case $::osfamily {
6 'RedHat': {
7 $api_service_name = 'openstack-watcher-api'
8 $api_package_name = 'openstack-watcher-api'
9 $common_package_name = 'openstack-watcher-common'
10 $applier_package_name = 'openstack-watcher-applier'
11 $applier_service_name = 'openstack-watcher-applier'
12 $decision_engine_package_name = 'openstack-watcher-decision-engine'
13 $decision_engine_service_name = 'openstack-watcher-decision-engine'
14 }
15 'Debian': {
16 $api_service_name = 'watcher-api'
17 $api_package_name = 'watcher-api'
18 $common_package_name = 'watcher-common'
19 $applier_package_name = 'watcher-applier'
20 $applier_service_name = 'watcher-applier'
21 $decision_engine_package_name = 'watcher-decision-engine'
22 $decision_engine_service_name = 'watcher-decision-engine'
23 }
24 default: {
25 fail("Unsupported osfamily: ${::osfamily} operatingsystem")
26 }
27
28 } # Case $::osfamily
29}
diff --git a/deployment_scripts/modules/watcher/manifests/policy.pp b/deployment_scripts/modules/watcher/manifests/policy.pp
new file mode 100644
index 0000000..21dd93f
--- /dev/null
+++ b/deployment_scripts/modules/watcher/manifests/policy.pp
@@ -0,0 +1,42 @@
1# == Class: watcher::policy
2#
3# Configure the watcher policies
4#
5# === Parameters
6#
7# [*policies*]
8# (optional) Set of policies to configure for watcher
9# Example :
10# {
11# 'watcher-context_is_admin' => {
12# 'key' => 'context_is_admin',
13# 'value' => 'true'
14# },
15# 'watcher-default' => {
16# 'key' => 'default',
17# 'value' => 'rule:admin_or_owner'
18# }
19# }
20# Defaults to empty hash.
21#
22# [*policy_path*]
23# (optional) Path to the nova policy.json file
24# Defaults to /etc/watcher/policy.json
25#
26class watcher::policy (
27 $policies = {},
28 $policy_path = '/etc/watcher/policy.json',
29) {
30
31 include ::watcher::deps
32
33 validate_hash($policies)
34
35 Openstacklib::Policy::Base {
36 file_path => $policy_path,
37 }
38
39 create_resources('openstacklib::policy::base', $policies)
40
41
42}
diff --git a/deployment_scripts/modules/watcher/metadata.json b/deployment_scripts/modules/watcher/metadata.json
new file mode 100644
index 0000000..f72cefe
--- /dev/null
+++ b/deployment_scripts/modules/watcher/metadata.json
@@ -0,0 +1,67 @@
1{
2 "name": "openstack-watcher",
3 "version": "10.3.0",
4 "author": "OpenStack Contributors",
5 "summary": "Puppet module for OpenStack Watcher",
6 "license": "Apache-2.0",
7 "source": "git://github.com/openstack/puppet-watcher.git",
8 "project_page": "https://launchpad.net/puppet-watcher",
9 "issues_url": "https://bugs.launchpad.net/puppet-watcher",
10 "description": "Installs and configures OpenStack Watcher.",
11 "requirements": [
12 {
13 "name": "pe",
14 "version_requirement": "4.x"
15 },
16 {
17 "name": "puppet",
18 "version_requirement": "4.x"
19 }
20 ],
21 "operatingsystem_support": [
22 {
23 "operatingsystem": "Debian",
24 "operatingsystemrelease": [
25 "8"
26 ]
27 },
28 {
29 "operatingsystem": "Fedora",
30 "operatingsystemrelease": [
31 "21",
32 "22"
33 ]
34 },
35 {
36 "operatingsystem": "RedHat",
37 "operatingsystemrelease": [
38 "7"
39 ]
40 },
41 {
42 "operatingsystem": "Ubuntu",
43 "operatingsystemrelease": [
44 "14.04",
45 "16.04"
46 ]
47 }
48 ],
49 "dependencies": [
50 {
51 "name": "puppetlabs/inifile",
52 "version_requirement": ">=1.0.0 <2.0.0"
53 },
54 {
55 "name": "puppetlabs/stdlib",
56 "version_requirement": ">= 4.2.0 <5.0.0"
57 },
58 {
59 "name": "openstack/openstacklib",
60 "version_requirement": ">=10.3.0 <11.0.0"
61 },
62 {
63 "name": "openstack/oslo",
64 "version_requirement": ">=10.3.0 <11.0.0"
65 }
66 ]
67}
diff --git a/deployment_scripts/modules/watcher/releasenotes/source/_static/.placeholder b/deployment_scripts/modules/watcher/releasenotes/source/_static/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/deployment_scripts/modules/watcher/releasenotes/source/_static/.placeholder
diff --git a/deployment_scripts/modules/watcher/releasenotes/source/conf.py b/deployment_scripts/modules/watcher/releasenotes/source/conf.py
new file mode 100644
index 0000000..dea0d42
--- /dev/null
+++ b/deployment_scripts/modules/watcher/releasenotes/source/conf.py
@@ -0,0 +1,262 @@
1# -*- coding: utf-8 -*-
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11# implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16# If extensions (or modules to document with autodoc) are in another directory,
17# add these directories to sys.path here. If the directory is relative to the
18# documentation root, use os.path.abspath to make it absolute, like shown here.
19#sys.path.insert(0, os.path.abspath('.'))
20
21# -- General configuration ------------------------------------------------
22
23# If your documentation needs a minimal Sphinx version, state it here.
24#needs_sphinx = '1.0'
25
26# Add any Sphinx extension module names here, as strings. They can be
27# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
28# ones.
29extensions = [
30 'oslosphinx',
31 'reno.sphinxext',
32]
33
34# Add any paths that contain templates here, relative to this directory.
35templates_path = ['_templates']
36
37# The suffix of source filenames.
38source_suffix = '.rst'
39
40# The encoding of source files.
41#source_encoding = 'utf-8-sig'
42
43# The master toctree document.
44master_doc = 'index'
45
46# General information about the project.
47project = u'puppet-watcher Release Notes'
48copyright = u'2016, Puppet OpenStack Developers'
49
50# The version info for the project you're documenting, acts as replacement for
51# |version| and |release|, also used in various other places throughout the
52# built documents.
53#
54# The short X.Y version.
55version = '10.3.0'
56# The full version, including alpha/beta/rc tags.
57release = '10.3.0'
58
59# The language for content autogenerated by Sphinx. Refer to documentation
60# for a list of supported languages.
61#language = None
62
63# There are two options for replacing |today|: either, you set today to some
64# non-false value, then it is used:
65#today = ''
66# Else, today_fmt is used as the format for a strftime call.
67#today_fmt = '%B %d, %Y'
68
69# List of patterns, relative to source directory, that match files and
70# directories to ignore when looking for source files.
71exclude_patterns = []
72
73# The reST default role (used for this markup: `text`) to use for all
74# documents.
75#default_role = None
76
77# If true, '()' will be appended to :func: etc. cross-reference text.
78#add_function_parentheses = True
79
80# If true, the current module name will be prepended to all description
81# unit titles (such as .. function::).
82#add_module_names = True
83
84# If true, sectionauthor and moduleauthor directives will be shown in the
85# output. They are ignored by default.
86#show_authors = False
87
88# The name of the Pygments (syntax highlighting) style to use.
89pygments_style = 'sphinx'
90
91# A list of ignored prefixes for module index sorting.
92#modindex_common_prefix = []
93
94# If true, keep warnings as "system message" paragraphs in the built documents.
95#keep_warnings = False
96
97
98# -- Options for HTML output ----------------------------------------------
99
100# The theme to use for HTML and HTML Help pages. See the documentation for
101# a list of builtin themes.
102html_theme = 'default'
103
104# Theme options are theme-specific and customize the look and feel of a theme
105# further. For a list of options available for each theme, see the
106# documentation.
107#html_theme_options = {}
108
109# Add any paths that contain custom themes here, relative to this directory.
110#html_theme_path = []
111
112# The name for this set of Sphinx documents. If None, it defaults to
113# "<project> v<release> documentation".
114#html_title = None
115
116# A shorter title for the navigation bar. Default is the same as html_title.
117#html_short_title = None
118
119# The name of an image file (relative to this directory) to place at the top
120# of the sidebar.
121#html_logo = None
122
123# The name of an image file (within the static path) to use as favicon of the
124# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
125# pixels large.
126#html_favicon = None
127
128# Add any paths that contain custom static files (such as style sheets) here,
129# relative to this directory. They are copied after the builtin static files,
130# so a file named "default.css" will overwrite the builtin "default.css".
131html_static_path = ['_static']
132
133# Add any extra paths that contain custom files (such as robots.txt or
134# .htaccess) here, relative to this directory. These files are copied
135# directly to the root of the documentation.
136#html_extra_path = []
137
138# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
139# using the given strftime format.
140#html_last_updated_fmt = '%b %d, %Y'
141
142# If true, SmartyPants will be used to convert quotes and dashes to
143# typographically correct entities.
144#html_use_smartypants = True
145
146# Custom sidebar templates, maps document names to template names.
147#html_sidebars = {}
148
149# Additional templates that should be rendered to pages, maps page names to
150# template names.
151#html_additional_pages = {}
152
153# If false, no module index is generated.
154#html_domain_indices = True
155
156# If false, no index is generated.
157#html_use_index = True
158
159# If true, the index is split into individual pages for each letter.
160#html_split_index = False
161
162# If true, links to the reST sources are added to the pages.
163#html_show_sourcelink = True
164
165# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
166#html_show_sphinx = True
167
168# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
169#html_show_copyright = True
170
171# If true, an OpenSearch description file will be output, and all pages will
172# contain a <link> tag referring to it. The value of this option must be the
173# base URL from which the finished HTML is served.
174#html_use_opensearch = ''
175
176# This is the file name suffix for HTML files (e.g. ".xhtml").
177#html_file_suffix = None
178
179# Output file base name for HTML help builder.
180htmlhelp_basename = 'puppet-watcherReleaseNotesdoc'
181
182
183# -- Options for LaTeX output ---------------------------------------------
184
185latex_elements = {
186# The paper size ('letterpaper' or 'a4paper').
187#'papersize': 'letterpaper',
188
189# The font size ('10pt', '11pt' or '12pt').
190#'pointsize': '10pt',
191
192# Additional stuff for the LaTeX preamble.
193#'preamble': '',
194}
195
196# Grouping the document tree into LaTeX files. List of tuples
197# (source start file, target name, title,
198# author, documentclass [howto, manual, or own class]).
199latex_documents = [
200 ('index', 'puppet-watcherReleaseNotes.tex', u'puppet-watcher Release Notes Documentation',
201 u'2016, Puppet OpenStack Developers', 'manual'),
202]
203
204# The name of an image file (relative to this directory) to place at the top of
205# the title page.
206#latex_logo = None
207
208# For "manual" documents, if this is true, then toplevel headings are parts,
209# not chapters.
210#latex_use_parts = False
211
212# If true, show page references after internal links.
213#latex_show_pagerefs = False
214
215# If true, show URL addresses after external links.
216#latex_show_urls = False
217
218# Documents to append as an appendix to all manuals.
219#latex_appendices = []
220
221# If false, no module index is generated.
222#latex_domain_indices = True
223
224
225# -- Options for manual page output ---------------------------------------
226
227# One entry per manual page. List of tuples
228# (source start file, name, description, authors, manual section).
229man_pages = [
230 ('index', 'puppet-watcherreleasenotes', u'puppet-watcher Release Notes Documentation',
231 [u'2016, Puppet OpenStack Developers'], 1)
232]
233
234# If true, show URL addresses after external links.
235#man_show_urls = False
236
237
238# -- Options for Texinfo output -------------------------------------------
239
240# Grouping the document tree into Texinfo files. List of tuples
241# (source start file, target name, title, author,
242# dir menu entry, description, category)
243texinfo_documents = [
244 ('index', 'puppet-watcherReleaseNotes', u'puppet-watcher Release Notes Documentation',
245 u'2016, Puppet OpenStack Developers', 'puppet-watcherReleaseNotes', 'One line description of project.',
246 'Miscellaneous'),
247]
248
249# Documents to append as an appendix to all manuals.
250#texinfo_appendices = []
251
252# If false, no module index is generated.
253#texinfo_domain_indices = True
254
255# How to display URL addresses: 'footnote', 'no', or 'inline'.
256#texinfo_show_urls = 'footnote'
257
258# If true, do not generate a @detailmenu in the "Top" node's menu.
259#texinfo_no_detailmenu = False
260
261# -- Options for Internationalization output ------------------------------
262locale_dirs = ['locale/']
diff --git a/deployment_scripts/modules/watcher/releasenotes/source/index.rst b/deployment_scripts/modules/watcher/releasenotes/source/index.rst
new file mode 100644
index 0000000..33cc3da
--- /dev/null
+++ b/deployment_scripts/modules/watcher/releasenotes/source/index.rst
@@ -0,0 +1,18 @@
1========================================
2Welcome to puppet-watcher Release Notes!
3========================================
4
5Contents
6========
7
8.. toctree::
9 :maxdepth: 2
10
11 unreleased
12
13
14Indices and tables
15==================
16
17* :ref:`genindex`
18* :ref:`search`
diff --git a/deployment_scripts/modules/watcher/releasenotes/source/unreleased.rst b/deployment_scripts/modules/watcher/releasenotes/source/unreleased.rst
new file mode 100644
index 0000000..2334dd5
--- /dev/null
+++ b/deployment_scripts/modules/watcher/releasenotes/source/unreleased.rst
@@ -0,0 +1,5 @@
1==============================
2 Current Series Release Notes
3==============================
4
5 .. release-notes::
diff --git a/deployment_scripts/modules/watcher/setup.cfg b/deployment_scripts/modules/watcher/setup.cfg
new file mode 100644
index 0000000..0112e0b
--- /dev/null
+++ b/deployment_scripts/modules/watcher/setup.cfg
@@ -0,0 +1,13 @@
1[metadata]
2name = puppet-watcher
3summary = Puppet module for OpenStack Watcher
4description-file =
5 README.md
6author = Puppet Labs and OpenStack Contributors
7author-email = openstack-dev@lists.openstack.org
8home-page = http://docs.openstack.org/developer/puppet-openstack-guide
9classifier =
10 Intended Audience :: Developers
11 Intended Audience :: System Administrators
12 License :: OSI Approved :: Apache Software License
13 Operating System :: POSIX :: Linux
diff --git a/deployment_scripts/modules/watcher/setup.py b/deployment_scripts/modules/watcher/setup.py
new file mode 100644
index 0000000..70c2b3f
--- /dev/null
+++ b/deployment_scripts/modules/watcher/setup.py
@@ -0,0 +1,22 @@
1#!/usr/bin/env python
2# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
18import setuptools
19
20setuptools.setup(
21 setup_requires=['pbr'],
22 pbr=True)
diff --git a/deployment_scripts/modules/watcher/spec/acceptance/nodesets/centos-70-x64.yml b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/centos-70-x64.yml
new file mode 100644
index 0000000..5f097e9
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/centos-70-x64.yml
@@ -0,0 +1,11 @@
1HOSTS:
2 centos-server-70-x64:
3 roles:
4 - master
5 platform: el-7-x86_64
6 box: puppetlabs/centos-7.0-64-nocm
7 box_url: https://vagrantcloud.com/puppetlabs/centos-7.0-64-nocm
8 hypervisor: vagrant
9CONFIG:
10 log_level: debug
11 type: foss
diff --git a/deployment_scripts/modules/watcher/spec/acceptance/nodesets/default.yml b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/default.yml
new file mode 100644
index 0000000..486b6a3
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/default.yml
@@ -0,0 +1,10 @@
1HOSTS:
2 ubuntu-server-14.04-amd64:
3 roles:
4 - master
5 platform: ubuntu-14.04-amd64
6 box: puppetlabs/ubuntu-14.04-64-nocm
7 box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
8 hypervisor: vagrant
9CONFIG:
10 type: foss
diff --git a/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-centos7.yml b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-centos7.yml
new file mode 100644
index 0000000..c552874
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-centos7.yml
@@ -0,0 +1,10 @@
1HOSTS:
2 centos-70-x64:
3 roles:
4 - master
5 platform: el-7-x86_64
6 hypervisor: none
7 ip: 127.0.0.1
8CONFIG:
9 type: foss
10 set_env: false
diff --git a/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-trusty.yml b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-trusty.yml
new file mode 100644
index 0000000..9fc624e
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-trusty.yml
@@ -0,0 +1,10 @@
1HOSTS:
2 ubuntu-14.04-amd64:
3 roles:
4 - master
5 platform: ubuntu-14.04-amd64
6 hypervisor: none
7 ip: 127.0.0.1
8CONFIG:
9 type: foss
10 set_env: false
diff --git a/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-xenial.yml b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-xenial.yml
new file mode 100644
index 0000000..99dd318
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/nodepool-xenial.yml
@@ -0,0 +1,10 @@
1HOSTS:
2 ubuntu-16.04-amd64:
3 roles:
4 - master
5 platform: ubuntu-16.04-amd64
6 hypervisor: none
7 ip: 127.0.0.1
8CONFIG:
9 type: foss
10 set_env: false
diff --git a/deployment_scripts/modules/watcher/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
new file mode 100644
index 0000000..8001929
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
@@ -0,0 +1,11 @@
1HOSTS:
2 ubuntu-server-14.04-amd64:
3 roles:
4 - master
5 platform: ubuntu-14.04-amd64
6 box: puppetlabs/ubuntu-14.04-64-nocm
7 box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
8 hypervisor: vagrant
9CONFIG:
10 log_level: debug
11 type: foss
diff --git a/deployment_scripts/modules/watcher/spec/acceptance/watcher_spec.rb b/deployment_scripts/modules/watcher/spec/acceptance/watcher_spec.rb
new file mode 100644
index 0000000..e7708ab
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/acceptance/watcher_spec.rb
@@ -0,0 +1,77 @@
1require 'spec_helper_acceptance'
2
3describe 'basic watcher' do
4
5 context 'default parameters' do
6
7 it 'should work with no errors' do
8 pp= <<-EOS
9 include ::openstack_integration
10 include ::openstack_integration::repos
11 include ::openstack_integration::rabbitmq
12 include ::openstack_integration::mysql
13 include ::openstack_integration::keystone
14
15 rabbitmq_user { 'watcher':
16 admin => true,
17 password => 'my_secret',
18 provider => 'rabbitmqctl',
19 require => Class['rabbitmq'],
20 }
21
22 rabbitmq_user_permissions { 'watcher@/':
23 configure_permission => '.*',
24 write_permission => '.*',
25 read_permission => '.*',
26 provider => 'rabbitmqctl',
27 require => Class['rabbitmq'],
28 }
29
30 # TODO(aschultz): fix after Ubuntu ocata-m3/rc1. watcher-db-manage is
31 # broken
32 if ($::osfamily == 'RedHat') {
33 class { '::watcher::db::mysql':
34 password => 'a_big_secret',
35 }
36 class { '::watcher::db':
37 database_connection => 'mysql+pymysql://watcher:a_big_secret@127.0.0.1/watcher?charset=utf8',
38 }
39 class { '::watcher::keystone::auth':
40 password => 'a_big_secret',
41 }
42 class { '::watcher::keystone::authtoken':
43 password => 'a_big_secret',
44 }
45 class { '::watcher::logging':
46 debug => true,
47 }
48 class { '::watcher':
49 default_transport_url => 'rabbit://watcher:my_secret@127.0.0.1:5672/',
50 }
51 class { '::watcher::api':
52 watcher_client_password => 'a_big_secret',
53 create_db_schema => true,
54 upgrade_db => true,
55 }
56 class { '::watcher::applier':
57 applier_workers => '2',
58 }
59 class { '::watcher::decision_engine':
60 decision_engine_workers => '2',
61 }
62 }
63 EOS
64
65 # Run it twice and test for idempotency
66 apply_manifest(pp, :catch_failures => true)
67 apply_manifest(pp, :catch_changes => true)
68 end
69
70 if os[:family].casecmp('RedHat') == 0
71 describe port(9322) do
72 it { is_expected.to be_listening }
73 end
74 end
75 end
76
77end
diff --git a/deployment_scripts/modules/watcher/spec/classes/watcher_api_spec.rb b/deployment_scripts/modules/watcher/spec/classes/watcher_api_spec.rb
new file mode 100644
index 0000000..40ddcef
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/classes/watcher_api_spec.rb
@@ -0,0 +1,161 @@
1require 'spec_helper'
2
3describe 'watcher::api' do
4
5 let :params do
6 { :watcher_client_password => 'password',
7 :manage_service => true,
8 :enabled => true,
9 :package_ensure => 'latest',
10 }
11 end
12
13 shared_examples 'watcher-api' do
14
15 context 'without required parameter watcher_client_password' do
16 before { params.delete(:watcher_client_password) }
17 it { expect { is_expected.to raise_error(Puppet::Error) } }
18 end
19
20 it { is_expected.to contain_class('watcher::params') }
21 it { is_expected.to contain_class('watcher::deps') }
22
23 it 'installs watcher-api package' do
24 is_expected.to contain_package('watcher-api').with(
25 :ensure => 'latest',
26 :name => platform_params[:api_package_name],
27 :tag => ['openstack', 'watcher-package'],
28 )
29 end
30
31 [{:enabled => true}, {:enabled => false}].each do |param_hash|
32 context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
33 before do
34 params.merge!(param_hash)
35 end
36
37 it 'configures watcher-api service' do
38 is_expected.to contain_service('watcher-api').with(
39 :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
40 :name => platform_params[:api_service_name],
41 :enable => params[:enabled],
42 :hasstatus => true,
43 :hasrestart => true,
44 :tag => ['watcher-service',
45 'watcher-db-manage-create_schema',
46 'watcher-db-manage-upgrade'],
47 )
48 end
49 end
50 end
51
52 context 'with default api configuration' do
53 it 'should configure the api configurations section when enabled' do
54 is_expected.to contain_watcher_config('api/port').with_value('9322')
55 is_expected.to contain_watcher_config('api/max_limit').with_value('<SERVICE DEFAULT>')
56 is_expected.to contain_watcher_config('api/host').with_value('0.0.0.0')
57 is_expected.to contain_watcher_config('api/workers').with_value(2)
58 is_expected.to contain_watcher_config('api/enable_ssl_api').with_value('<SERVICE DEFAULT>')
59 end
60 end
61
62 context 'with disabled service managing' do
63 before do
64 params.merge!({
65 :manage_service => false,
66 :enabled => false })
67 end
68
69 it 'configures watcher-api service' do
70 is_expected.to contain_service('watcher-api').with(
71 :ensure => nil,
72 :name => platform_params[:api_service_name],
73 :enable => false,
74 :hasstatus => true,
75 :hasrestart => true,
76 :tag => ['watcher-service',
77 'watcher-db-manage-create_schema',
78 'watcher-db-manage-upgrade'],
79 )
80 end
81
82 it 'should not configure the api configurations section when disabled' do
83 is_expected.to_not contain_watcher_config('api/port')
84 is_expected.to_not contain_watcher_config('api/max_limit')
85 is_expected.to_not contain_watcher_config('api/host')
86 is_expected.to_not contain_watcher_config('api/workers')
87 is_expected.to_not contain_watcher_config('api/enable_ssl_api')
88 end
89
90 end
91
92 context 'watcher clients auth section with default parameters' do
93 it 'configures watcher clients auth' do
94 is_expected.to contain_watcher_config('watcher_clients_auth/username').with_value('watcher')
95 is_expected.to contain_watcher_config('watcher_clients_auth/password').with_value( params[:watcher_client_password] )
96 is_expected.to contain_watcher_config('watcher_clients_auth/auth_url').with_value('http://localhost:35357/')
97 is_expected.to contain_watcher_config('watcher_clients_auth/auth_uri').with_value('http://localhost:5000/')
98 is_expected.to contain_watcher_config('watcher_clients_auth/project_name').with_value('service')
99 is_expected.to contain_watcher_config('watcher_clients_auth/project_domain_name').with_value('<SERVICE DEFAULT>')
100 is_expected.to contain_watcher_config('watcher_clients_auth/insecure').with_value('<SERVICE DEFAULT>')
101 is_expected.to contain_watcher_config('watcher_clients_auth/auth_type').with_value('password')
102 is_expected.to contain_watcher_config('watcher_clients_auth/cafile').with_value('<SERVICE DEFAULT>')
103 is_expected.to contain_watcher_config('watcher_clients_auth/certfile').with_value('<SERVICE DEFAULT>')
104 is_expected.to contain_watcher_config('watcher_clients_auth/keyfile').with_value('<SERVICE DEFAULT>')
105 end
106 end
107
108 context 'watcher clients auth section with overridden parameters' do
109 before do
110 params.merge! ({
111 :watcher_client_username => 'watcher_user',
112 :watcher_client_password => 'PassWoRD',
113 :watcher_client_auth_uri => 'http://localhost:5001/',
114 :watcher_client_auth_url => 'http://localhost:35358/',
115 :watcher_client_project_name => 'ProjectZero',
116 :watcher_client_project_domain_name => 'WatcherDomain',
117 :watcher_client_insecure => 'true',
118 :watcher_client_auth_type => 'password',
119 :watcher_client_cafile => '/tmp/ca.crt',
120 :watcher_client_certfile => '/tmp/watcher.com.crt',
121 :watcher_client_keyfile => '/tmp/key.pm',
122 })
123 end
124 it 'configures watcher clients auth' do
125 is_expected.to contain_watcher_config('watcher_clients_auth/username').with_value( params[:watcher_client_username] )
126 is_expected.to contain_watcher_config('watcher_clients_auth/password').with_value( params[:watcher_client_password] )
127 is_expected.to contain_watcher_config('watcher_clients_auth/auth_uri').with_value('http://localhost:5001/')
128 is_expected.to contain_watcher_config('watcher_clients_auth/auth_url').with_value('http://localhost:35358/')
129 is_expected.to contain_watcher_config('watcher_clients_auth/project_name').with_value( params[:watcher_client_project_name] )
130 is_expected.to contain_watcher_config('watcher_clients_auth/project_domain_name').with_value( params[:watcher_client_project_domain_name] )
131 is_expected.to contain_watcher_config('watcher_clients_auth/insecure').with_value( params[:watcher_client_insecure] )
132 is_expected.to contain_watcher_config('watcher_clients_auth/auth_type').with_value( params[:watcher_client_auth_type] )
133 is_expected.to contain_watcher_config('watcher_clients_auth/cafile').with_value( params[:watcher_client_cafile] )
134 is_expected.to contain_watcher_config('watcher_clients_auth/certfile').with_value( params[:watcher_client_certfile] )
135 is_expected.to contain_watcher_config('watcher_clients_auth/keyfile').with_value( params[:watcher_client_keyfile] )
136 end
137 end
138 end
139
140 on_supported_os({
141 :supported_os => OSDefaults.get_supported_os
142 }).each do |os,facts|
143 context "on #{os}" do
144 let (:facts) do
145 facts.merge!(OSDefaults.get_facts())
146 end
147 let(:platform_params) do
148 case facts[:osfamily]
149 when 'Debian'
150 { :api_package_name => 'watcher-api',
151 :api_service_name => 'watcher-api' }
152 when 'RedHat'
153 { :api_package_name => 'openstack-watcher-api',
154 :api_service_name => 'openstack-watcher-api' }
155 end
156 end
157 it_behaves_like 'watcher-api'
158 end
159 end
160
161end
diff --git a/deployment_scripts/modules/watcher/spec/classes/watcher_applier_spec.rb b/deployment_scripts/modules/watcher/spec/classes/watcher_applier_spec.rb
new file mode 100644
index 0000000..f5b98dd
--- /dev/null
+++ b/deployment_scripts/modules/watcher/spec/classes/watcher_applier_spec.rb
@@ -0,0 +1,93 @@
1require 'spec_helper'
2
3describe 'watcher::applier' do
4
5 shared_examples 'watcher-applier' do
6
7 context 'with default parameters' do
8
9 it 'installs packages' do
10 is_expected.to contain_package('watcher-applier').with(
11 :name => platform_params[:watcher_applier_package],
12 :ensure => 'present',
13 :tag => ['openstack', 'watcher-package']
14 )
15 end
16
17 it 'configures watcher applier service' do
18 is_expected.to contain_watcher_config('watcher_applier/workers').with_value('<SERVICE DEFAULT>')
19 is_expected.to contain_watcher_config('watcher_applier/conductor_topic').with_value('<SERVICE DEFAULT>')
20 is_expected.to contain_watcher_config('watcher_applier/status_topic').with_value('<SERVICE DEFAULT>')
21 is_expected.to contain_watcher_config('watcher_applier/publisher_id').with_value('<SERVICE DEFAULT>')
22 is_expected.to contain_watcher_config('watcher_applier/workflow_engine').with_value('<SERVICE DEFAULT>')
23 end
24 end
25
26 [{:enabled => true}, {:enabled => false}].each do |param_hash|
27 context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
28 let :params do
29 { :enabled => true,
30 :manage_service => true,
31 }
32 end
33 before do
34 params.merge!(param_hash)
35 end
36
37 it 'configures watcher applier service' do
38 is_expected.to contain_service('watcher-applier').with(
39 :ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
40 :name => platform_params[:applier_service_name],
41 :enable => params[:enabled],
42 :hasstatus => true,
43 :hasrestart => true,
44 :tag => ['watcher-service'],
45 )
46 end
47 end
48 end
49
50 context 'with overridden parameters' do
51 let :params do
52 {
53 :package_ensure => '2012.1.1-15.el6',
54 :applier_workers => '10',
55 :applier_conductor_topic => 'applier123',
56 :applier_status_topic => 'someStatus',
57 :applier_publisher_id => '20120101',
58 :applier_workflow_engine => 'taskFloooow',
59 }
60 end
61 it 'configures watcher applier' do
62 is_expected.to contain_watcher_config('watcher_applier/workers').with_value('10')
63 is_expected.to contain_watcher_config('watcher_applier/conductor_topic').with_value('applier123')
64 is_expected.to contain_watcher_config('watcher_applier/status_topic').with_value('someStatus')
65 is_expected.to contain_watcher_config('watcher_applier/publisher_id').with_value('20120101')
66 is_expected.to contain_watcher_config('watcher_applier/workflow_engine').with_value('taskFloooow')
67 end
68 end
69 end
70
71 on_supported_os({
72 :supported_os => OSDefaults.get_supported_os
73 }).each do |os,facts|
74 context "on #{os}" do
75 let (:facts) do
76 facts.merge!(OSDefaults.get_facts())
77 end
78 let(:platform_params) do
79 case facts[:osfamily]
80 when 'Debian'
81 { :watcher_applier_package => 'watcher-applier',
82