Update opensds ansible
[stor4nfv.git] / ci / ansible / README.md
1 # opensds-ansible
2 This is an installation tool for opensds using ansible.
3
4 ## 1. How to install an opensds local cluster
5 This installation document assumes there is a clean Ubuntu 16.04 environment. If golang is already installed in the environment, make sure the following parameters are configured in ```/etc/profile``` and run ``source /etc/profile``:
6 ```conf
7 export GOROOT=/usr/local/go
8 export GOPATH=$HOME/gopath
9 export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
10 ```
11
12 ### Pre-config (Ubuntu 16.04)
13 First download some system packages:
14 ```
15 sudo apt-get install -y openssh-server git make gcc
16 ```
17 Then config ```/etc/ssh/sshd_config``` file and change one line:
18 ```conf
19 PermitRootLogin yes
20 ```
21 Next generate ssh-token:
22 ```bash
23 ssh-keygen -t rsa
24 ssh-copy-id -i ~/.ssh/id_rsa.pub <ip_address> # IP address of the target machine of the installation
25 ```
26
27 ### Install docker
28 If use a standalone cinder as backend, you also need to install docker to run cinder service. Please see the [docker installation document](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/) for details.
29
30 ### Install ansible tool
31 ```bash
32 sudo add-apt-repository ppa:ansible/ansible # This step is needed to upgrade ansible to version 2.4.2 which is required for the ceph backend.
33 sudo apt-get update
34 sudo apt-get install ansible
35 ansible --version # Ansible version 2.4.2 or higher is required for ceph; 2.0.0.2 or higher is needed for other backends.
36 ```
37
38 ### Download opensds source code
39 ```bash
40 mkdir -p $HOME/gopath/src/github.com/opensds && cd $HOME/gopath/src/github.com/opensds
41 git clone https://github.com/opensds/opensds.git -b <specified_branch_name>
42 cd opensds/contrib/ansible
43 ```
44
45 ### Configure opensds cluster variables:
46 ##### System environment:
47 Configure the ```workplace``` in `group_vars/common.yml`:
48 ```yaml
49 workplace: /home/your_username # Change this field according to your username. If login as root, configure this parameter to '/root'
50 ```
51
52 ##### LVM
53 If `lvm` is chosen as storage backend, modify `group_vars/osdsdock.yml`:
54 ```yaml
55 enabled_backend: lvm # Change it according to the chosen backend. Supported backends include 'lvm', 'ceph', and 'cinder'
56 pv_device: "your_pv_device_path" # Specify a block device and ensure it exists if lvm is chosen
57 vg_name: "specified_vg_name" # Specify a name for VG if choosing lvm
58 ```
59 Modify ```group_vars/lvm/lvm.yaml```, change pool name to be the same as `vg_name` above:
60 ```yaml
61 "vg001" # change pool name to be the same as vg_name
62 ```
63 ##### Ceph
64 If `ceph` is chosen as storage backend, modify `group_vars/osdsdock.yml`:
65 ```yaml
66 enabled_backend: ceph # Change it according to the chosen backend. Supported backends include 'lvm', 'ceph', and 'cinder'.
67 ceph_pool_name: "specified_pool_name" # Specify a name for ceph pool if choosing ceph
68 ```
69 Modify ```group_vars/ceph/ceph.yaml```, change pool name to be the same as `ceph_pool_name`:
70 ```yaml
71 "rbd" # change pool name to be the same as ceph pool
72 ```
73 Configure two files under ```group_vars/ceph```: `all.yml` and `osds.yml`. Here is an example:
74
75 ```group_vars/ceph/all.yml```:
76 ```yml
77 ceph_origin: repository
78 ceph_repository: community
79 ceph_stable_release: luminous # Choose luminous as default version
80 public_network: "192.168.3.0/24" # Run 'ip -4 address' to check the ip address
81 cluster_network: "{{ public_network }}"
82 monitor_interface: eth1 # Change to the network interface on the target machine
83 ```
84 ```group_vars/ceph/osds.yml```:
85 ```yml
86 devices: # For ceph devices, append one or multiple devices like the example below:
87     - '/dev/sda' # Ensure this device exists and available if ceph is chosen
88     - '/dev/sdb' # Ensure this device exists and available if ceph is chosen
89 osd_scenario: collocated
90 ```
91
92 ##### Cinder
93 If `cinder` is chosen as storage backend, modify `group_vars/osdsdock.yml`:
94 ```yaml
95 enabled_backend: cinder # Change it according to the chosen backend. Supported backends include 'lvm', 'ceph', and 'cinder'
96
97 # Use block-box install cinder_standalone if true, see details in:
98 use_cinder_standalone: true
99 # If true, you can configure cinder_container_platform,  cinder_image_tag,
100 # cinder_volume_group.
101
102 # Default: debian:stretch, and ubuntu:xenial, centos:7 is also supported.
103 cinder_container_platform: debian:stretch
104 # The image tag can be arbitrarily modified, as long as follow the image naming
105 # conventions, default: debian-cinder
106 cinder_image_tag: debian-cinder
107 # The cinder standalone use lvm driver as default driver, therefore `volume_group`
108 # should be configured, the default is: cinder-volumes. The volume group will be
109 # removed when use ansible script clean environment.
110 cinder_volume_group: cinder-volumes
111 ```
112
113 Configure the auth and pool options to access cinder in `group_vars/cinder/cinder.yaml`. Do not need to make additional configure changes if using cinder standalone.
114
115 ### Check if the hosts can be reached
116 ```bash
117 sudo ansible all -m ping -i local.hosts
118 ```
119
120 ### Run opensds-ansible playbook to start deploy
121 ```bash
122 sudo ansible-playbook site.yml -i local.hosts
123 ```
124
125 ## 2. How to test opensds cluster
126
127 ### Configure opensds CLI tool
128 ```bash
129 sudo cp $GOPATH/src/github.com/opensds/opensds/build/out/bin/osdsctl /usr/local/bin
130 export OPENSDS_ENDPOINT=http://127.0.0.1:50040
131 osdsctl pool list # Check if the pool resource is available
132 ```
133
134 ### Create a default profile first.
135 ```
136 osdsctl profile create '{"name": "default", "description": "default policy"}'
137 ```
138
139 ### Create a volume.
140 ```
141 osdsctl volume create 1 --name=test-001
142 ```
143 For cinder, az needs to be specified.
144 ```
145 osdsctl volume create 1 --name=test-001 --az nova
146 ```
147
148 ### List all volumes.
149 ```
150 osdsctl volume list
151 ```
152
153 ### Delete the volume.
154 ```
155 osdsctl volume delete <your_volume_id>
156 ```
157
158
159 ## 3. How to purge and clean opensds cluster
160
161 ### Run opensds-ansible playbook to clean the environment
162 ```bash
163 sudo ansible-playbook clean.yml -i local.hosts
164 ```
165
166 ### Run ceph-ansible playbook to clean ceph cluster if ceph is deployed
167 ```bash
168 cd /opt/ceph-ansible
169 sudo ansible-playbook infrastructure-playbooks/purge-cluster.yml -i ceph.hosts
170 ```
171
172 In addition, clean up the logical partition on the physical block device used by ceph, using the ```fdisk``` tool.
173
174 ### Remove ceph-ansible source code (optional)
175 ```bash
176 cd ..
177 sudo rm -rf /opt/ceph-ansible
178 ```