-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: Ib69556ae8532c6f52457eb3bd37be0d23ebeb3fd
- Loading branch information
Showing
12 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,7 @@ nfs: | |
protocols: "3,4" | ||
access_type: RW | ||
user: cephnfs | ||
|
||
mds: | ||
multi: true | ||
max: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
backend/common/decapod_common/playbooks/plays/deploy_mds.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
# Copyright (c) 2017 Mirantis Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
- include: "{{ decapod_common_playbooks }}/plays/add_ceph_ansible_role.yaml" | ||
|
||
- hosts: mons | ||
become: true | ||
tasks: | ||
- block: | ||
- name: get default pg_num | ||
command: > | ||
ceph --cluster {{ cluster | quote }} daemon | ||
mon.{{ ansible_hostname }} config get osd_pool_default_pg_num | ||
register: default_pg_num | ||
|
||
- name: create filesystem pools | ||
command: > | ||
ceph --cluster {{ cluster | quote }} osd pool create | ||
{{ item | quote }} | ||
{{ (default_pg_num.stdout | from_json).osd_pool_default_pg_num }} | ||
with_items: | ||
- cephfs_data | ||
- cephfs_metadata | ||
changed_when: false | ||
|
||
- name: check if ceph filesystem already exists | ||
command: ceph --cluster {{ cluster | quote }} fs get cephfs | ||
register: check_existing_cephfs | ||
changed_when: false | ||
failed_when: false | ||
|
||
- name: create ceph filesystem | ||
command: > | ||
ceph --cluster {{ cluster | quote }} fs new | ||
cephfs cephfs_metadata cephfs_data | ||
changed_when: false | ||
when: check_existing_cephfs.rc != 0 | ||
|
||
- name: allow multimds | ||
command: > | ||
ceph --cluster {{ cluster | quote }} fs set cephfs | ||
allow_multimds true --yes-i-really-mean-it | ||
changed_when: false | ||
when: mds_allow_multimds | ||
|
||
- name: set max mds | ||
command: > | ||
ceph --cluster {{ cluster | quote }} fs set cephfs max_mds | ||
{{ mds_max_mds }} | ||
changed_when: false | ||
when: | ||
- mds_allow_multimds | ||
- mds_max_mds | ||
when: | ||
- "{{ (groups.mdss | length) > 0 }}" | ||
- "{{ inventory_hostname == (groups.mons | last) }}" | ||
|
||
- hosts: mdss | ||
become: true | ||
roles: | ||
- ceph-client | ||
- ceph-mds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include decapod_plugin_playbook_add_mds/config.yaml | ||
include decapod_plugin_playbook_add_mds/playbook.yaml |
Empty file.
15 changes: 15 additions & 0 deletions
15
plugins/playbook/add_mds/decapod_plugin_playbook_add_mds/config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
# Copyright (c) 2016 Mirantis Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
18 changes: 18 additions & 0 deletions
18
plugins/playbook/add_mds/decapod_plugin_playbook_add_mds/playbook.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
# Copyright (c) 2016 Mirantis Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
- include: "{{ decapod_common_playbooks }}/plays/deploy_mds.yaml" |
114 changes: 114 additions & 0 deletions
114
plugins/playbook/add_mds/decapod_plugin_playbook_add_mds/plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2016 Mirantis Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Playbook plugin for Add metadata server host.""" | ||
|
||
|
||
from decapod_common import log | ||
from decapod_common import playbook_plugin | ||
from decapod_common import playbook_plugin_hints | ||
from decapod_common.models import cluster_data | ||
from decapod_common.models import server | ||
|
||
|
||
DESCRIPTION = "Add metadata server host" | ||
"""Plugin description.""" | ||
|
||
HINTS_SCHEMA = { | ||
"ceph_version_verify": { | ||
"description": "Verify Ceph version consistency on install", | ||
"typename": "boolean", | ||
"type": "boolean", | ||
"default_value": True | ||
} | ||
} | ||
"""Schema for playbook hints.""" | ||
|
||
LOG = log.getLogger(__name__) | ||
"""Logger.""" | ||
|
||
|
||
class AddMds(playbook_plugin.CephAnsiblePlaybook): | ||
|
||
NAME = "Add metadata server host" | ||
DESCRIPTION = DESCRIPTION | ||
PUBLIC = True | ||
REQUIRED_SERVER_LIST = True | ||
SERVER_LIST_POLICY = playbook_plugin.ServerListPolicy.not_in_other_cluster | ||
|
||
HINTS = playbook_plugin_hints.Hints(HINTS_SCHEMA) | ||
|
||
def on_pre_execute(self, task): | ||
super().on_pre_execute(task) | ||
|
||
playbook_config = self.get_playbook_configuration(task) | ||
config = playbook_config.configuration["inventory"] | ||
cluster = playbook_config.cluster | ||
servers = playbook_config.servers | ||
servers = {srv.ip: srv for srv in servers} | ||
|
||
for name, group_vars in config.items(): | ||
if name != "mdss" or not group_vars: | ||
continue | ||
group_servers = [servers[ip] for ip in group_vars] | ||
cluster.add_servers(group_servers, name) | ||
|
||
if cluster.configuration.changed: | ||
cluster.save() | ||
|
||
def make_playbook_configuration(self, cluster, servers, hints): | ||
data = cluster_data.ClusterData.find_one(cluster.model_id) | ||
global_vars = self.make_global_vars(cluster, data, servers, hints) | ||
inventory = self.make_inventory(cluster, data, servers, hints) | ||
|
||
return global_vars, inventory | ||
|
||
def make_global_vars(self, cluster, data, servers, hints): | ||
result = super().make_global_vars(cluster, servers, hints) | ||
result.update(data.global_vars) | ||
|
||
result["ceph_version_verify"] = bool(hints["ceph_version_verify"]) | ||
|
||
return result | ||
|
||
def make_inventory(self, cluster, data, servers, hints): | ||
groups = self.get_inventory_groups(cluster, servers, hints) | ||
inventory = {"_meta": {"hostvars": {}}} | ||
|
||
for name, group_servers in groups.items(): | ||
for srv in group_servers: | ||
inventory.setdefault(name, []).append(srv.ip) | ||
|
||
hostvars = inventory["_meta"]["hostvars"].setdefault( | ||
srv.ip, {}) | ||
hostvars.update(data.get_host_vars(srv.ip)) | ||
hostvars["ansible_user"] = srv.username | ||
|
||
return inventory | ||
|
||
def get_inventory_groups(self, cluster, servers, hints): | ||
cluster_servers = server.ServerModel.cluster_servers(cluster.model_id) | ||
cluster_servers = {item._id: item for item in cluster_servers} | ||
|
||
mons = [ | ||
cluster_servers[item["server_id"]] | ||
for item in cluster.configuration.state if item["role"] == "mons" | ||
] | ||
|
||
return { | ||
"mons": mons, | ||
"mdss": servers, | ||
"already_deployed": list(cluster_servers.values()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[bdist_wheel] | ||
python-tag = py3 | ||
|
||
[flake8] | ||
exclude = build,dist,docs/conf.py,*.egg-info,.eggs,.cache,.tox | ||
inline-quotes = " | ||
application-import-names = decapod_api,decapod_common,decapod_controller,decapodlib | ||
import-order-style = smarkets | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2016 Mirantis Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
# implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Setup script for decapod_plugin_playbook_add_mds plugin.""" | ||
|
||
|
||
import setuptools | ||
|
||
|
||
setuptools.setup( | ||
name="decapod-plugin-playbook-add-mds", | ||
description="Add metadata server host", | ||
version="1.1.0.dev1", | ||
author="Sergey Arkhipov", | ||
author_email="sarkhipov@mirantis.com", | ||
url="https://github.com/Mirantis/ceph-lcm", | ||
packages=setuptools.find_packages(), | ||
entry_points={ | ||
"decapod.playbooks": [ | ||
"add_mds = decapod_plugin_playbook_add_mds.plugin:AddMds" | ||
] | ||
}, | ||
python_requires=">= 3.4", | ||
include_package_data=True, | ||
package_data={ | ||
"decapod_plugin_playbook_add_mds": [ | ||
"config.yaml", | ||
"playbook.yaml" | ||
] | ||
}, | ||
install_requires=[ | ||
"decapod-common~=1.1.dev1" | ||
], | ||
zip_safe=False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[DEFAULT] | ||
X-Python3-Version: >= 3.4 | ||
Depends3: python3-decapod-common (>= 1.1), python3-decapod-common (<< 1.2) |