summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/ceph-config/tasks/create_config.yml
blob: b0be0f2e07508d9ad474a95ab2ab88dec47569b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
##############################################################################
# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
- name: gen ceph fsid
  shell: uuidgen
  register: ceph_fsid
  when: inventory_hostname in groups['ceph_adm']

- name: gen ceph conf
  local_action:
    module: "template"
    src: "ceph.j2"
    dest: "/tmp/ceph.conf"
  when: inventory_hostname in groups['ceph_adm']

- name: fetch ceph conf from ceph_adm
  fetch: src="/etc/ceph/ceph.conf" dest="/tmp/ceph.conf" flat=yes
  delegate_to: "{{ public_vip.ip }}"
  when: compute_expansion

- name: "make directory for ceph config file"
  file: path="/etc/ceph" state="directory"

- name: copy ceph conf to dest mon node
  copy: src="/tmp/ceph.conf" dest="/etc/ceph/ceph.conf"

- name: install ceph-related packages
  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
  with_items:
    - ceph

- name: gen create monmap script
  local_action: template src="create_monmap.j2" dest="/tmp/create_monmap.sh" mode=0755
  when: inventory_hostname in groups['ceph_adm']

- name: create monmap
  script: /tmp/create_monmap.sh
  when: inventory_hostname in groups['ceph_mon']

- name: create mon.keyring
  shell: "ceph-authtool --create-keyring /tmp/ceph.mon.keyring \
             --gen-key -n mon. --cap mon 'allow *'"
  when: inventory_hostname in groups['ceph_adm']

- name: create admin.keyring
  shell: "ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring \
             --gen-key -n client.admin --set-uid=0 \
             --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'"
  when: inventory_hostname in groups['ceph_adm']

- name: Add the client.admin key to the ceph.mon.keyring
  shell: "ceph-authtool /tmp/ceph.mon.keyring \
             --import-keyring /etc/ceph/ceph.client.admin.keyring"
  when: inventory_hostname in groups['ceph_adm']

- name: fetch mon.keyring to local
  fetch: src="/tmp/ceph.mon.keyring" dest="/tmp/ceph.mon.keyring" flat=yes
  when: inventory_hostname in groups['ceph_adm']

- name: fetch mon.keyring from ceph_adm
  fetch: src="/tmp/ceph.mon.keyring" dest="/tmp/ceph.mon.keyring" flat=yes
  delegate_to: "{{ public_vip.ip }}"
  when: compute_expansion

- name: fetch client.admin.keyring to local
  fetch:
    src: "/etc/ceph/ceph.client.admin.keyring"
    dest: "/tmp/ceph.client.admin.keyring"
    flat: "yes"
  when: inventory_hostname in groups['ceph_adm']

- name: fetch mon.keyring from ceph_adm
  fetch:
    src: "/etc/ceph/ceph.client.admin.keyring"
    dest: "/tmp/ceph.client.admin.keyring"
    flat: "yes"
  delegate_to: "{{ public_vip.ip }}"
  when: compute_expansion

- name: copy mon.keyring to remote nodes
  copy: src="/tmp/ceph.mon.keyring" dest="/tmp/ceph.mon.keyring"

- name: copy admin.keyring to remote nodes
  copy:
    src: "/tmp/ceph.client.admin.keyring"
    dest: "/etc/ceph/ceph.client.admin.keyring"

- meta: flush_handlers