Browse Source

Merge "Use memcached for token caching in heat authtoken"

tags/11.2.0
Zuul 1 week ago
parent
commit
aa4417017d

+ 3
- 1
manifests/profile/base/heat.pp View File

@@ -96,6 +96,9 @@ class tripleo::profile::base::heat (
96 96
   $oslomsg_notify_username = hiera('oslo_messaging_notify_user_name', 'guest'),
97 97
   $oslomsg_notify_use_ssl  = hiera('oslo_messaging_notify_use_ssl', '0'),
98 98
 ) {
99
+
100
+  include ::tripleo::profile::base::heat::authtoken
101
+
99 102
   # Domain resources will be created at step5 on the node running keystone.pp
100 103
   # configure heat.conf at step3 and 4 but actually create the domain later.
101 104
   if $step >= 3 {
@@ -136,4 +139,3 @@ class tripleo::profile::base::heat (
136 139
     }
137 140
   }
138 141
 }
139
-

+ 44
- 0
manifests/profile/base/heat/authtoken.pp View File

@@ -0,0 +1,44 @@
1
+# Copyright 2019 Red Hat, Inc.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+#      http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+#
15
+# == Class: tripleo::profile::base::heat::authtoken
16
+#
17
+# Heat authtoken profile for TripleO
18
+#
19
+# [*step*]
20
+#   (Optional) The current step in deployment. See tripleo-heat-templates
21
+#   for more details.
22
+#   Defaults to hiera('step')
23
+#
24
+# [*memcached_ips*]
25
+#   (Optional) Array of ipv4 or ipv6 addresses for memcache.
26
+#   Defaults to hiera('memcached_node_ips')
27
+#
28
+class tripleo::profile::base::heat::authtoken (
29
+  $step                = Integer(hiera('step')),
30
+  $memcached_ips       = hiera('memcached_node_ips'),
31
+) {
32
+
33
+  if $step >= 3 {
34
+    if is_ipv6_address($memcached_ips[0]) {
35
+      $memcache_servers = prefix(suffix(any2array(normalize_ip_for_uri($memcached_ips)), ':11211'), 'inet6:')
36
+    } else {
37
+      $memcache_servers = suffix(any2array(normalize_ip_for_uri($memcached_ips)), ':11211')
38
+    }
39
+
40
+    class { '::heat::keystone::authtoken':
41
+      memcached_servers => $memcache_servers
42
+    }
43
+  }
44
+}

+ 70
- 0
spec/classes/tripleo_profile_base_heat_authtoken_spec.rb View File

@@ -0,0 +1,70 @@
1
+#
2
+# Copyright (C) 2019 Red Hat, Inc.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+# not use this file except in compliance with the License. You may obtain
6
+# a copy of the License at
7
+#
8
+#      http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+# License for the specific language governing permissions and limitations
14
+# under the License.
15
+#
16
+
17
+require 'spec_helper'
18
+
19
+describe 'tripleo::profile::base::heat::authtoken' do
20
+  shared_examples_for 'tripleo::profile::base::heat::authtoken' do
21
+    context 'with step less than 3' do
22
+      let(:params) { {
23
+        :step => 1,
24
+      } }
25
+
26
+      it {
27
+        is_expected.to contain_class('tripleo::profile::base::heat::authtoken')
28
+        is_expected.to_not contain_class('heat::keystone::authtoken')
29
+      }
30
+    end
31
+
32
+    context 'with step 3' do
33
+      let(:params) { {
34
+        :step => 3,
35
+        :memcached_ips => '127.0.0.1',
36
+      } }
37
+
38
+      it {
39
+        is_expected.to contain_class('tripleo::profile::base::heat::authtoken')
40
+        is_expected.to contain_class('heat::keystone::authtoken').with(
41
+            :memcached_servers => ['127.0.0.1:11211'])
42
+      }
43
+    end
44
+
45
+    context 'with step 3 with ipv6' do
46
+      let(:params) { {
47
+        :step     => 3,
48
+        :memcached_ips => '::1',
49
+      } }
50
+
51
+      it {
52
+        is_expected.to contain_class('tripleo::profile::base::heat::authtoken')
53
+        is_expected.to contain_class('heat::keystone::authtoken').with(
54
+            :memcached_servers => ['[::1]:11211'])
55
+      }
56
+    end
57
+
58
+  end
59
+
60
+
61
+  on_supported_os.each do |os, facts|
62
+    context "on #{os}" do
63
+      let(:facts) do
64
+        facts.merge({ :hostname => 'node.example.com' })
65
+      end
66
+
67
+      it_behaves_like 'tripleo::profile::base::heat::authtoken'
68
+    end
69
+  end
70
+end

+ 3
- 1
spec/fixtures/hieradata/default.yaml View File

@@ -47,7 +47,9 @@ gnocchi::storage::ceph::ceph_secret: 'password'
47 47
 # haproxy related items
48 48
 mysql_enabled: true
49 49
 controller_node_ips: '10.1.0.1,10.1.0.2'
50
-# mysql related
50
+# heat related items
51
+heat::keystone::authtoken::password: 'password'
52
+# mysql related items
51 53
 mysql_short_bootstrap_node_name: node
52 54
 # manila related items
53 55
 manila::rabbit_password: 'password'

Loading…
Cancel
Save