Adds a puppet module to configure a Ceph cluster
[genesis.git] / common / puppet-opnfv / manifests / ceph_deploy.pp
1 #Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
2 #
3 #   Licensed under the Apache License, Version 2.0 (the "License");
4 #   you may not use this file except in compliance with the License.
5 #   You may obtain 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,
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #   See the License for the specific language governing permissions and
13 #   limitations under the License.
14 #
15 #Class installs and configures a ceph cluster
16 #Creates a single OSD per host and configures host as a monitor
17 #Inserts authentication keyrings for volumes and images users
18 #Creates OSD pools for volumes and images (needed by OpenStack)
19 #Depends on puppet module: https://github.com/stackforge/puppet-ceph/
20
21 class opnfv::ceph_deploy (
22   $fsid                      = '904c8491-5c16-4dae-9cc3-6ce633a7f4cc',
23   $osd_pool_default_pg_num   = '128',
24   $osd_pool_default_size     = '1',
25   $osd_pool_default_min_size = '1',
26   $mon_initial_members       = '',
27   $mon_host                  = '',
28   $cluster_network           = "10.4.8.0/21",
29   $public_network            = "10.4.8.0/21",
30   $osd_journal_size          = '1000',
31   $osd_ip                    = '',
32   $mon_key                   = 'AQDcvhVV+H08DBAA5/0GGcfBQxz+/eKAdbJdTQ==',
33   $admin_key                 = 'AQDcvhVV+H08DBAA5/0GGcfBQxz+/eKAdbJdTQ==',
34   $images_key                = 'AQAfHBdUKLnUFxAAtO7WPKQZ8QfEoGqH0CLd7A==',
35   $volumes_key               = 'AQAfHBdUsFPTHhAAfqVqPq31FFCvyyO7oaOQXw==',
36   $boostrap_key              = 'AQDcvhVV+H08DBAA5/0GGcfBQxz+/eKAdbJdTQ==',
37 ) {
38
39   class { 'ceph':
40      fsid                      => $fsid,
41      osd_pool_default_pg_num   => $osd_pool_default_pg_num,
42      osd_pool_default_size     => $osd_pool_default_size,
43      osd_pool_default_min_size => $osd_pool_default_min_size,
44      mon_initial_members       => $mon_initial_members,
45      mon_host                  => $mon_host,
46      cluster_network           => $cluster_network,
47      public_network            => $public_network,
48   }
49   ->
50   ceph_config {
51     'global/osd_journal_size': value => $osd_journal_size;
52   }
53   ->
54   ceph::mon { $::hostname:
55      public_addr  => $osd_ip,
56      key          => $mon_key,
57   }
58
59   Ceph::Key {
60         inject         => true,
61         inject_as_id   => 'mon.',
62         inject_keyring => "/var/lib/ceph/mon/ceph-${::hostname}/keyring",
63   }
64
65   ceph::key { 'client.admin':
66         secret  => $admin_key,
67         cap_mon => 'allow *',
68         cap_osd => 'allow *',
69         cap_mds => 'allow',
70         mode    => '0644',
71   }
72   ceph::key { 'client.images':
73         secret  => $images_key,
74         cap_mon => 'allow r',
75         cap_osd => 'allow class-read object_prefix rbd_children, allow rwx pool=images',
76         inject  => true,
77         mode    => '0644',
78   }
79
80   ceph::key { 'client.volumes':
81         secret  => $volumes_key,
82         cap_mon => 'allow r',
83         cap_osd => 'allow class-read object_prefix rbd_children, allow rwx pool=volumes',
84         inject  => true,
85         mode    => '0644',
86   }
87   ceph::key { 'client.bootstrap-osd':
88         secret  => $boostrap_key,
89         cap_mon => 'allow profile bootstrap-osd',
90         keyring_path => '/var/lib/ceph/bootstrap-osd/ceph.keyring',
91   }
92   ->
93   ceph::osd { '/osd0': }
94   ->
95   exec { 'create volumes pool':
96         command => "/usr/bin/ceph osd pool create volumes $osd_pool_default_pg_num",
97   }
98   ->
99   exec { 'create images pool':
100         command => "/usr/bin/ceph osd pool create images $osd_pool_default_pg_num",
101   }
102 }