summaryrefslogtreecommitdiffstats
path: root/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml
blob: c0044322ff54d5bbd8b7f9efc8808ce43d761126 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# #############################################################################
# Copyright (c) 2018 Intel Corp.
#
# 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: ensure opensds.conf exists
  stat:
    path: /etc/opensds/opensds.conf
  register: opensds_exists
  when:
    - inventory_hostname in groups['ceph_adm']

- name: configure ceph.yaml, opensds.conf
  remote_user: root
  shell: |
    cd /root/gopath/src/github.com/os-stor4nfv/stor4nfv/ci/ansible
    cp group_vars/ceph/ceph.yaml /etc/opensds/driver/
    sed -i 's/^ enabled_backends.*/ enabled_backends: ceph/g' /etc/opensds/opensds.conf
    sudo cat >> /etc/opensds/opensds.conf << OPENSDS_GLOABL_CONFIG_DOC

    [ceph]
     name = ceph
     description = Ceph Test
     driver_name = ceph
     config_path = /etc/opensds/driver/ceph.yaml
    OPENSDS_GLOABL_CONFIG_DOC
  when:
    - inventory_hostname in groups['ceph_adm']

- name: modify osdsdock endpoint
  remote_user: root
  shell:
    _raw_params: |
      function _modify_osdsdock_endpoint {
          local ip_addr=$((lxc-info -n $(lxc-ls --line | grep ceph-mon) -iH)|grep "10.1")
          if [ ! -z "${ip_addr}" ]; then
              sed -i 's/api_endpoint = localhost:50050/api_endpoint = '"$ip_addr"':50050/g' \
                  /etc/opensds/opensds.conf
          fi
      }
      _modify_osdsdock_endpoint
  args:
    executable: /bin/bash
  become: true
  when:
    - inventory_hostname in groups['ceph_adm']

- name: copy ceph.conf from ceph-mon container
  remote_user: root
  shell: |
    mkdir -p /etc/ceph;
    cp /proc/$(lxc-info -n $(lxc-ls --line | grep ceph-mon) -p -H)/root/etc/ceph/ceph.conf \
       /etc/ceph/ceph.conf
  when:
    - inventory_hostname in groups['ceph_adm']

- name: copy osdsdock executable to ceph-mon container
  remote_user: root
  shell: |
    cd /opt;
    tar -C opensds-hotpot-linux-amd64 -c . | lxc-attach -n \
    $(lxc-ls --line | grep ceph-mon) -- /bin/sh -c "tar -C /opt/ -vx; chmod 1777 /opt;"
  when:
    - inventory_hostname in groups['ceph_adm']

- name: copy opensds conf files to ceph-mon container
  remote_user: root
  shell: |
    cd /etc;
    tar -C opensds -c . | lxc-attach -n \
    $(lxc-ls --line | grep ceph-mon) -- /bin/sh -c "tar -C /tmp/ -vx; chmod 1777 /tmp;"
  when:
    - inventory_hostname in groups['ceph_adm']

- name: ensure opensds driver exists
  stat:
    path: /tmp/driver
  register: opensds_driver_exists
  when:
    - inventory_hostname in groups['ceph-mon']
    - groups['ceph_adm'][0] in inventory_hostname

- name: copy opensds conf
  remote_user: root
  shell: |
    mkdir -p /etc/opensds;
    cp /tmp/opensds.conf /etc/opensds;
    cp /tmp/policy.json /etc/opensds;
    cp -r /tmp/driver /etc/opensds;
  when:
    - inventory_hostname in groups['ceph-mon']
    - groups['ceph_adm'][0] in inventory_hostname

- name: create ceph pool
  remote_user: root
  shell: |
    ceph osd pool create rbd 24 && ceph osd pool set rbd size 1
  when:
    - inventory_hostname in groups['ceph-mon']
    - groups['ceph_adm'][0] in inventory_hostname

- name: ensure osdsdock exists
  stat:
    path: /opt/bin/osdsdock
  register: opensds_exists
  when:
    - inventory_hostname in groups['ceph-mon']
    - groups['ceph_adm'][0] in inventory_hostname

- name: start osdsdock daemon
  remote_user: root
  shell: |
    cd /opt && ./bin/osdsdock -daemon
  when:
    - inventory_hostname in groups['ceph-mon']
    - groups['ceph_adm'][0] in inventory_hostname

- name: ensure osdsctl exists
  stat:
    path: /opt/opensds-hotpot-linux-amd64/bin/osdsctl
  register: osdsctl_exists
  when:
    - inventory_hostname in groups['ceph_adm']

- name: run cinder-compatible-api, create opensds default profile
  remote_user: root
  shell: |
    cd $HOME/gopath/src/github.com/os-stor4nfv/stor4nfv/ci/ansible;
    export OPENSDS_ENDPOINT=http://{{ public_vip.ip }}:50040;
    export CINDER_ENDPOINT=http://{{ internal_vip.ip }}:8776/v3;
    chmod +x ../bin/cindercompatibleapi;
    ( ( nohup ../bin/cindercompatibleapi > /var/log/cindercompatibleapi.log 2>&1 ) & );
    cp /opt/opensds-hotpot-linux-amd64/bin/osdsctl /usr/local/bin;
    export OPENSDS_AUTH_STRATEGY=noauth;
    osdsctl profile create '{"name": "default", "description": "default policy"}'
  when:
    - inventory_hostname in groups['ceph_adm']