Browse Source

Trove fuel plugin changes for implementing new fuel Trove role.

Implements: blueprint fuel-plugin-dbaas-trove

Change-Id: I56719a1e1327c47c7725ba88fea7b7ddf2a56c03
Apsar, Shaik (sa709c) 3 years ago
parent
commit
219f2ff75d
77 changed files with 5899 additions and 56 deletions
  1. 50
    0
      deployment_scripts/puppet/manifests/cluster.pp
  2. 53
    0
      deployment_scripts/puppet/manifests/db.pp
  3. 48
    0
      deployment_scripts/puppet/manifests/haproxy.pp
  4. 44
    0
      deployment_scripts/puppet/manifests/keystone.pp
  5. 147
    0
      deployment_scripts/puppet/manifests/rabbitmq.pp
  6. 92
    0
      deployment_scripts/puppet/manifests/trove.pp
  7. 8
    0
      deployment_scripts/puppet/modules/trove/.gitignore
  8. 4
    0
      deployment_scripts/puppet/modules/trove/.gitreview
  9. 18
    0
      deployment_scripts/puppet/modules/trove/CHANGELOG.md
  10. 35
    0
      deployment_scripts/puppet/modules/trove/Gemfile
  11. 176
    0
      deployment_scripts/puppet/modules/trove/LICENSE
  12. 70
    0
      deployment_scripts/puppet/modules/trove/README.md
  13. 73
    0
      deployment_scripts/puppet/modules/trove/Rakefile
  14. 38
    0
      deployment_scripts/puppet/modules/trove/examples/site.pp
  15. 113
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove.rb
  16. 27
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_api_paste_ini/ini_setting.rb
  17. 27
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_conductor_config/ini_setting.rb
  18. 27
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_config/ini_setting.rb
  19. 52
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_datastore/trove.rb
  20. 60
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_datastore_version/trove.rb
  21. 27
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_guestagent_config/ini_setting.rb
  22. 27
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_taskmanager_config/ini_setting.rb
  23. 42
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_api_paste_ini.rb
  24. 42
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_conductor_config.rb
  25. 42
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_config.rb
  26. 26
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_datastore.rb
  27. 38
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_datastore_version.rb
  28. 42
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_guestagent_config.rb
  29. 42
    0
      deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_taskmanager_config.rb
  30. 370
    0
      deployment_scripts/puppet/modules/trove/manifests/api.pp
  31. 40
    0
      deployment_scripts/puppet/modules/trove/manifests/client.pp
  32. 224
    0
      deployment_scripts/puppet/modules/trove/manifests/conductor.pp
  33. 84
    0
      deployment_scripts/puppet/modules/trove/manifests/config.pp
  34. 83
    0
      deployment_scripts/puppet/modules/trove/manifests/db/mysql.pp
  35. 47
    0
      deployment_scripts/puppet/modules/trove/manifests/db/postgresql.pp
  36. 28
    0
      deployment_scripts/puppet/modules/trove/manifests/db/sync.pp
  37. 91
    0
      deployment_scripts/puppet/modules/trove/manifests/generic_service.pp
  38. 213
    0
      deployment_scripts/puppet/modules/trove/manifests/guestagent.pp
  39. 259
    0
      deployment_scripts/puppet/modules/trove/manifests/init.pp
  40. 220
    0
      deployment_scripts/puppet/modules/trove/manifests/keystone/auth.pp
  41. 35
    0
      deployment_scripts/puppet/modules/trove/manifests/params.pp
  42. 106
    0
      deployment_scripts/puppet/modules/trove/manifests/rabbitmq.pp
  43. 281
    0
      deployment_scripts/puppet/modules/trove/manifests/taskmanager.pp
  44. 39
    0
      deployment_scripts/puppet/modules/trove/metadata.json
  45. 114
    0
      deployment_scripts/puppet/modules/trove/spec/acceptance/basic_trove_spec.rb
  46. 9
    0
      deployment_scripts/puppet/modules/trove/spec/acceptance/nodesets/default.yml
  47. 10
    0
      deployment_scripts/puppet/modules/trove/spec/acceptance/nodesets/nodepool-centos7.yml
  48. 10
    0
      deployment_scripts/puppet/modules/trove/spec/acceptance/nodesets/nodepool-trusty.yml
  49. 194
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_api_spec.rb
  50. 55
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_client_spec.rb
  51. 153
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_conductor_spec.rb
  52. 63
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_config_spec.rb
  53. 109
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_db_mysql_spec.rb
  54. 58
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_db_postgresql_spec.rb
  55. 158
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_guestagent_spec.rb
  56. 66
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_init_spec.rb
  57. 141
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_keystone_auth_spec.rb
  58. 211
    0
      deployment_scripts/puppet/modules/trove/spec/classes/trove_taskmanager_spec.rb
  59. 56
    0
      deployment_scripts/puppet/modules/trove/spec/shared_examples.rb
  60. 7
    0
      deployment_scripts/puppet/modules/trove/spec/spec_helper.rb
  61. 56
    0
      deployment_scripts/puppet/modules/trove/spec/spec_helper_acceptance.rb
  62. 37
    0
      deployment_scripts/puppet/modules/trove/spec/unit/provider/trove_config/ini_setting_spec.rb
  63. 57
    0
      deployment_scripts/puppet/modules/trove/spec/unit/provider/trove_datastore/trove_spec.rb
  64. 50
    0
      deployment_scripts/puppet/modules/trove/spec/unit/provider/trove_datastore_version/trove_spec.rb
  65. 14
    0
      deployment_scripts/puppet/modules/trove/spec/unit/provider/trove_spec.rb
  66. 52
    0
      deployment_scripts/puppet/modules/trove/spec/unit/type/trove_config_spec.rb
  67. 182
    0
      deployment_scripts/puppet/modules/trove/templates/rabbitmq-init-centos.erb
  68. 231
    0
      deployment_scripts/puppet/modules/trove/templates/rabbitmq-init-ubuntu.erb
  69. 7
    0
      deployment_scripts/puppet/modules/trove/templates/rabbitmq.config.erb
  70. 73
    0
      deployment_scripts/puppet/modules/trove/templates/trove-guestagent.conf.erb
  71. 76
    30
      deployment_tasks.yaml
  72. 11
    7
      environment_config.yaml
  73. 14
    4
      metadata.yaml
  74. 4
    8
      network_roles.yaml
  75. 9
    4
      node_roles.yaml
  76. 1
    3
      pre_build_hook
  77. 1
    0
      volumes.yaml

+ 50
- 0
deployment_scripts/puppet/manifests/cluster.pp View File

@@ -0,0 +1,50 @@
1
+notice('MODULAR: trove/cluster.pp')
2
+
3
+if !(hiera('role') in ['trove']) {
4
+    fail('The node role is not in trove roles')
5
+}
6
+
7
+$network_scheme = hiera_hash('network_scheme', {})
8
+$network_metadata = hiera_hash('network_metadata', {})
9
+
10
+prepare_network_config($network_scheme)
11
+
12
+$trove_node       = get_nodes_hash_by_roles($network_metadata, ['trove'])
13
+
14
+$corosync_nodes   = corosync_nodes($trove_node, 'trove/api')
15
+
16
+$network_ip       = get_network_role_property('trove/api', 'ipaddr')
17
+
18
+class { 'cluster':
19
+  internal_address => $network_ip,
20
+  corosync_nodes   => $corosync_nodes,
21
+}
22
+
23
+pcmk_nodes { 'pacemaker' :
24
+  nodes => $corosync_nodes,
25
+  add_pacemaker_nodes => false,
26
+}
27
+
28
+Service <| title == 'corosync' |> {
29
+  subscribe => File['/etc/corosync/service.d'],
30
+  require   => File['/etc/corosync/corosync.conf'],
31
+}
32
+
33
+Service['corosync'] -> Pcmk_nodes<||>
34
+Pcmk_nodes<||> -> Service<| provider == 'pacemaker' |>
35
+
36
+# Sometimes during first start pacemaker can not connect to corosync
37
+# via IPC due to pacemaker and corosync processes are run under different users
38
+if($::operatingsystem == 'Ubuntu') {
39
+  $pacemaker_run_uid = 'hacluster'
40
+  $pacemaker_run_gid = 'haclient'
41
+
42
+  file {'/etc/corosync/uidgid.d/pacemaker':
43
+    content =>"uidgid {
44
+   uid: ${pacemaker_run_uid}
45
+   gid: ${pacemaker_run_gid}
46
+}"
47
+  }
48
+
49
+  File['/etc/corosync/corosync.conf'] -> File['/etc/corosync/uidgid.d/pacemaker'] -> Service <| title == 'corosync' |>
50
+}

+ 53
- 0
deployment_scripts/puppet/manifests/db.pp View File

@@ -0,0 +1,53 @@
1
+notice('MODULAR: trove/db.pp')
2
+
3
+$node_name = hiera('node_name')
4
+$trove_hash    = hiera_hash('fuel-plugin-dbaas-trove', {})
5
+$trove_enabled = pick($trove_hash['metadata']['enabled'], false)
6
+$mysql_hash     = hiera_hash('mysql_hash', {})
7
+$management_vip = hiera('management_vip', undef)
8
+$database_vip   = hiera('database_vip')
9
+
10
+$mysql_root_user     = pick($mysql_hash['root_user'], 'root')
11
+$mysql_db_create     = pick($mysql_hash['db_create'], true)
12
+$mysql_root_password = $mysql_hash['root_password']
13
+
14
+$db_user     = pick($trove_hash['metadata']['db_user'], 'trove')
15
+$db_name     = pick($trove_hash['metadata']['db_name'], 'trove')
16
+$db_password = pick($trove_hash['metadata']['db_password'], $mysql_root_password)
17
+
18
+$db_host          = pick($trove_hash['metadata']['db_host'], $database_vip, 'localhost')
19
+$db_create        = pick($trove_hash['metadata']['db_create'], $mysql_db_create)
20
+$db_root_user     = pick($trove_hash['metadata']['root_user'], $mysql_root_user)
21
+$db_root_password = pick($trove_hash['metadata']['root_password'], $mysql_root_password)
22
+
23
+$allowed_hosts = [ $node_name, 'localhost', '127.0.0.1', '%' ]
24
+
25
+if $trove_enabled and $db_create {
26
+
27
+  class { 'galera::client':
28
+    custom_setup_class => hiera('mysql_custom_setup_class', 'galera'),
29
+  }
30
+
31
+  class { 'trove::db::mysql':
32
+    user          => $db_user,
33
+    password      => $db_password,
34
+    dbname        => $db_name,
35
+    allowed_hosts => $allowed_hosts,
36
+  }
37
+
38
+  class { 'osnailyfacter::mysql_access':
39
+    db_host     => $db_host,
40
+    db_user     => $db_root_user,
41
+    db_password => $db_root_password,
42
+  }
43
+
44
+  Class['galera::client'] ->
45
+    Class['osnailyfacter::mysql_access'] ->
46
+      Class['trove::db::mysql']
47
+
48
+}
49
+
50
+class mysql::config {}
51
+include mysql::config
52
+class mysql::server {}
53
+include mysql::server

+ 48
- 0
deployment_scripts/puppet/manifests/haproxy.pp View File

@@ -0,0 +1,48 @@
1
+notice('MODULAR: trove/haproxy.pp')
2
+
3
+$network_metadata = hiera_hash('network_metadata')
4
+$trove_hash    = hiera_hash('fuel-plugin-dbaas-trove', {})
5
+# enabled by default
6
+$use_trove = pick($trove_hash['metadata']['enabled'], true)
7
+$public_ssl_hash = hiera('public_ssl')
8
+
9
+$troves_address_map = get_node_to_ipaddr_map_by_network_role(get_nodes_hash_by_roles($network_metadata, ['trove']), 'trove/api')
10
+
11
+if ($use_trove) {
12
+  $server_names        = hiera_array('trove_names', keys($troves_address_map))
13
+  $ipaddresses         = hiera_array('trove_ipaddresses', values($troves_address_map))
14
+  $public_virtual_ip   = hiera('public_vip')
15
+  $internal_virtual_ip = hiera('management_vip')
16
+	
17
+	# configure trove ha proxy
18
+    Openstack::Ha::Haproxy_service {
19
+		internal_virtual_ip => $internal_virtual_ip,
20
+		ipaddresses         => $ipaddresses,
21
+		public_virtual_ip   => $public_virtual_ip,
22
+		server_names        => $server_names,
23
+		public_ssl          => $public_ssl_hash['services'],
24
+	}
25
+
26
+	openstack::ha::haproxy_service { 'trove-api':
27
+	    order               => '210',
28
+	    listen_port         => 8779,
29
+		internal            => true,
30
+        public              => true,
31
+	}
32
+
33
+	openstack::ha::haproxy_service { 'trove-rabbitmq':
34
+		order                  => '211',
35
+		listen_port            => 55671,
36
+		define_backups         => true,
37
+		internal               => true,
38
+        public                 => true,
39
+		haproxy_config_options => {
40
+		  'option'         => ['tcpka'],
41
+		  'timeout client' => '48h',
42
+		  'timeout server' => '48h',
43
+		  'balance'        => 'roundrobin',
44
+		  'mode'           => 'tcp'
45
+		},
46
+		balancermember_options => 'check inter 5000 rise 2 fall 3',  
47
+	}
48
+}

+ 44
- 0
deployment_scripts/puppet/manifests/keystone.pp View File

@@ -0,0 +1,44 @@
1
+notice('MODULAR: trove/keystone.pp')
2
+
3
+$trove_hash         = hiera_hash('fuel-plugin-dbaas-trove', {})
4
+$public_ssl_hash     = hiera('public_ssl')
5
+$public_vip          = hiera('public_vip')
6
+$public_address      = $public_ssl_hash['services'] ? {
7
+  true    => $public_ssl_hash['hostname'],
8
+  default => $public_vip,
9
+}
10
+$public_protocol     = $public_ssl_hash['services'] ? {
11
+  true    => 'https',
12
+  default => 'http',
13
+}
14
+$admin_protocol      = 'http'
15
+$admin_address       = hiera('management_vip')
16
+$region              = pick($trove_hash['metadata']['region'], hiera('region', 'RegionOne'))
17
+
18
+$password            = pick($trove_hash['metadata']['user_password'], 'password')
19
+$auth_name           = pick($trove_hash['metadata']['auth_name'], 'trove')
20
+$configure_endpoint  = pick($trove_hash['metadata']['configure_endpoint'], true)
21
+$configure_user      = pick($trove_hash['metadata']['configure_user'], true)
22
+$configure_user_role = pick($trove_hash['metadata']['configure_user_role'], true)
23
+$service_name        = pick($trove_hash['metadata']['service_name'], 'trove')
24
+$tenant              = pick($trove_hash['metadata']['tenant'], 'services')
25
+
26
+$port = '8779'
27
+
28
+$public_url      = "${public_protocol}://${public_address}:${port}/v1.0/%(tenant_id)s"
29
+$admin_url       = "${admin_protocol}://${admin_address}:${port}/v1.0/%(tenant_id)s"
30
+
31
+validate_string($public_address)
32
+validate_string($password)
33
+
34
+class { 'trove::keystone::auth':
35
+  password            => $password,
36
+  auth_name           => $auth_name,
37
+  configure_endpoint  => $configure_endpoint,
38
+  service_name        => $service_name,
39
+  public_url          => $public_url,
40
+  internal_url        => $admin_url,
41
+  admin_url           => $admin_url,
42
+  region              => $region,
43
+  tenant              => $tenant,
44
+}

+ 147
- 0
deployment_scripts/puppet/manifests/rabbitmq.pp View File

@@ -0,0 +1,147 @@
1
+notice('MODULAR: trove/rabbitmq.pp')
2
+
3
+$network_scheme = hiera_hash('network_scheme', {})
4
+prepare_network_config($network_scheme)
5
+
6
+$queue_provider = hiera('queue_provider', 'rabbitmq')
7
+
8
+if $queue_provider == 'rabbitmq' {
9
+  $trove_hash      = hiera_hash('fuel-plugin-dbaas-trove', {})
10
+  $erlang_cookie   = hiera('erlang_cookie', 'EOKOWXQREETZSHFNTPEY')
11
+  $version         = hiera('rabbit_version', '3.3.5')
12
+  $debug           = hiera('debug', false)
13
+  $deployment_mode = hiera('deployment_mode', 'ha_compact')
14
+  $amqp_port       = pick($trove_hash['rabbit_port'], '55671')
15
+  $rabbit_hash     = hiera_hash('rabbit_hash', {})
16
+  $enabled         = pick($rabbit_hash['enabled'], true)
17
+  $use_pacemaker   = pick($rabbit_hash['pacemaker'], true)
18
+
19
+  case $::osfamily {
20
+    'RedHat': {
21
+      $command_timeout  = "'-s KILL'"
22
+      $package_provider = 'yum'
23
+    }
24
+    'Debian': {
25
+      $command_timeout  = "'--signal=KILL'"
26
+      $package_provider = 'apt'
27
+    }
28
+    default: {
29
+      fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem},\
30
+  module ${module_name} only support osfamily RedHat and Debian")
31
+    }
32
+  }
33
+
34
+  if ($debug) {
35
+    # FIXME(aschultz): debug wasn't introduced until v3.5.0, when we upgrade
36
+    # we should change info to debug. Also don't forget to fix tests!
37
+    $rabbit_levels = '[{connection,info}]'
38
+  } else {
39
+    $rabbit_levels = '[{connection,info}]'
40
+  }
41
+
42
+  $cluster_partition_handling   = hiera('rabbit_cluster_partition_handling', 'autoheal')
43
+  $mnesia_table_loading_timeout = hiera('mnesia_table_loading_timeout', '10000')
44
+  $rabbitmq_bind_ip_address     = pick(get_network_role_property('trove/api', 'ipaddr'), 'UNSET')
45
+
46
+  # NOTE(bogdando) not a hash. Keep an indentation as is
47
+  $rabbit_tcp_listen_options    = hiera('rabbit_tcp_listen_options',
48
+    '[
49
+      binary,
50
+      {packet, raw},
51
+      {reuseaddr, true},
52
+      {backlog, 128},
53
+      {nodelay, true},
54
+      {exit_on_close, false},
55
+      {keepalive, true}
56
+    ]'
57
+  )
58
+  $config_kernel_variables = hiera('rabbit_config_kernel_variables',
59
+    {
60
+      'inet_dist_listen_min'         => '41055',
61
+      'inet_dist_listen_max'         => '41055',
62
+      'inet_default_connect_options' => '[{nodelay,true}]',
63
+      'net_ticktime'                 => '10',
64
+    }
65
+  )
66
+  $config_variables = hiera('rabbit_config_variables',
67
+    {
68
+      'log_levels'                 => $rabbit_levels,
69
+      'default_vhost'              => "<<\"/\">>",
70
+      'default_permissions'        => '[<<".*">>, <<".*">>, <<".*">>]',
71
+      'tcp_listen_options'         => $rabbit_tcp_listen_options,
72
+      'cluster_partition_handling' => $cluster_partition_handling,
73
+      'mnesia_table_loading_timeout' => $mnesia_table_loading_timeout,
74
+    }
75
+  )
76
+
77
+  $thread_pool_calc = min(100,max(12*$physicalprocessorcount,30))
78
+
79
+  if $deployment_mode == 'ha_compact' {
80
+    $rabbit_pid_file                   = '/var/run/rabbitmq/p_pid'
81
+    } else {
82
+    $rabbit_pid_file                   = '/var/run/rabbitmq/pid'
83
+  }
84
+  $environment_variables = hiera('rabbit_environment_variables',
85
+    {
86
+      'SERVER_ERL_ARGS'     => "\"+K true +A${thread_pool_calc} +P 1048576\"",
87
+      'PID_FILE'            => $rabbit_pid_file,
88
+    }
89
+  )
90
+
91
+  if ($enabled) {
92
+    class { '::rabbitmq':
93
+      admin_enable               => true,
94
+      repos_ensure               => false,
95
+      package_provider           => $package_provider,
96
+      package_source             => undef,
97
+      service_ensure             => 'running',
98
+      service_manage             => true,
99
+      port                       => $amqp_port,
100
+      delete_guest_user          => true,
101
+      default_user               => 'trove',
102
+      default_pass               => $trove_hash['metadata']['rabbit_password'],
103
+      # NOTE(bogdando) set to true and uncomment the lines below, if puppet should create a cluster
104
+      # We don't want it as far as OCF script creates the cluster
105
+      config_cluster             => false,
106
+      #erlang_cookie              => $erlang_cookie,
107
+      #wipe_db_on_cookie_change   => true,
108
+      #cluster_nodes              => $rabbitmq_cluster_nodes,
109
+      #cluster_node_type          => 'disc',
110
+      #cluster_partition_handling => $cluster_partition_handling,
111
+      version                    => $version,
112
+      node_ip_address            => $rabbitmq_bind_ip_address,
113
+      config_kernel_variables    => $config_kernel_variables,
114
+      config_variables           => $config_variables,
115
+      environment_variables      => $environment_variables,
116
+    }
117
+
118
+    if ($use_pacemaker) {
119
+      # Install rabbit-fence daemon
120
+      class { 'cluster::rabbitmq_fence':
121
+        enabled => $enabled,
122
+        require => Class['::rabbitmq']
123
+      }
124
+    }
125
+
126
+    class { 'trove::rabbitmq':
127
+      enabled        => $enabled,
128
+      # Do not install rabbitmq from trove classes
129
+      rabbitmq_class => false,
130
+      userid         => $trove_hash['metadata']['rabbit_user'],
131
+      password       => $trove_hash['metadata']['rabbit_password'],
132
+      require        => Class['::rabbitmq'],
133
+    }
134
+
135
+    if ($use_pacemaker) {
136
+      class { 'pacemaker_wrappers::rabbitmq':
137
+        command_timeout => $command_timeout,
138
+        debug           => $debug,
139
+        erlang_cookie   => $erlang_cookie,
140
+        admin_user      => $trove_hash['metadata']['rabbit_user'],
141
+        admin_pass      => $trove_hash['metadata']['rabbit_password'],
142
+        before          => Class['trove::rabbitmq'],
143
+      }
144
+    }
145
+  }
146
+
147
+}

+ 92
- 0
deployment_scripts/puppet/manifests/trove.pp View File

@@ -0,0 +1,92 @@
1
+notice('MODULAR: trove/trove.pp')
2
+
3
+prepare_network_config(hiera('network_scheme', {}))
4
+
5
+$trove_hash                 = hiera_hash('fuel-plugin-dbaas-trove', {})
6
+$nova_hash                  = hiera_hash('nova_hash', {})
7
+$neutron_config             = hiera_hash('neutron_config', {})
8
+$node_role                  = hiera('node_role')
9
+$public_ip                  = hiera('public_vip')
10
+$database_ip                = hiera('database_vip')
11
+$management_ip              = hiera('management_vip')
12
+$region                     = hiera('region', 'RegionOne')
13
+$service_endpoint           = hiera('service_endpoint')
14
+$debug                      = hiera('debug', false)
15
+$verbose                    = hiera('verbose', true)
16
+$use_syslog                 = hiera('use_syslog', true)
17
+$use_stderr                 = hiera('use_stderr', false)
18
+$rabbit_ha_queues           = hiera('rabbit_ha_queues')
19
+$amqp_port                  = hiera('amqp_port')
20
+$amqp_hosts                 = hiera('amqp_hosts')
21
+$public_ssl                 = hiera_hash('public_ssl', {})
22
+
23
+#################################################################
24
+
25
+if $trove_hash['metadata']['enabled'] {
26
+  $public_protocol = pick($public_ssl['services'], false) ? {
27
+    true    => 'https',
28
+    default => 'http',
29
+  }
30
+
31
+  $public_address = pick($public_ssl['services'], false) ? {
32
+    true    => pick($public_ssl['hostname']),
33
+    default => $public_ip,
34
+  }
35
+
36
+  $firewall_rule  = '210 trove-api'
37
+
38
+  $api_bind_port  = '8779'
39
+  $api_bind_host  = get_network_role_property('trove/api', 'ipaddr')
40
+
41
+  $trove_user    = pick($trove_hash['metadata']['user'], 'trove')
42
+  $tenant         = pick($trove_hash['metadata']['tenant'], 'services')
43
+  $internal_url   = "http://${api_bind_host}:${api_bind_port}"
44
+  $db_user        = pick($trove_hash['metadata']['db_user'], 'trove')
45
+  $db_name        = pick($trove_hash['metadata']['db_name'], 'trove')
46
+  $db_password    = pick($trove_hash['metadata']['db_password'], 's3cr3t')
47
+  $db_host        = pick($trove_hash['metadata']['db_host'], $database_ip)
48
+  $read_timeout   = '60'
49
+  $sql_connection = "mysql://${db_user}:${db_password}@${db_host}/${db_name}?read_timeout=${read_timeout}"
50
+
51
+ 
52
+  class { '::trove::client': }
53
+
54
+  class { '::trove':
55
+    database_connection   => $sql_connection,
56
+    rabbit_host           => $management_ip,
57
+    rabbit_password       => $trove_hash['metadata']['rabbit_password'],
58
+    rabbit_port           => '55671',
59
+    rabbit_userid         => $trove_hash['metadata']['rabbit_user'],
60
+    rabbit_use_ssl        => false,
61
+    nova_proxy_admin_pass => $nova_hash['user_password'],
62
+	nova_proxy_admin_user => 'nova',
63
+    nova_proxy_admin_tenant_name => pick($nova_hash['tenant_name'], 'services'),
64
+  }
65
+
66
+  class { '::trove::api':
67
+    debug             => true,
68
+    verbose           => true,
69
+    bind_host         => $api_bind_host,
70
+    auth_url          => "http://${service_endpoint}:5000/v2.0/",
71
+    keystone_password => $trove_hash['metadata']['user_password'],
72
+  }
73
+
74
+  class { '::trove::conductor':
75
+    debug             => true,
76
+    verbose           => true,
77
+    auth_url          => "http://${service_endpoint}:5000/v2.0/",
78
+  }
79
+
80
+  class { '::trove::taskmanager':
81
+    debug             => true,
82
+    verbose           => true,
83
+    auth_url          => "http://${service_endpoint}:5000/v2.0/",
84
+  }
85
+  
86
+  firewall { $firewall_rule :
87
+    dport  => $api_bind_port,
88
+    proto  => 'tcp',
89
+    action => 'accept',
90
+  }
91
+
92
+}

+ 8
- 0
deployment_scripts/puppet/modules/trove/.gitignore View File

@@ -0,0 +1,8 @@
1
+*.swp
2
+spec/fixtures/modules/*
3
+spec/fixtures/manifests/site.pp
4
+Gemfile.lock
5
+.vendor
6
+.bundle/
7
+vendor/
8
+openstack/

+ 4
- 0
deployment_scripts/puppet/modules/trove/.gitreview View File

@@ -0,0 +1,4 @@
1
+[gerrit]
2
+host=review.openstack.org
3
+port=29418
4
+project=openstack/puppet-trove.git

+ 18
- 0
deployment_scripts/puppet/modules/trove/CHANGELOG.md View File

@@ -0,0 +1,18 @@
1
+##2015-10-10 - 6.1.0
2
+###Summary
3
+
4
+This is a feature and bugfix release in the Kilo series.
5
+
6
+####Features
7
+- Introduce trove:config to manage custom options
8
+
9
+####Maintenance
10
+- acceptance: checkout stable/kilo puppet modules
11
+
12
+####Bugfixes
13
+- Fix catalog compilation when not configuring endpoint
14
+
15
+##2015-07-08 - 6.0.0
16
+###Summary
17
+
18
+- Initial release of the puppet-trove module

+ 35
- 0
deployment_scripts/puppet/modules/trove/Gemfile View File

@@ -0,0 +1,35 @@
1
+source 'https://rubygems.org'
2
+
3
+group :development, :test do
4
+  gem 'puppetlabs_spec_helper', :require => false
5
+  gem 'rspec-puppet', '~> 2.1.0', :require => false
6
+
7
+  gem 'metadata-json-lint'
8
+  gem 'puppet-lint-param-docs'
9
+  gem 'puppet-lint-absolute_classname-check'
10
+  gem 'puppet-lint-absolute_template_path'
11
+  gem 'puppet-lint-trailing_newline-check'
12
+
13
+  # Puppet 4.x related lint checks
14
+  gem 'puppet-lint-unquoted_string-check'
15
+  gem 'puppet-lint-leading_zero-check'
16
+  gem 'puppet-lint-variable_contains_upcase'
17
+  gem 'puppet-lint-numericvariable'
18
+
19
+  gem 'beaker-rspec', :require => false
20
+  gem 'beaker-puppet_install_helper', :require => false
21
+  gem 'json'
22
+  gem 'webmock'
23
+end
24
+
25
+group :system_tests do
26
+  gem 'r10k', :require => 'false'
27
+end
28
+
29
+if puppetversion = ENV['PUPPET_GEM_VERSION']
30
+  gem 'puppet', puppetversion, :require => false
31
+else
32
+  gem 'puppet', :require => false
33
+end
34
+
35
+# vim:ft=ruby

+ 176
- 0
deployment_scripts/puppet/modules/trove/LICENSE View File

@@ -0,0 +1,176 @@
1
+
2
+                                 Apache License
3
+                           Version 2.0, January 2004
4
+                        http://www.apache.org/licenses/
5
+
6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+   1. Definitions.
9
+
10
+      "License" shall mean the terms and conditions for use, reproduction,
11
+      and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+      "Licensor" shall mean the copyright owner or entity authorized by
14
+      the copyright owner that is granting the License.
15
+
16
+      "Legal Entity" shall mean the union of the acting entity and all
17
+      other entities that control, are controlled by, or are under common
18
+      control with that entity. For the purposes of this definition,
19
+      "control" means (i) the power, direct or indirect, to cause the
20
+      direction or management of such entity, whether by contract or
21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+      outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+      "You" (or "Your") shall mean an individual or Legal Entity
25
+      exercising permissions granted by this License.
26
+
27
+      "Source" form shall mean the preferred form for making modifications,
28
+      including but not limited to software source code, documentation
29
+      source, and configuration files.
30
+
31
+      "Object" form shall mean any form resulting from mechanical
32
+      transformation or translation of a Source form, including but
33
+      not limited to compiled object code, generated documentation,
34
+      and conversions to other media types.
35
+
36
+      "Work" shall mean the work of authorship, whether in Source or
37
+      Object form, made available under the License, as indicated by a
38
+      copyright notice that is included in or attached to the work
39
+      (an example is provided in the Appendix below).
40
+
41
+      "Derivative Works" shall mean any work, whether in Source or Object
42
+      form, that is based on (or derived from) the Work and for which the
43
+      editorial revisions, annotations, elaborations, or other modifications
44
+      represent, as a whole, an original work of authorship. For the purposes
45
+      of this License, Derivative Works shall not include works that remain
46
+      separable from, or merely link (or bind by name) to the interfaces of,
47
+      the Work and Derivative Works thereof.
48
+
49
+      "Contribution" shall mean any work of authorship, including
50
+      the original version of the Work and any modifications or additions
51
+      to that Work or Derivative Works thereof, that is intentionally
52
+      submitted to Licensor for inclusion in the Work by the copyright owner
53
+      or by an individual or Legal Entity authorized to submit on behalf of
54
+      the copyright owner. For the purposes of this definition, "submitted"
55
+      means any form of electronic, verbal, or written communication sent
56
+      to the Licensor or its representatives, including but not limited to
57
+      communication on electronic mailing lists, source code control systems,
58
+      and issue tracking systems that are managed by, or on behalf of, the
59
+      Licensor for the purpose of discussing and improving the Work, but
60
+      excluding communication that is conspicuously marked or otherwise
61
+      designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
64
+      on behalf of whom a Contribution has been received by Licensor and
65
+      subsequently incorporated within the Work.
66
+
67
+   2. Grant of Copyright License. Subject to the terms and conditions of
68
+      this License, each Contributor hereby grants to You a perpetual,
69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+      copyright license to reproduce, prepare Derivative Works of,
71
+      publicly display, publicly perform, sublicense, and distribute the
72
+      Work and such Derivative Works in Source or Object form.
73
+
74
+   3. Grant of Patent License. Subject to the terms and conditions of
75
+      this License, each Contributor hereby grants to You a perpetual,
76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+      (except as stated in this section) patent license to make, have made,
78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
79
+      where such license applies only to those patent claims licensable
80
+      by such Contributor that are necessarily infringed by their
81
+      Contribution(s) alone or by combination of their Contribution(s)
82
+      with the Work to which such Contribution(s) was submitted. If You
83
+      institute patent litigation against any entity (including a
84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+      or a Contribution incorporated within the Work constitutes direct
86
+      or contributory patent infringement, then any patent licenses
87
+      granted to You under this License for that Work shall terminate
88
+      as of the date such litigation is filed.
89
+
90
+   4. Redistribution. You may reproduce and distribute copies of the
91
+      Work or Derivative Works thereof in any medium, with or without
92
+      modifications, and in Source or Object form, provided that You
93
+      meet the following conditions:
94
+
95
+      (a) You must give any other recipients of the Work or
96
+          Derivative Works a copy of this License; and
97
+
98
+      (b) You must cause any modified files to carry prominent notices
99
+          stating that You changed the files; and
100
+
101
+      (c) You must retain, in the Source form of any Derivative Works
102
+          that You distribute, all copyright, patent, trademark, and
103
+          attribution notices from the Source form of the Work,
104
+          excluding those notices that do not pertain to any part of
105
+          the Derivative Works; and
106
+
107
+      (d) If the Work includes a "NOTICE" text file as part of its
108
+          distribution, then any Derivative Works that You distribute must
109
+          include a readable copy of the attribution notices contained
110
+          within such NOTICE file, excluding those notices that do not
111
+          pertain to any part of the Derivative Works, in at least one
112
+          of the following places: within a NOTICE text file distributed
113
+          as part of the Derivative Works; within the Source form or
114
+          documentation, if provided along with the Derivative Works; or,
115
+          within a display generated by the Derivative Works, if and
116
+          wherever such third-party notices normally appear. The contents
117
+          of the NOTICE file are for informational purposes only and
118
+          do not modify the License. You may add Your own attribution
119
+          notices within Derivative Works that You distribute, alongside
120
+          or as an addendum to the NOTICE text from the Work, provided
121
+          that such additional attribution notices cannot be construed
122
+          as modifying the License.
123
+
124
+      You may add Your own copyright statement to Your modifications and
125
+      may provide additional or different license terms and conditions
126
+      for use, reproduction, or distribution of Your modifications, or
127
+      for any such Derivative Works as a whole, provided Your use,
128
+      reproduction, and distribution of the Work otherwise complies with
129
+      the conditions stated in this License.
130
+
131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
132
+      any Contribution intentionally submitted for inclusion in the Work
133
+      by You to the Licensor shall be under the terms and conditions of
134
+      this License, without any additional terms or conditions.
135
+      Notwithstanding the above, nothing herein shall supersede or modify
136
+      the terms of any separate license agreement you may have executed
137
+      with Licensor regarding such Contributions.
138
+
139
+   6. Trademarks. This License does not grant permission to use the trade
140
+      names, trademarks, service marks, or product names of the Licensor,
141
+      except as required for reasonable and customary use in describing the
142
+      origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+   7. Disclaimer of Warranty. Unless required by applicable law or
145
+      agreed to in writing, Licensor provides the Work (and each
146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+      implied, including, without limitation, any warranties or conditions
149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
151
+      appropriateness of using or redistributing the Work and assume any
152
+      risks associated with Your exercise of permissions under this License.
153
+
154
+   8. Limitation of Liability. In no event and under no legal theory,
155
+      whether in tort (including negligence), contract, or otherwise,
156
+      unless required by applicable law (such as deliberate and grossly
157
+      negligent acts) or agreed to in writing, shall any Contributor be
158
+      liable to You for damages, including any direct, indirect, special,
159
+      incidental, or consequential damages of any character arising as a
160
+      result of this License or out of the use or inability to use the
161
+      Work (including but not limited to damages for loss of goodwill,
162
+      work stoppage, computer failure or malfunction, or any and all
163
+      other commercial damages or losses), even if such Contributor
164
+      has been advised of the possibility of such damages.
165
+
166
+   9. Accepting Warranty or Additional Liability. While redistributing
167
+      the Work or Derivative Works thereof, You may choose to offer,
168
+      and charge a fee for, acceptance of support, warranty, indemnity,
169
+      or other liability obligations and/or rights consistent with this
170
+      License. However, in accepting such obligations, You may act only
171
+      on Your own behalf and on Your sole responsibility, not on behalf
172
+      of any other Contributor, and only if You agree to indemnify,
173
+      defend, and hold each Contributor harmless for any liability
174
+      incurred by, or claims asserted against, such Contributor by reason
175
+      of your accepting any such warranty or additional liability.
176
+

+ 70
- 0
deployment_scripts/puppet/modules/trove/README.md View File

@@ -0,0 +1,70 @@
1
+puppet-trove
2
+=============
3
+
4
+6.1.0 - 2015.1 - Kilo
5
+
6
+#### Table of Contents
7
+
8
+1. [Overview - What is the trove module?](#overview)
9
+2. [Module Description - What does the module do?](#module-description)
10
+3. [Setup - The basics of getting started with trove](#setup)
11
+4. [Implementation - An under-the-hood peek at what the module is doing](#implementation)
12
+5. [Limitations - OS compatibility, etc.](#limitations)
13
+6. [Development - Guide for contributing to the module](#development)
14
+7. [Contributors - Those with commits](#contributors)
15
+
16
+Overview
17
+--------
18
+
19
+The trove module is a part of [OpenStack](https://github.com/openstack), an effort by the Openstack infrastructure team to provide continuous integration testing and code review for Openstack and Openstack community projects as part of the core software. The module itself is used to flexibly configure and manage the database service for Openstack.
20
+
21
+Module Description
22
+------------------
23
+
24
+Setup
25
+-----
26
+
27
+**What the trove module affects:**
28
+
29
+* trove, the database service for Openstack.
30
+
31
+Implementation
32
+--------------
33
+
34
+### trove
35
+
36
+trove is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers.
37
+
38
+Limitations
39
+-----------
40
+
41
+Security
42
+--------
43
+
44
+For security reasons, a separate in-cloud RabbitMQ cluster should be set up for Trove to use. The reason for this is that the guest agent needs to communicate with RabbitMQ, so it is not advisable to give instances access to the same RabbitMQ server that the core OpenStack services are using for communication.
45
+
46
+Please note that puppet-trove cannot check if this rule is being followed, so it is the deployer's responsibility to do it.
47
+
48
+Beaker-Rspec
49
+------------
50
+
51
+This module has beaker-rspec tests
52
+
53
+To run:
54
+
55
+``shell
56
+bundle install
57
+bundle exec rspec spec/acceptance
58
+``
59
+
60
+Development
61
+-----------
62
+
63
+Developer documentation for the entire puppet-openstack project.
64
+
65
+* https://wiki.openstack.org/wiki/Puppet-openstack#Developer_documentation
66
+
67
+Contributors
68
+------------
69
+
70
+* https://github.com/enovance/puppet-trove/graphs/contributors

+ 73
- 0
deployment_scripts/puppet/modules/trove/Rakefile View File

@@ -0,0 +1,73 @@
1
+require 'puppetlabs_spec_helper/rake_tasks'
2
+require 'puppet-lint/tasks/puppet-lint'
3
+require 'json'
4
+
5
+modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
6
+
7
+PuppetLint.configuration.fail_on_warnings = true
8
+PuppetLint.configuration.send('disable_80chars')
9
+PuppetLint.configuration.send('disable_class_parameter_defaults')
10
+
11
+task(:default).clear
12
+task :default => [:spec, :lint]
13
+
14
+Rake::Task[:spec_prep].clear
15
+desc 'Create the fixtures directory'
16
+task :spec_prep do
17
+  # Allow to test the module with custom dependencies
18
+  # like you could do with .fixtures file
19
+  if ENV['PUPPETFILE']
20
+    puppetfile = ENV['PUPPETFILE']
21
+    if ENV['GEM_HOME']
22
+      gem_home    = ENV['GEM_HOME']
23
+      gem_bin_dir = "#{gem_home}" + '/bin/'
24
+    else
25
+      gem_bin_dir = ''
26
+    end
27
+    r10k = ['env']
28
+    r10k += ["PUPPETFILE=#{puppetfile}"]
29
+    r10k += ["PUPPETFILE_DIR=#{Dir.pwd}/spec/fixtures/modules"]
30
+    r10k += ["#{gem_bin_dir}r10k"]
31
+    r10k += ['puppetfile', 'install', '-v']
32
+    sh(*r10k)
33
+  else
34
+  # otherwise, use official OpenStack Puppetfile
35
+    zuul_ref = ENV['ZUUL_REF']
36
+    zuul_branch = ENV['ZUUL_BRANCH']
37
+    zuul_url = ENV['ZUUL_URL']
38
+    repo = 'openstack/puppet-openstack-integration'
39
+    rm_rf(repo)
40
+    if File.exists?('/usr/zuul-env/bin/zuul-cloner')
41
+      zuul_clone_cmd = ['/usr/zuul-env/bin/zuul-cloner']
42
+      zuul_clone_cmd += ['--cache-dir', '/opt/git']
43
+      zuul_clone_cmd += ['--zuul-ref', "#{zuul_ref}"]
44
+      zuul_clone_cmd += ['--zuul-branch', "#{zuul_branch}"]
45
+      zuul_clone_cmd += ['--zuul-url', "#{zuul_url}"]
46
+      zuul_clone_cmd += ['git://git.openstack.org', "#{repo}"]
47
+      sh(*zuul_clone_cmd)
48
+    else
49
+      sh("git clone https://git.openstack.org/#{repo} -b stable/kilo #{repo}")
50
+    end
51
+    script = ['env']
52
+    script += ["PUPPETFILE_DIR=#{Dir.pwd}/spec/fixtures/modules"]
53
+    script += ["ZUUL_REF=#{zuul_ref}"]
54
+    script += ["ZUUL_BRANCH=#{zuul_branch}"]
55
+    script += ["ZUUL_URL=#{zuul_url}"]
56
+    script += ['bash', "#{repo}/install_modules_unit.sh"]
57
+    sh(*script)
58
+  end
59
+  rm_rf("spec/fixtures/modules/#{modname}")
60
+  ln_s(Dir.pwd, "spec/fixtures/modules/#{modname}")
61
+  mkdir_p('spec/fixtures/manifests')
62
+  touch('spec/fixtures/manifests/site.pp')
63
+end
64
+
65
+Rake::Task[:spec_clean].clear
66
+desc 'Clean up the fixtures directory'
67
+task :spec_clean do
68
+  rm_rf('spec/fixtures/modules')
69
+  rm_rf('openstack')
70
+  if File.zero?('spec/fixtures/manifests/site.pp')
71
+    rm_f('spec/fixtures/manifests/site.pp')
72
+  end
73
+end

+ 38
- 0
deployment_scripts/puppet/modules/trove/examples/site.pp View File

@@ -0,0 +1,38 @@
1
+# This is an example of site.pp to deploy Trove
2
+
3
+class { '::trove::client': }
4
+
5
+class { '::trove::keystone::auth':
6
+  admin_address    => '10.0.0.1',
7
+  internal_address => '10.0.0.1',
8
+  public_address   => '10.0.0.1',
9
+  password         => 'verysecrete',
10
+  region           => 'OpenStack'
11
+}
12
+
13
+class { '::trove::db::mysql':
14
+  password      => 'dbpass',
15
+  host          => '10.0.0.1',
16
+  allowed_hosts => '10.0.0.1'
17
+}
18
+
19
+class { '::trove':
20
+  database_connection   => 'mysql://trove:secrete@10.0.0.1/trove?charset=utf8',
21
+  rabbit_hosts          => '10.0.0.1',
22
+  rabbit_password       => 'secrete',
23
+  nova_proxy_admin_pass => 'novapass',
24
+}
25
+
26
+class { '::trove::api':
27
+  bind_host         => '10.0.0.1',
28
+  auth_url          => 'https://identity.openstack.org:5000/v2.0',
29
+  keystone_password => 'verysecrete'
30
+}
31
+
32
+class { '::trove::conductor':
33
+  auth_url          => 'https://identity.openstack.org:5000/v2.0'
34
+}
35
+
36
+class { '::trove::taskmanager':
37
+  auth_url          => 'https://identity.openstack.org:5000/v2.0'
38
+}

+ 113
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove.rb View File

@@ -0,0 +1,113 @@
1
+require 'json'
2
+require 'puppet/util/inifile'
3
+
4
+class Puppet::Provider::Trove < Puppet::Provider
5
+
6
+  def self.conf_filename
7
+    '/etc/trove/trove.conf'
8
+  end
9
+
10
+  def self.withenv(hash, &block)
11
+    saved = ENV.to_hash
12
+    hash.each do |name, val|
13
+      ENV[name.to_s] = val
14
+    end
15
+
16
+    yield
17
+  ensure
18
+    ENV.clear
19
+    saved.each do |name, val|
20
+      ENV[name] = val
21
+    end
22
+  end
23
+
24
+  def self.trove_credentials
25
+    @trove_credentials ||= get_trove_credentials
26
+  end
27
+
28
+  def self.get_trove_credentials
29
+    auth_keys = ['auth_host', 'auth_port', 'auth_protocol',
30
+                 'admin_tenant_name', 'admin_user', 'admin_password']
31
+    conf = trove_conf
32
+    if conf and conf['keystone_authtoken'] and
33
+        auth_keys.all?{|k| !conf['keystone_authtoken'][k].nil?}
34
+      return Hash[ auth_keys.map \
35
+                   { |k| [k, conf['keystone_authtoken'][k].strip] } ]
36
+    else
37
+      raise(Puppet::Error, "File: #{conf_filename} does not contain all \
38
+required sections.  Trove types will not work if trove is not \
39
+correctly configured.")
40
+    end
41
+  end
42
+
43
+  def trove_credentials
44
+    self.class.trove_credentials
45
+  end
46
+
47
+  def self.auth_endpoint
48
+    @auth_endpoint ||= get_auth_endpoint
49
+  end
50
+
51
+  def self.get_auth_endpoint
52
+    q = trove_credentials
53
+    "#{q['auth_protocol']}://#{q['auth_host']}:#{q['auth_port']}/v2.0/"
54
+  end
55
+
56
+  def self.trove_conf
57
+    return @trove_conf if @trove_conf
58
+    @trove_conf = Puppet::Util::IniConfig::File.new
59
+    @trove_conf.read(conf_filename)
60
+    @trove_conf
61
+  end
62
+
63
+  def self.auth_trove(*args)
64
+    q = trove_credentials
65
+    authenv = {
66
+      :OS_AUTH_URL    => self.auth_endpoint,
67
+      :OS_USERNAME    => q['admin_user'],
68
+      :OS_TENANT_NAME => q['admin_tenant_name'],
69
+      :OS_PASSWORD    => q['admin_password']
70
+    }
71
+    begin
72
+      withenv authenv do
73
+        trove(args)
74
+      end
75
+    rescue Exception => e
76
+      if (e.message =~ /\[Errno 111\] Connection refused/) or
77
+          (e.message =~ /\(HTTP 400\)/)
78
+        sleep 10
79
+        withenv authenv do
80
+          trove(args)
81
+        end
82
+      else
83
+       raise(e)
84
+      end
85
+    end
86
+  end
87
+
88
+  def auth_trove(*args)
89
+    self.class.auth_trove(args)
90
+  end
91
+
92
+  def trove_manage(*args)
93
+    cmd = args.join(" ")
94
+    output = `#{cmd}`
95
+    $?.exitstatus
96
+  end
97
+
98
+  def self.reset
99
+    @trove_conf        = nil
100
+    @trove_credentials = nil
101
+  end
102
+
103
+  def self.list_trove_resources(type, *args)
104
+    json = auth_trove("--json", "#{type}-list", *args)
105
+    return JSON.parse(json)
106
+  end
107
+
108
+  def self.get_trove_resource_attrs(type, id)
109
+    json = auth_trove("--json", "#{type}-show", id)
110
+    return JSON.parse(json)
111
+  end
112
+
113
+end

+ 27
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_api_paste_ini/ini_setting.rb View File

@@ -0,0 +1,27 @@
1
+Puppet::Type.type(:trove_api_paste_ini).provide(
2
+  :ini_setting,
3
+  :parent => Puppet::Type.type(:ini_setting).provider(:ruby)
4
+) do
5
+
6
+  def section
7
+    resource[:name].split('/', 2).first
8
+  end
9
+
10
+  def setting
11
+    resource[:name].split('/', 2).last
12
+  end
13
+
14
+  def separator
15
+    '='
16
+  end
17
+
18
+  def self.file_path
19
+    '/etc/trove/api-paste.ini'
20
+  end
21
+
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
27
+end

+ 27
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_conductor_config/ini_setting.rb View File

@@ -0,0 +1,27 @@
1
+Puppet::Type.type(:trove_conductor_config).provide(
2
+  :ini_setting,
3
+  :parent => Puppet::Type.type(:ini_setting).provider(:ruby)
4
+) do
5
+
6
+  def section
7
+    resource[:name].split('/', 2).first
8
+  end
9
+
10
+  def setting
11
+    resource[:name].split('/', 2).last
12
+  end
13
+
14
+  def separator
15
+    '='
16
+  end
17
+
18
+  def self.file_path
19
+    '/etc/trove/trove-conductor.conf'
20
+  end
21
+
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
27
+end

+ 27
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_config/ini_setting.rb View File

@@ -0,0 +1,27 @@
1
+Puppet::Type.type(:trove_config).provide(
2
+  :ini_setting,
3
+  :parent => Puppet::Type.type(:ini_setting).provider(:ruby)
4
+) do
5
+
6
+  def section
7
+    resource[:name].split('/', 2).first
8
+  end
9
+
10
+  def setting
11
+    resource[:name].split('/', 2).last
12
+  end
13
+
14
+  def separator
15
+    '='
16
+  end
17
+
18
+  def self.file_path
19
+    '/etc/trove/trove.conf'
20
+  end
21
+
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
27
+end

+ 52
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_datastore/trove.rb View File

@@ -0,0 +1,52 @@
1
+require File.join(File.dirname(__FILE__), "..","..","..",
2
+                  "puppet/provider/trove")
3
+
4
+Puppet::Type.type(:trove_datastore).provide(
5
+  :trove,
6
+  :parent => Puppet::Provider::Trove
7
+) do
8
+  desc <<-EOT
9
+    Trove provider to manage datastore type.
10
+  EOT
11
+
12
+  commands :trove => "trove"
13
+
14
+  mk_resource_methods
15
+
16
+  def self.instances
17
+    list_trove_resources("datastore").collect do |attrs|
18
+      new(
19
+        :ensure         => :present,
20
+        :name           => attrs["name"],
21
+        :id             => attrs["id"]
22
+      )
23
+    end
24
+  end
25
+
26
+  def self.prefetch(resources)
27
+    instances_ = instances
28
+    resources.keys.each do |name|
29
+      if provider = instances_.find{ |instance| instance.name == name }
30
+        resources[name].provider = provider
31
+      end
32
+    end
33
+  end
34
+
35
+  def exists?
36
+    @property_hash[:ensure] == :present
37
+  end
38
+
39
+  def create
40
+    if trove_manage(['trove-manage', 'datastore_update',
41
+                     "#{@resource[:name]}", "''"]) != 0
42
+      fail("Failed to create datastore #{@resource[:name]}")
43
+    end
44
+
45
+    if trove_manage(['trove-manage', 'datastore_update',
46
+                     "#{@resource[:name]}", "#{@resource[:version]}"]) != 0
47
+      fail("Failed to set version for datastore #{@resource[:name]}")
48
+    end
49
+  end
50
+
51
+end
52
+

+ 60
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_datastore_version/trove.rb View File

@@ -0,0 +1,60 @@
1
+require File.join(File.dirname(__FILE__), "..","..","..",
2
+                  "puppet/provider/trove")
3
+
4
+Puppet::Type.type(:trove_datastore_version).provide(
5
+  :trove,
6
+  :parent => Puppet::Provider::Trove
7
+) do
8
+  desc <<-EOT
9
+    Trove provider to manage datastore version type.
10
+  EOT
11
+
12
+  commands :trove => "trove"
13
+
14
+  mk_resource_methods
15
+
16
+  def self.prefetch(resource)
17
+    @datastore_version_hash = nil
18
+  end
19
+
20
+  def self.datastore_version_hash(datastore)
21
+    @datastore_version_hash ||= build_datastore_version_hash(datastore)
22
+  end
23
+
24
+  def datastore_version_hash(datastore)
25
+    self.class.datastore_version_hash(datastore)
26
+  end
27
+
28
+  def self.instances
29
+    []
30
+  end
31
+
32
+  def exists?
33
+    datastore_version_hash(resource[:datastore])[resource[:name]]
34
+  end
35
+
36
+  def create
37
+    cmd = ['trove-manage', 'datastore_version_update',
38
+           "#{@resource[:datastore]}", "#{@resource[:name]}",
39
+           "#{@resource[:manager]}", "#{@resource[:image_id]}",
40
+           "#{@resource[:packages]}", "#{@resource[:active]}"]
41
+    if trove_manage(cmd) != 0
42
+      fail("Failed to create datastore version #{@resource[:name]}")
43
+    end
44
+  end
45
+
46
+  def destroy
47
+    fail("Datastore version cannot be removed")
48
+  end
49
+
50
+  private
51
+
52
+    def self.build_datastore_version_hash(datastore)
53
+      dvs = {}
54
+      list_trove_resources("datastore-version", datastore).collect do |attrs|
55
+        dvs[attrs["name"]] = attrs
56
+      end
57
+      dvs
58
+    end
59
+
60
+end

+ 27
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_guestagent_config/ini_setting.rb View File

@@ -0,0 +1,27 @@
1
+Puppet::Type.type(:trove_guestagent_config).provide(
2
+  :ini_setting,
3
+  :parent => Puppet::Type.type(:ini_setting).provider(:ruby)
4
+) do
5
+
6
+  def section
7
+    resource[:name].split('/', 2).first
8
+  end
9
+
10
+  def setting
11
+    resource[:name].split('/', 2).last
12
+  end
13
+
14
+  def separator
15
+    '='
16
+  end
17
+
18
+  def self.file_path
19
+    '/etc/trove/trove-guestagent.conf'
20
+  end
21
+
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
27
+end

+ 27
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/provider/trove_taskmanager_config/ini_setting.rb View File

@@ -0,0 +1,27 @@
1
+Puppet::Type.type(:trove_taskmanager_config).provide(
2
+  :ini_setting,
3
+  :parent => Puppet::Type.type(:ini_setting).provider(:ruby)
4
+) do
5
+
6
+  def section
7
+    resource[:name].split('/', 2).first
8
+  end
9
+
10
+  def setting
11
+    resource[:name].split('/', 2).last
12
+  end
13
+
14
+  def separator
15
+    '='
16
+  end
17
+
18
+  def self.file_path
19
+    '/etc/trove/trove-taskmanager.conf'
20
+  end
21
+
22
+  # added for backwards compatibility with older versions of inifile
23
+  def file_path
24
+    self.class.file_path
25
+  end
26
+
27
+end

+ 42
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_api_paste_ini.rb View File

@@ -0,0 +1,42 @@
1
+Puppet::Type.newtype(:trove_api_paste_ini) do
2
+
3
+  ensurable
4
+
5
+  newparam(:name, :namevar => true) do
6
+    desc 'Section/setting name to manage from /etc/trove/api-paste.ini'
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
+
18
+    def is_to_s( currentvalue )
19
+      if resource.secret?
20
+        return '[old secret redacted]'
21
+      else
22
+        return currentvalue
23
+      end
24
+    end
25
+
26
+    def should_to_s( newvalue )
27
+      if resource.secret?
28
+        return '[new secret redacted]'
29
+      else
30
+        return newvalue
31
+      end
32
+    end
33
+  end
34
+
35
+  newparam(:secret, :boolean => true) do
36
+    desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
37
+
38
+    newvalues(:true, :false)
39
+
40
+    defaultto false
41
+  end
42
+end

+ 42
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_conductor_config.rb View File

@@ -0,0 +1,42 @@
1
+Puppet::Type.newtype(:trove_conductor_config) do
2
+
3
+  ensurable
4
+
5
+  newparam(:name, :namevar => true) do
6
+    desc 'Section/setting name to manage from /etc/trove/trove-conductor.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
+
18
+    def is_to_s( currentvalue )
19
+      if resource.secret?
20
+        return '[old secret redacted]'
21
+      else
22
+        return currentvalue
23
+      end
24
+    end
25
+
26
+    def should_to_s( newvalue )
27
+      if resource.secret?
28
+        return '[new secret redacted]'
29
+      else
30
+        return newvalue
31
+      end
32
+    end
33
+  end
34
+
35
+  newparam(:secret, :boolean => true) do
36
+    desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
37
+
38
+    newvalues(:true, :false)
39
+
40
+    defaultto false
41
+  end
42
+end

+ 42
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_config.rb View File

@@ -0,0 +1,42 @@
1
+Puppet::Type.newtype(:trove_config) do
2
+
3
+  ensurable
4
+
5
+  newparam(:name, :namevar => true) do
6
+    desc 'Section/setting name to manage from /etc/trove/trove.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
+
18
+    def is_to_s( currentvalue )
19
+      if resource.secret?
20
+        return '[old secret redacted]'
21
+      else
22
+        return currentvalue
23
+      end
24
+    end
25
+
26
+    def should_to_s( newvalue )
27
+      if resource.secret?
28
+        return '[new secret redacted]'
29
+      else
30
+        return newvalue
31
+      end
32
+    end
33
+  end
34
+
35
+  newparam(:secret, :boolean => true) do
36
+    desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
37
+
38
+    newvalues(:true, :false)
39
+
40
+    defaultto false
41
+  end
42
+end

+ 26
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_datastore.rb View File

@@ -0,0 +1,26 @@
1
+Puppet::Type.newtype(:trove_datastore) do
2
+
3
+  @doc = "Manage creation of Trove datastores"
4
+
5
+  ensurable
6
+
7
+  newparam(:name, :namevar => true) do
8
+    desc "Datastore version name)"
9
+    newvalues(/^.*$/)
10
+  end
11
+
12
+  newparam(:version) do
13
+    desc "Datastore version name"
14
+  end
15
+
16
+  newproperty(:id) do
17
+    validate do |v|
18
+      raise(Puppet::Error, 'This is a read only property')
19
+    end
20
+  end
21
+
22
+  validate do
23
+    raise(Puppet::Error, 'Version must be set') unless self[:version]
24
+  end
25
+end
26
+

+ 38
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_datastore_version.rb View File

@@ -0,0 +1,38 @@
1
+Puppet::Type.newtype(:trove_datastore_version) do
2
+
3
+  @doc = "Manage creation of Trove datastore versions"
4
+
5
+  ensurable
6
+
7
+  newparam(:name, :namevar => true) do
8
+    desc "Datastore version"
9
+  end
10
+
11
+  newparam(:datastore) do
12
+    desc "Datastore name)"
13
+  end
14
+
15
+  newparam(:manager) do
16
+    desc "Manager name"
17
+  end
18
+
19
+  newparam(:image_id) do
20
+    desc "Glance image id"
21
+  end
22
+
23
+  newparam(:packages) do
24
+    desc "Packages to install"
25
+  end
26
+
27
+  newparam(:active) do
28
+    desc "State"
29
+  end
30
+
31
+  validate do
32
+    raise(Puppet::Error, 'Datastore must be set') unless self[:datastore]
33
+    raise(Puppet::Error, 'Manager must be set') unless self[:manager]
34
+    raise(Puppet::Error, 'Image must be set') unless self[:image_id]
35
+    raise(Puppet::Error, 'Packages must be set') unless self[:packages]
36
+    raise(Puppet::Error, 'State must be set') unless self[:active]
37
+  end
38
+end

+ 42
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_guestagent_config.rb View File

@@ -0,0 +1,42 @@
1
+Puppet::Type.newtype(:trove_guestagent_config) do
2
+
3
+  ensurable
4
+
5
+  newparam(:name, :namevar => true) do
6
+    desc 'Section/setting name to manage from /etc/trove/trove-guestagent.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
+
18
+    def is_to_s( currentvalue )
19
+      if resource.secret?
20
+        return '[old secret redacted]'
21
+      else
22
+        return currentvalue
23
+      end
24
+    end
25
+
26
+    def should_to_s( newvalue )
27
+      if resource.secret?
28
+        return '[new secret redacted]'
29
+      else
30
+        return newvalue
31
+      end
32
+    end
33
+  end
34
+
35
+  newparam(:secret, :boolean => true) do
36
+    desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
37
+
38
+    newvalues(:true, :false)
39
+
40
+    defaultto false
41
+  end
42
+end

+ 42
- 0
deployment_scripts/puppet/modules/trove/lib/puppet/type/trove_taskmanager_config.rb View File

@@ -0,0 +1,42 @@
1
+Puppet::Type.newtype(:trove_taskmanager_config) do
2
+
3
+  ensurable
4
+
5
+  newparam(:name, :namevar => true) do
6
+    desc 'Section/setting name to manage from /etc/trove/trove-taskmanager.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
+
18
+    def is_to_s( currentvalue )
19
+      if resource.secret?
20
+        return '[old secret redacted]'
21
+      else
22
+        return currentvalue
23
+      end
24
+    end
25
+
26
+    def should_to_s( newvalue )
27
+      if resource.secret?
28
+        return '[new secret redacted]'
29
+      else
30
+        return newvalue
31
+      end
32
+    end
33
+  end
34
+
35
+  newparam(:secret, :boolean => true) do
36
+    desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
37
+
38
+    newvalues(:true, :false)
39
+
40
+    defaultto false
41
+  end
42
+end

+ 370
- 0
deployment_scripts/puppet/modules/trove/manifests/api.pp View File

@@ -0,0 +1,370 @@
1
+#
2
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3
+#
4
+# Author: Emilien Macchi <emilien.macchi@enovance.com>
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#      http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+#
18
+# == Class trove::api
19
+#
20
+# Configure API service in trove
21
+#
22
+# == Parameters
23
+#
24
+# [*manage_service*]
25
+#   (optional) Whether to start/stop the service
26
+#   Defaults to true
27
+#
28
+# [*ensure_package*]
29
+#   (optional) Whether the trove api package will be installed
30
+#   Defaults to 'present'
31
+#
32
+# [*keystone_password*]
33
+#   (required) Password used to authentication.
34
+#
35
+# [*verbose*]
36
+#   (optional) Rather to log the trove api service at verbose level.
37
+#   Default: false
38
+#
39
+# [*debug*]
40
+#   (optional) Rather to log the trove api service at debug level.
41
+#   Default: false
42
+#
43
+# [*bind_host*]
44
+#   (optional) The address of the host to bind to.
45
+#   Default: 0.0.0.0
46
+#
47
+# [*bind_port*]
48
+#   (optional) The port the server should bind to.
49
+#   Default: 8779
50
+#
51
+# [*backlog*]
52
+#   (optional) Backlog requests when creating socket
53
+#   Default: 4096
54
+#
55
+# [*workers*]
56
+#   (optional) Number of trove API worker processes to start
57
+#   Default: $::processorcount
58
+#
59
+# [*log_file*]
60
+#   (optional) The path of file used for logging
61
+#   If set to boolean false, it will not log to any file.
62
+#   Default: /var/log/trove/trove-api.log
63
+#
64
+# [*log_dir*]
65
+#   (optional) directory to which trove logs are sent.
66
+#   If set to boolean false, it will not log to any directory.
67
+#   Defaults to '/var/log/trove'
68
+#
69
+# [*auth_host*]
70
+#   (optional) Host running auth service.
71
+#   Defaults to '127.0.0.1'.
72
+#
73
+# [*auth_url*]
74
+#   (optional) Authentication URL.
75
+#   Defaults to 'http://localhost:5000/v2.0'.
76
+#
77
+# [*auth_port*]
78
+#   (optional) Port to use for auth service on auth_host.
79
+#   Defaults to '35357'.
80
+#
81
+# [*auth_protocol*]
82
+#   (optional) Protocol to use for auth.
83
+#   Defaults to 'http'.
84
+#
85
+# [*keystone_tenant*]
86
+#   (optional) Tenant to authenticate to.
87
+#   Defaults to services.
88
+#
89
+# [*keystone_user*]
90
+#   (optional) User to authenticate as with keystone.
91
+#   Defaults to 'trove'.
92
+#
93
+# [*enabled*]
94
+#   (optional) Whether to enable services.
95
+#   Defaults to true.
96
+#
97
+# [*use_syslog*]
98
+#   (optional) Use syslog for logging.
99
+#   Defaults to false.
100
+#
101
+# [*log_facility*]
102
+#   (optional) Syslog facility to receive log lines.
103
+#   Defaults to 'LOG_USER'.
104
+#
105
+# [*purge_config*]
106
+#   (optional) Whether to set only the specified config options
107
+#   in the api config.
108
+#   Defaults to false.
109
+#
110
+# [*cert_file*]
111
+#   (optinal) Certificate file to use when starting API server securely
112
+#   Defaults to false, not set
113
+#
114
+# [*key_file*]
115
+#   (optional) Private key file to use when starting API server securely
116
+#   Defaults to false, not set
117
+#
118
+# [*ca_file*]
119
+#   (optional) CA certificate file to use to verify connecting clients
120
+#   Defaults to false, not set
121
+#
122
+class trove::api(
123
+  $keystone_password,
124
+  $verbose                      = false,
125
+  $debug                        = false,
126
+  $bind_host                    = '0.0.0.0',
127
+  $bind_port                    = '8779',
128
+  $backlog                      = '4096',
129
+  $workers                      = $::processorcount,
130
+  $log_file                     = '/var/log/trove/trove-api.log',
131
+  $log_dir                      = '/var/log/trove',
132
+  $auth_host                    = '127.0.0.1',
133
+  $auth_url                     = false,
134
+  $auth_port                    = '35357',
135
+  $auth_protocol                = 'http',
136
+  $keystone_tenant              = 'services',
137
+  $keystone_user                = 'trove',
138
+  $enabled                      = true,
139
+  $use_syslog                   = false,
140
+  $log_facility                 = 'LOG_USER',
141
+  $purge_config                 = false,
142
+  $cert_file                    = false,
143
+  $key_file                     = false,
144
+  $ca_file                      = false,
145
+  $manage_service               = true,
146
+  $ensure_package               = 'present',
147
+) inherits trove {
148
+
149
+  require ::keystone::python
150
+  include ::trove::params
151
+
152
+  Trove_config<||> ~> Exec['post-trove_config']
153
+  Trove_config<||> ~> Service['trove-api']
154
+  Package['trove-api'] -> Trove_api_paste_ini<||>
155
+  Trove_api_paste_ini<||> ~> Service['trove-api']
156
+  # Trove db sync is broken in Ubuntu packaging
157
+  # This is a temporary fix until it's fixed in packaging.
158
+  # https://bugs.launchpad.net/ubuntu/+source/openstack-trove/+bug/1451134
159
+  file { '/etc/trove/trove.conf':
160
+    require => File['/etc/trove'],
161
+  }
162
+  File['/etc/trove/trove.conf'] -> Trove_config<||>
163
+  Trove_config<||> -> Package[$::trove::params::api_package_name]
164
+
165
+  if $::trove::database_connection {
166
+    if($::trove::database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
167
+      require 'mysql::bindings'
168
+      require 'mysql::bindings::python'
169
+    } elsif($::trove::database_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
170
+
171
+    } elsif($::trove::database_connection =~ /sqlite:\/\//) {
172
+
173
+    } else {
174
+      fail("Invalid db connection ${::trove::database_connection}")
175
+    }
176
+    trove_config {
177
+      'database/connection':   value => $::trove::database_connection;
178
+      'database/idle_timeout': value => $::trove::database_idle_timeoutl;
179
+    }
180
+  }
181
+
182
+  # basic service config
183
+  trove_config {
184
+    'DEFAULT/verbose':                      value => $verbose;
185
+    'DEFAULT/debug':                        value => $debug;
186
+    'DEFAULT/bind_host':                    value => $bind_host;
187
+    'DEFAULT/bind_port':                    value => $bind_port;
188
+    'DEFAULT/backlog':                      value => $backlog;
189
+    'DEFAULT/trove_api_workers':            value => $workers;
190
+    'DEFAULT/nova_proxy_admin_user':        value => $::trove::nova_proxy_admin_user;
191
+    'DEFAULT/nova_proxy_admin_pass':        value => $::trove::nova_proxy_admin_pass;
192
+    'DEFAULT/nova_proxy_admin_tenant_name': value => $::trove::nova_proxy_admin_tenant_name;
193
+    'DEFAULT/control_exchange':             value => $::trove::control_exchange;
194
+  }
195
+
196
+  if $auth_url {
197
+    trove_config { 'DEFAULT/trove_auth_url': value => $auth_url; }
198
+  } else {
199
+    trove_config { 'DEFAULT/trove_auth_url': value => "${auth_protocol}://${auth_host}:5000/v2.0"; }
200
+  }
201
+
202
+  # auth config
203
+  trove_config {
204
+    'keystone_authtoken/auth_host':         value => $auth_host;
205
+    'keystone_authtoken/auth_port':         value => $auth_port;
206
+    'keystone_authtoken/auth_protocol':     value => $auth_protocol;
207
+    'keystone_authtoken/admin_tenant_name': value => $keystone_tenant;
208
+    'keystone_authtoken/admin_user':        value => $keystone_user;
209
+    'keystone_authtoken/admin_password':    value => $keystone_password, secret => true;
210
+  }
211
+
212
+  # SSL Options
213
+  if $cert_file {
214
+    trove_config {
215
+      'DEFAULT/cert_file' : value => $cert_file;
216
+    }
217
+  } else {
218
+    trove_config {
219
+      'DEFAULT/cert_file': ensure => absent;
220
+    }
221
+  }
222
+  if $key_file {
223
+    trove_config {
224
+      'DEFAULT/key_file'  : value => $key_file;
225
+    }
226
+  } else {
227
+    trove_config {
228
+      'DEFAULT/key_file': ensure => absent;
229
+    }
230
+  }
231
+  if $ca_file {
232
+    trove_config {
233
+      'DEFAULT/ca_file'   : value => $ca_file;
234
+    }
235
+  } else {
236
+    trove_config {
237
+      'DEFAULT/ca_file': ensure => absent;
238
+    }
239
+  }
240
+
241
+  # Logging
242
+  if $log_file {
243
+    trove_config {
244
+      'DEFAULT/log_file': value  => $log_file;
245
+    }
246
+  } else {
247
+    trove_config {
248
+      'DEFAULT/log_file': ensure => absent;
249
+    }
250
+  }
251
+
252
+  if $log_dir {
253
+    trove_config {
254
+      'DEFAULT/log_dir': value  => $log_dir;
255
+    }
256
+  } else {
257
+    trove_config {
258
+      'DEFAULT/log_dir': ensure => absent;
259
+    }
260
+  }
261
+
262
+  # Syslog
263
+  if $use_syslog {
264
+    trove_config {
265
+      'DEFAULT/use_syslog'          : value => true;
266
+      'DEFAULT/syslog_log_facility' : value => $log_facility;
267
+    }
268
+  } else {
269
+    trove_config {
270
+      'DEFAULT/use_syslog': value => false;
271
+    }
272
+  }
273
+
274
+  resources { 'trove_config':
275
+    purge => $purge_config,
276
+  }
277
+
278
+  if $::trove::rpc_backend == 'trove.openstack.common.rpc.impl_kombu' {
279
+    if ! $::trove::rabbit_password {
280
+      fail('When rpc_backend is rabbitmq, you must set rabbit password')
281
+    }
282
+    if $::trove::rabbit_hosts {
283
+      trove_config { 'oslo_messaging_rabbit/rabbit_hosts':     value  => join($::trove::rabbit_hosts, ',') }
284
+      trove_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value  => true }
285
+    } else  {
286
+      trove_config { 'oslo_messaging_rabbit/rabbit_host':      value => $::trove::rabbit_host }
287
+      trove_config { 'oslo_messaging_rabbit/rabbit_port':      value => $::trove::rabbit_port }
288
+      trove_config { 'oslo_messaging_rabbit/rabbit_hosts':     value => "${::trove::rabbit_host}:${::trove::rabbit_port}" }
289
+      trove_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false }
290
+    }
291
+
292
+    trove_config {
293
+      'oslo_messaging_rabbit/rabbit_userid':         value => $::trove::rabbit_user;
294
+      'oslo_messaging_rabbit/rabbit_password':       value => $::trove::rabbit_password, secret => true;
295
+      'oslo_messaging_rabbit/rabbit_virtual_host':   value => $::trove::rabbit_virtual_host;
296
+      'oslo_messaging_rabbit/rabbit_use_ssl':        value => $::trove::rabbit_use_ssl;
297
+      'oslo_messaging_rabbit/kombu_reconnect_delay': value => $::trove::kombu_reconnect_delay;
298
+    }
299
+
300
+    if $::trove::rabbit_use_ssl {
301
+
302
+      if $::trove::kombu_ssl_ca_certs {
303
+        trove_config { 'oslo_messaging_rabbit/kombu_ssl_ca_certs': value => $::trove::kombu_ssl_ca_certs; }
304
+      } else {
305
+        trove_config { 'oslo_messaging_rabbit/kombu_ssl_ca_certs': ensure => absent; }
306
+      }
307
+
308
+      if $::trove::kombu_ssl_certfile or $::trove::kombu_ssl_keyfile {
309
+        trove_config {
310
+          'oslo_messaging_rabbit/kombu_ssl_certfile': value => $::trove::kombu_ssl_certfile;
311
+          'oslo_messaging_rabbit/kombu_ssl_keyfile':  value => $::trove::kombu_ssl_keyfile;
312
+        }
313
+      } else {
314
+        trove_config {
315
+          'oslo_messaging_rabbit/kombu_ssl_certfile': ensure => absent;
316
+          'oslo_messaging_rabbit/kombu_ssl_keyfile':  ensure => absent;
317
+        }
318
+      }
319
+
320
+      if $::trove::kombu_ssl_version {
321
+        trove_config { 'oslo_messaging_rabbit/kombu_ssl_version':  value => $::trove::kombu_ssl_version; }
322
+      } else {
323
+        trove_config { 'oslo_messaging_rabbit/kombu_ssl_version':  ensure => absent; }
324
+      }
325
+
326
+    } else {
327
+      trove_config {
328
+        'oslo_messaging_rabbit/kombu_ssl_ca_certs': ensure => absent;
329
+        'oslo_messaging_rabbit/kombu_ssl_certfile': ensure => absent;
330
+        'oslo_messaging_rabbit/kombu_ssl_keyfile':  ensure => absent;
331
+        'oslo_messaging_rabbit/kombu_ssl_version':  ensure => absent;
332
+      }
333
+    }
334
+  }
335
+
336
+  if $::trove::rpc_backend == 'trove.openstack.common.rpc.impl_qpid' {
337
+    trove_config {
338
+      'DEFAULT/qpid_hostname':               value => $::trove::qpid_hostname;
339
+      'DEFAULT/qpid_port':                   value => $::trove::qpid_port;
340
+      'DEFAULT/qpid_username':               value => $::trove::qpid_username;
341
+      'DEFAULT/qpid_password':               value => $::trove::qpid_password, secret => true;
342
+      'DEFAULT/qpid_heartbeat':              value => $::trove::qpid_heartbeat;
343
+      'DEFAULT/qpid_protocol':               value => $::trove::qpid_protocol;
344
+      'DEFAULT/qpid_tcp_nodelay':            value => $::trove::qpid_tcp_nodelay;
345
+    }
346
+    if is_array($::trove::qpid_sasl_mechanisms) {
347
+      trove_config {
348
+        'DEFAULT/qpid_sasl_mechanisms': value => join($::trove::qpid_sasl_mechanisms, ' ');
349
+      }
350
+    }
351
+    elsif $::trove::qpid_sasl_mechanisms {
352
+      trove_config {
353
+        'DEFAULT/qpid_sasl_mechanisms': value => $::trove::qpid_sasl_mechanisms;
354
+      }
355
+    }
356
+    else {
357
+      trove_config {
358
+        'DEFAULT/qpid_sasl_mechanisms': ensure => absent;
359
+      }
360
+    }
361
+  }
362
+
363
+  trove::generic_service { 'api':
364
+    enabled        => $enabled,
365
+    manage_service => $manage_service,
366
+    ensure_package => $ensure_package,
367
+    package_name   => $::trove::params::api_package_name,
368
+    service_name   => $::trove::params::api_service_name,
369
+  }
370
+}

+ 40
- 0
deployment_scripts/puppet/modules/trove/manifests/client.pp View File

@@ -0,0 +1,40 @@
1
+#
2
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3
+#
4
+# Author: Emilien Macchi <emilien.macchi@enovance.com>
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#      http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+
18
+# trove::client
19
+#
20
+# Manages the trove client package on systems
21
+#
22
+# === Parameters:
23
+#
24
+# [*package_ensure*]
25
+#   (optional) The state of the package
26
+#   Defaults to present
27
+#
28
+#
29
+class trove::client (
30
+  $package_ensure = present
31
+) {
32
+
33
+  include ::trove::params
34
+
35
+  package { 'python-troveclient':
36
+    ensure => $package_ensure,
37
+    name   => $::trove::params::client_package_name,
38
+  }
39
+
40
+}

+ 224
- 0
deployment_scripts/puppet/modules/trove/manifests/conductor.pp View File

@@ -0,0 +1,224 @@
1
+# == Class: trove::conductor
2
+#
3
+# Manages trove conductor package and service
4
+#
5
+# === Parameters:
6
+#
7
+# [*enabled*]
8
+#   (optional) Whether to enable the trove-conductor service
9
+#   Defaults to true
10
+#
11
+# [*manage_service*]
12
+#   (optional) Whether to start/stop the service
13
+#   Defaults to true
14
+#
15
+# [*ensure_package*]
16
+#   (optional) The state of the trove conductor package
17
+#   Defaults to 'present'
18
+#
19
+# [*verbose*]
20
+#   (optional) Rather to log the trove api service at verbose level.
21
+#   Default: false
22
+#
23
+# [*debug*]
24
+#   (optional) Rather to log the trove api service at debug level.
25
+#   Default: false
26
+#
27
+# [*log_file*]
28
+#   (optional) The path of file used for logging
29
+#   If set to boolean false, it will not log to any file.
30
+#   Default: /var/log/trove/trove-conductor.log
31
+#
32
+# [*log_dir*]
33
+#    (optional) directory to which trove logs are sent.
34
+#    If set to boolean false, it will not log to any directory.
35
+#    Defaults to '/var/log/trove'
36
+#
37
+# [*use_syslog*]
38
+#   (optional) Use syslog for logging.
39
+#   Defaults to false.
40
+#
41
+# [*log_facility*]
42
+#   (optional) Syslog facility to receive log lines.
43
+#   Defaults to 'LOG_USER'.
44
+#
45
+# [*auth_url*]
46
+#   (optional) Authentication URL.
47
+#   Defaults to 'http://localhost:5000/v2.0'.
48
+#
49
+# [*conductor_manager*]
50
+#   (optional) Trove conductor manager.
51
+#   Defaults to 'trove.conductor.manager.Manager'.
52
+#
53
+class trove::conductor(
54
+  $enabled                   = true,
55
+  $manage_service            = true,
56
+  $ensure_package            = 'present',
57
+  $verbose                   = false,
58
+  $debug                     = false,
59
+  $log_file                  = '/var/log/trove/trove-conductor.log',
60
+  $log_dir                   = '/var/log/trove',
61
+  $use_syslog                = false,
62
+  $log_facility              = 'LOG_USER',
63
+  $auth_url                  = 'http://localhost:5000/v2.0',
64
+  $conductor_manager         = 'trove.conductor.manager.Manager',
65
+) inherits trove {
66
+
67
+  include ::trove::params
68
+
69
+  Trove_conductor_config<||> ~> Exec['post-trove_config']
70
+  Trove_conductor_config<||> ~> Service['trove-conductor']
71
+  # Trove db sync is broken in Ubuntu packaging
72
+  # This is a temporary fix until it's fixed in packaging.
73
+  # https://bugs.launchpad.net/ubuntu/+source/openstack-trove/+bug/1451134
74
+  file { '/etc/trove/trove-conductor.conf':
75
+    require => File['/etc/trove'],
76
+  }
77
+  File['/etc/trove/trove-conductor.conf'] -> Trove_conductor_config<||>
78
+  Trove_conductor_config<||> -> Package[$::trove::params::conductor_package_name]
79
+
80
+  if $::trove::database_connection {
81
+    if($::trove::database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
82
+      require 'mysql::bindings'
83
+      require 'mysql::bindings::python'
84
+    } elsif($::trove::database_connection =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
85
+
86
+    } elsif($::trove::database_connection =~ /sqlite:\/\//) {
87
+
88
+    } else {
89
+      fail("Invalid db connection ${::trove::database_connection}")
90
+    }
91
+    trove_conductor_config {
92
+      'database/connection':   value => $::trove::database_connection;
93
+      'database/idle_timeout': value => $::trove::database_idle_timeoutl;
94
+    }
95
+  }
96
+
97
+  # basic service config
98
+  trove_conductor_config {
99
+    'DEFAULT/verbose':                      value => $verbose;
100
+    'DEFAULT/debug':                        value => $debug;
101
+    'DEFAULT/trove_auth_url':               value => $auth_url;
102
+    'DEFAULT/nova_proxy_admin_user':        value => $::trove::nova_proxy_admin_user;
103
+    'DEFAULT/nova_proxy_admin_tenant_name': value => $::trove::nova_proxy_admin_tenant_name;
104
+    'DEFAULT/nova_proxy_admin_pass':        value => $::trove::nova_proxy_admin_pass;
105
+    'DEFAULT/control_exchange':             value => $::trove::control_exchange;
106
+  }
107
+
108
+  if $::trove::rpc_backend == 'trove.openstack.common.rpc.impl_kombu' {
109
+    if ! $::trove::rabbit_password {
110
+      fail('When rpc_backend is rabbitmq, you must set rabbit password')
111
+    }
112
+    if $::trove::rabbit_hosts {
113
+      trove_conductor_config { 'oslo_messaging_rabbit/rabbit_hosts':     value  => join($::trove::rabbit_hosts, ',') }
114
+      trove_conductor_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value  => true }
115
+    } else  {
116
+      trove_conductor_config { 'oslo_messaging_rabbit/rabbit_host':      value => $::trove::rabbit_host }
117
+      trove_conductor_config { 'oslo_messaging_rabbit/rabbit_port':      value => $::trove::rabbit_port }
118
+      trove_conductor_config { 'oslo_messaging_rabbit/rabbit_hosts':     value => "${::trove::rabbit_host}:${::trove::rabbit_port}" }
119
+      trove_conductor_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false }
120
+    }
121
+
122
+    trove_conductor_config {
123
+      'oslo_messaging_rabbit/rabbit_userid':         value => $::trove::rabbit_user;
124
+      'oslo_messaging_rabbit/rabbit_password':       value => $::trove::rabbit_password, secret => true;
125
+      'oslo_messaging_rabbit/rabbit_virtual_host':   value => $::trove::rabbit_virtual_host;
126
+      'oslo_messaging_rabbit/rabbit_use_ssl':        value => $::trove::rabbit_use_ssl;
127
+      'oslo_messaging_rabbit/kombu_reconnect_delay': value => $::trove::kombu_reconnect_delay;
128
+    }
129
+
130
+    if $::trove::rabbit_use_ssl {
131
+
132
+      if $::trove::kombu_ssl_ca_certs {
133
+        trove_conductor_config { 'oslo_messaging_rabbit/kombu_ssl_ca_certs': value => $::trove::kombu_ssl_ca_certs; }
134
+      } else {
135
+        trove_conductor_config { 'oslo_messaging_rabbit/kombu_ssl_ca_certs': ensure => absent; }
136
+      }
137
+
138
+      if $::trove::kombu_ssl_certfile or $::trove::kombu_ssl_keyfile {
139
+        trove_conductor_config {
140
+          'oslo_messaging_rabbit/kombu_ssl_certfile': value => $::trove::kombu_ssl_certfile;
141
+          'oslo_messaging_rabbit/kombu_ssl_keyfile':  value => $::trove::kombu_ssl_keyfile;
142
+        }
143
+      } else {
144
+        trove_conductor_config {
145
+          'oslo_messaging_rabbit/kombu_ssl_certfile': ensure => absent;
146
+          'oslo_messaging_rabbit/kombu_ssl_keyfile':  ensure => absent;
147
+        }
148
+      }
149
+
150
+      if $::trove::kombu_ssl_version {
151
+        trove_conductor_config { 'oslo_messaging_rabbit/kombu_ssl_version':  value => $::trove::kombu_ssl_version; }
152
+      } else {
153
+        trove_conductor_config { 'oslo_messaging_rabbit/kombu_ssl_version':  ensure => absent; }
154
+      }
155
+
156
+    } else {
157
+      trove_conductor_config {
158
+        'oslo_messaging_rabbit/kombu_ssl_ca_certs': ensure => absent;
159
+        'oslo_messaging_rabbit/kombu_ssl_certfile': ensure => absent;
160
+        'oslo_messaging_rabbit/kombu_ssl_keyfile':  ensure => absent;
161
+        'oslo_messaging_rabbit/kombu_ssl_version':  ensure => absent;
162
+      }
163
+    }
164
+  }
165
+
166
+  if $::trove::rpc_backend == 'trove.openstack.common.rpc.impl_qpid' {
167
+    trove_conductor_config {
168
+      'DEFAULT/qpid_hostname':               value => $::trove::qpid_hostname;
169
+      'DEFAULT/qpid_port':                   value => $::trove::qpid_port;
170
+      'DEFAULT/qpid_username':               value => $::trove::qpid_username;
171
+      'DEFAULT/qpid_password':               value => $::trove::qpid_password, secret => true;
172
+      'DEFAULT/qpid_heartbeat':              value => $::trove::qpid_heartbeat;
173
+      'DEFAULT/qpid_protocol':               value => $::trove::qpid_protocol;
174
+      'DEFAULT/qpid_tcp_nodelay':            value => $::trove::qpid_tcp_nodelay;
175
+    }
176
+    if is_array($::trove::qpid_sasl_mechanisms) {
177
+      trove_conductor_config {
178
+        'DEFAULT/qpid_sasl_mechanisms': value => join($::trove::qpid_sasl_mechanisms, ' ');
179
+      }
180
+    }
181
+  }
182
+
183
+  # Logging
184
+  if $log_file {
185
+    trove_conductor_config {
186
+      'DEFAULT/log_file': value  => $log_file;
187
+    }
188
+  } else {
189
+    trove_conductor_config {
190
+      'DEFAULT/log_file': ensure => absent;
191
+    }
192
+  }
193
+
194
+  if $log_dir {
195
+    trove_conductor_config {
196
+      'DEFAULT/log_dir': value  => $log_dir;
197
+    }
198
+  } else {
199
+    trove_conductor_config {
200
+      'DEFAULT/log_dir': ensure => absent;
201
+    }
202
+  }
203
+
204
+  # Syslog
205
+  if $use_syslog {
206
+    trove_conductor_config {
207
+      'DEFAULT/use_syslog'          : value => true;
208
+      'DEFAULT/syslog_log_facility' : value => $log_facility;
209
+    }
210
+  } else {
211
+    trove_conductor_config {
212
+      'DEFAULT/use_syslog': value => false;
213
+    }
214
+  }
215
+
216
+  trove::generic_service { 'conductor':
217
+    enabled        => $enabled,
218
+    manage_service => $manage_service,
219
+    package_name   => $::trove::params::conductor_package_name,
220
+    service_name   => $::trove::params::conductor_service_name,
221
+    ensure_package => $ensure_package,
222
+  }
223
+
224
+}

+ 84
- 0
deployment_scripts/puppet/modules/trove/manifests/config.pp View File

@@ -0,0 +1,84 @@
1
+#
2
+# Copyright (C) 2015  UnitedStack <devops@unitedstack.com>
3
+#
4
+# Author: Xingchao Yu <xingchao@unitedstack.com>
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#      http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+#
18
+# == Class: trove::config
19
+#
20
+# This class is used to manage arbitrary trove configurations.
21
+#
22
+# === Parameters
23
+#
24
+# [*trove_config*]
25
+#   (optional) Allow configuration of arbitrary trove configurations.
26
+#   The value is an hash of trove_config resources.
27
+#   Defaults to {}
28
+#
29
+# [*trove_taskmanager_config*]
30
+#   (optional) Allow configuration of arbitrary trove taskmanager configurations.
31
+#   The value is an hash of trove_taskmanager_config resources.
32
+#   Defaults to {}
33
+#
34
+# [*trove_conductor_config*]
35
+#   (optional) Allow configuration of arbitrary trove conductor configurations.
36
+#   The value is an hash of trove_conductor_config resources.
37
+#   Defaults to {}
38
+#
39
+# [*trove_guestagent_config*]
40
+#   (optional) Allow configuration of arbitrary trove guestagent configurations.
41
+#   The value is an hash of trove_guestagent_config resources.
42
+#   Defaults to {}
43
+#
44
+# [*trove_api_paste_ini*]
45
+#   (optional) Allow configuration of arbitrary trove paste api configurations.
46
+#   The value is an hash of trove_paste_api_ini resources.
47
+#   Defaults to {}
48
+#
49
+#   Example:
50
+#   { 'DEFAULT/foo' => { value => 'fooValue'},
51
+#     'DEFAULT/bar' => { value => 'barValue'}
52
+#   }
53
+#
54
+#   In yaml format, Example:
55
+#   trove_config:
56
+#     DEFAULT/foo:
57
+#       value: fooValue
58
+#     DEFAULT/bar:
59
+#       value: barValue
60
+#
61
+#   NOTE: The configuration MUST NOT be already handled by this module
62
+#   or Puppet catalog compilation will fail with duplicate resources.
63
+#
64
+class trove::config (
65
+  $trove_config             = {},
66
+  $trove_taskmanager_config = {},
67
+  $trove_conductor_config   = {},
68
+  $trove_guestagent_config  = {},
69
+  $trove_api_paste_ini      = {},
70
+) {
71
+
72
+  validate_hash($trove_config)
73
+  validate_hash($trove_taskmanager_config)
74
+  validate_hash($trove_conductor_config)
75
+  validate_hash($trove_guestagent_config)
76
+  validate_hash($trove_api_paste_ini)
77
+
78
+  create_resources('trove_config', $trove_config)
79
+  create_resources('trove_taskmanager_config', $trove_taskmanager_config)
80
+  create_resources('trove_conductor_config', $trove_conductor_config)
81
+  create_resources('trove_guestagent_config', $trove_guestagent_config)
82
+  create_resources('trove_api_paste_ini', $trove_api_paste_ini)
83
+
84
+}

+ 83
- 0
deployment_scripts/puppet/modules/trove/manifests/db/mysql.pp View File

@@ -0,0 +1,83 @@
1
+#
2
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3
+#
4
+# Author: Emilien Macchi <emilien.macchi@enovance.com>
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#      http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+#
18
+# == Class: trove::db::mysql
19
+#
20
+# The trove::db::mysql class creates a MySQL database for trove.
21
+# It must be used on the MySQL server
22
+#
23
+# === Parameters
24
+#
25
+# [*password*]
26
+#   (required) Password that will be used for the trove db user.
27
+#
28
+# [*dbname*]
29
+#   (optional) Name of trove database.
30
+#   Defaults to trove
31
+#
32
+# [*user*]
33
+#   (optional) Name of trove user.
34
+#   Defaults to trove
35
+#
36
+# [*host*]
37
+#   (optional) Host where user should be allowed all privileges for database.
38
+#   Defaults to 127.0.0.1
39
+#
40
+# [*allowed_hosts*]
41
+#   (optional) Hosts allowed to use the database
42
+#   Defaults to undef.
43
+#
44
+# [*charset*]
45
+#   (optional) Charset of trove database
46
+#   Defaults 'utf8'.
47
+#
48
+# [*collate*]
49
+#   (optional) Charset collate of trove database
50
+#   Defaults 'utf8_general_ci'.
51
+#
52
+# [*mysql_module*]
53
+#   (optional) Deprecated. Does nothing
54
+#
55
+class trove::db::mysql(
56
+  $password,
57
+  $dbname        = 'trove',
58
+  $user          = 'trove',
59
+  $host          = '127.0.0.1',
60
+  $allowed_hosts = undef,
61
+  $charset       = 'utf8',
62
+  $collate       = 'utf8_general_ci',
63
+  $mysql_module  = undef,
64
+) {
65
+
66
+  if $mysql_module {
67
+    warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
68
+  }
69
+
70
+  validate_string($password)
71
+
72
+  ::openstacklib::db::mysql { 'trove':
73
+    user          => $user,
74
+    password_hash => mysql_password($password),
75
+    dbname        => $dbname,
76
+    host          => $host,
77
+    charset       => $charset,
78
+    collate       => $collate,
79
+    allowed_hosts => $allowed_hosts,
80
+  }
81
+
82
+  ::Openstacklib::Db::Mysql['trove'] ~> Exec<| title == 'trove-db-sync' |>
83
+}

+ 47
- 0
deployment_scripts/puppet/modules/trove/manifests/db/postgresql.pp View File

@@ -0,0 +1,47 @@
1
+# == Class: trove::db::postgresql
2
+#
3
+# Class that configures postgresql for trove
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 'trove'.
14
+#
15
+# [*user*]
16
+#   (Optional) User to connect to the database.
17
+#   Defaults to 'trove'.
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
+class trove::db::postgresql(
28
+  $password,
29
+  $dbname     = 'trove',
30
+  $user       = 'trove',
31
+  $encoding   = undef,
32
+  $privileges = 'ALL',
33
+) {
34
+
35
+  Class['trove::db::postgresql'] -> Service<| title == 'trove' |>
36
+
37
+  ::openstacklib::db::postgresql { 'trove':
38
+    password_hash => postgresql_password($user, $password),
39
+    dbname        => $dbname,
40
+    user          => $user,
41
+    encoding      => $encoding,
42
+    privileges    => $privileges,
43
+  }
44
+
45
+  ::Openstacklib::Db::Postgresql['trove']    ~> Exec<| title == 'trove-manage db_sync' |>
46
+
47
+}

+ 28
- 0
deployment_scripts/puppet/modules/trove/manifests/db/sync.pp View File

@@ -0,0 +1,28 @@
1
+#
2
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3
+#
4
+# Author: Emilien Macchi <emilien.macchi@enovance.com>
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#      http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+#
18
+# Class to execute "trove-manage db_sync
19
+#
20
+class trove::db::sync {
21
+  exec { 'trove-manage db_sync':
22
+    path        => '/usr/bin',
23
+    user        => 'trove',
24
+    refreshonly => true,
25
+    subscribe   => Trove_config['database/connection'],
26
+    require     => Package['trove-api'],
27
+  }
28
+}

+ 91
- 0
deployment_scripts/puppet/modules/trove/manifests/generic_service.pp View File

@@ -0,0 +1,91 @@
1
+#
2
+# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3
+#
4
+# Author: Emilien Macchi <emilien.macchi@enovance.com>
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#      http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+#
18
+# == Define: trove::generic_service
19
+#
20
+# This defined type implements basic trove services.
21
+# It is introduced to attempt to consolidate
22
+# common code.
23
+#
24
+# It also allows users to specify ad-hoc services
25
+# as needed
26
+#
27
+# This define creates a service resource with title trove-${name} and
28
+# conditionally creates a package resource with title trove-${name}
29
+#
30
+# === Parameters:
31
+#
32
+# [*package_name*]
33
+#   (mandatory) The package name (for the generic_service)
34
+#
35
+# [*service_name*]
36
+#   (mandatory) The service name (for the generic_service)
37
+#
38
+# [*enabled*]
39
+#   (optional) Define if the service must be enabled or not
40
+#   Defaults to false.
41
+#
42
+# [*manage_service*]
43
+#   (optional) Manage or not the service (if a service_name is provided).
44
+#   Defaults to true.
45
+#
46
+# [*ensure_package*]
47
+#   (optional) Control the ensure parameter for the package ressource.
48
+#   Defaults to 'present'.
49
+#
50
+define trove::generic_service(
51
+  $package_name,
52
+  $service_name,
53
+  $enabled        = false,
54
+  $manage_service = true,
55
+  $ensure_package = 'present'
56
+) {
57
+
58
+  include ::trove::params
59
+  include ::trove::db::sync
60
+
61
+  $trove_title = "trove-${name}"
62
+  Exec['post-trove_config'] ~> Service<| title == $trove_title |>
63
+  Exec<| title == 'trove-db-sync' |> ~> Service<| title == $trove_title |>
64
+
65
+  if ($package_name) {
66
+    if !defined(Package[$package_name]) {
67
+      package { $trove_title:
68
+        ensure => $ensure_package,
69
+        name   => $package_name,
70
+        notify => Service[$trove_title],
71
+      }
72
+    }
73
+  }
74
+
75
+  if $service_name {
76
+    if $manage_service {
77
+      if $enabled {
78
+        $service_ensure = 'running'
79
+      } else {
80
+        $service_ensure = 'stopped'
81
+      }
82
+    }
83
+
84
+    service { $trove_title:
85
+      ensure    => $service_ensure,
86
+      name      => $service_name,
87
+      enable    => $enabled,
88
+      hasstatus => true,
89
+    }
90
+  }