[stor4nfv] Add os-stor4nfv role for OpenStack deploy 99/60499/12
authorramamani yeleswarapu <ramamani.yeleswarapu@intel.com>
Thu, 2 Aug 2018 01:23:01 +0000 (18:23 -0700)
committerramamani yeleswarapu <ramamani.yeleswarapu@intel.com>
Wed, 22 Aug 2018 17:06:46 +0000 (10:06 -0700)
Adds os-stor4nfv role for OpenStack deploy which installs
OpenSDS and Cindercompatibleapi.

Disables Cinder service and configures cindercompatibleapi
to work with 'lvm' backend.

Adds os-nosdn-stor4nfv-ha scenario file.
Adds os-nosdn-stor4nfv-noha scenario file.

Change-Id: Ie4b6a874beb3f61aa2fd08ebc6c97ab737c012ee
Signed-off-by: ramamani yeleswarapu <ramamani.yeleswarapu@intel.com>
deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml
deploy/conf/vm_environment/os-nosdn-stor4nfv-ha.yml [new file with mode: 0644]
deploy/conf/vm_environment/os-nosdn-stor4nfv-noha.yml [new file with mode: 0644]
plugins/stor4nfv/plugin.desc
plugins/stor4nfv/roles/os-stor4nfv/files/install_ansible.sh [new file with mode: 0644]
plugins/stor4nfv/roles/os-stor4nfv/files/os_configure_vars.sh [new file with mode: 0644]
plugins/stor4nfv/roles/os-stor4nfv/tasks/main.yml [new file with mode: 0644]
plugins/stor4nfv/roles/os-stor4nfv/tasks/opensds.yml [new file with mode: 0644]
plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml [new file with mode: 0644]

index c14f958..1d4ec9e 100644 (file)
   remote_user: root
   roles:
     - moon
+
+- hosts:
+    - ceph_adm
+  remote_user: root
+  roles:
+    - os-stor4nfv
diff --git a/deploy/conf/vm_environment/os-nosdn-stor4nfv-ha.yml b/deploy/conf/vm_environment/os-nosdn-stor4nfv-ha.yml
new file mode 100644 (file)
index 0000000..1ef4bdd
--- /dev/null
@@ -0,0 +1,45 @@
+##############################################################################
+# 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
+##############################################################################
+
+---
+TYPE: virtual
+FLAVOR: cluster
+
+plugins:
+  - stor4nfv: "Enable"
+
+hosts:
+  - name: host1
+    roles:
+      - controller
+      - ha
+      - ceph-adm
+      - ceph-mon
+
+  - name: host2
+    roles:
+      - controller
+      - ha
+      - ceph-mon
+
+  - name: host3
+    roles:
+      - controller
+      - ha
+      - ceph-mon
+
+  - name: host4
+    roles:
+      - compute
+      - ceph-osd
+
+  - name: host5
+    roles:
+      - compute
+      - ceph-osd
diff --git a/deploy/conf/vm_environment/os-nosdn-stor4nfv-noha.yml b/deploy/conf/vm_environment/os-nosdn-stor4nfv-noha.yml
new file mode 100644 (file)
index 0000000..e03a4d4
--- /dev/null
@@ -0,0 +1,28 @@
+##############################################################################
+# 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
+##############################################################################
+
+---
+TYPE: virtual
+FLAVOR: cluster
+
+plugins:
+  - stor4nfv: "Enable"
+
+hosts:
+  - name: host1
+    roles:
+      - controller
+      - ha
+      - ceph-adm
+      - ceph-mon
+
+  - name: host2
+    roles:
+      - compute
+      - ceph-osd
index ae589a6..e0a1e69 100644 (file)
@@ -43,3 +43,7 @@ plugin:
         phrase: post_k8s
         inventory:
           - localhost
+      - role: os-stor4nfv
+        phrase: post_openstack
+        inventory:
+          - localhost
diff --git a/plugins/stor4nfv/roles/os-stor4nfv/files/install_ansible.sh b/plugins/stor4nfv/roles/os-stor4nfv/files/install_ansible.sh
new file mode 100644 (file)
index 0000000..d921d4e
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+# #############################################################################
+# 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
+# #############################################################################
+
+add-apt-repository ppa:ansible/ansible-2.4
+
+apt-get update
+apt-get install -y ansible
+sleep 5
+
+ansible --version
+
diff --git a/plugins/stor4nfv/roles/os-stor4nfv/files/os_configure_vars.sh b/plugins/stor4nfv/roles/os-stor4nfv/files/os_configure_vars.sh
new file mode 100644 (file)
index 0000000..7d49759
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+# #############################################################################
+# 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
+# #############################################################################
+
+cd $HOME/gopath/src/github.com/os-stor4nfv/stor4nfv/ci/ansible
+
+sed -i '/- osdsdock/s/^/#/g' site.yml
+
+sed -i '/- dashboard-installer/s/^/#/g' site.yml
+
+sed -i '/- nbp-installer/s/^/#/g' site.yml
+
+sed -i  '/check_ansible_version/a \  ignore_errors: yes\' roles/common/tasks/main.yml
+
+# auth
+sed -i 's/^opensds_auth_strategy.*/opensds_auth_strategy: noauth/g' group_vars/auth.yml
+
+# opensds_endpoint
+sed -i 's/^opensds_endpoint.*/opensds_endpoint: http:\/\/'"$1"':50040/g' group_vars/common.yml
diff --git a/plugins/stor4nfv/roles/os-stor4nfv/tasks/main.yml b/plugins/stor4nfv/roles/os-stor4nfv/tasks/main.yml
new file mode 100644 (file)
index 0000000..060c9cf
--- /dev/null
@@ -0,0 +1,14 @@
+# #############################################################################
+# 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
+# #############################################################################
+---
+- include: opensds.yml
+- include: post-install.yml
+  when:
+    - ansible_distribution == 'Ubuntu'
+    - stor4nfv is defined and stor4nfv == "Enable"
diff --git a/plugins/stor4nfv/roles/os-stor4nfv/tasks/opensds.yml b/plugins/stor4nfv/roles/os-stor4nfv/tasks/opensds.yml
new file mode 100644 (file)
index 0000000..2d0f05c
--- /dev/null
@@ -0,0 +1,72 @@
+# #############################################################################
+# 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: install prerequisites package
+  apt:
+    name: "{{ item }}"
+    state: present
+  with_items:
+    - git
+    - gawk
+    - curl
+    - wget
+    - software-properties-common
+
+- name: copy install_ansible script
+  remote_user: root
+  copy:
+    src: install_ansible.sh
+    dest: /opt/install_ansible.sh
+    mode: 0777
+
+- name: install ansible
+  command: su -s /bin/sh -c "/opt/install_ansible.sh"
+  ignore_errors: "true"
+
+- name: disable cinder
+  remote_user: root
+  shell: |
+    lxc-stop -n $(lxc-ls --line | grep cinder_api)
+    lxc-stop -n $(lxc-ls --line | grep cinder_scheduler)
+  ignore_errors: "true"
+
+- name: modify haproxy.cfg and restart haproxy
+  remote_user: root
+  shell: |
+    sed -i \
+        '/frontend cinder_api-front/,/host1_cinder_api_container/ s/^/#/' /etc/haproxy/haproxy.cfg
+    systemctl restart haproxy
+  ignore_errors: "true"
+
+- name: fetch stor4nfv source code
+  remote_user: root
+  shell: |
+    mkdir -p $HOME/gopath/src/github.com/os-stor4nfv && cd $HOME/gopath/src/github.com/os-stor4nfv;
+    rm -rf stor4nfv;
+    git clone https://gerrit.opnfv.org/gerrit/stor4nfv.git
+
+- name: copy os_configure_vars script
+  remote_user: root
+  copy:
+    src: os_configure_vars.sh
+    dest: /opt/os_configure_vars.sh
+    mode: 0777
+
+- name: configure variables for opensds
+  remote_user: root
+  shell: |
+    cd /opt;
+    ./os_configure_vars.sh {{ public_vip.ip }}
+
+- name: run playbook
+  remote_user: root
+  shell: |
+    cd $HOME/gopath/src/github.com/os-stor4nfv/stor4nfv/ci/ansible;
+    ansible-playbook site.yml -i local.hosts | tee /var/log/os-stor4nfv.log
diff --git a/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml b/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml
new file mode 100644 (file)
index 0000000..c549566
--- /dev/null
@@ -0,0 +1,78 @@
+# #############################################################################
+# 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
+  ignore_errors: "true"
+  register: opensds_exists
+
+- 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:
+    - opensds_exists.stat.exists
+
+- 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:
+    - opensds_exists.stat.exists
+
+- name: ensure osdsdock exists
+  stat:
+    path: /opt/opensds-hotpot-linux-amd64/bin/osdsdock
+  ignore_errors: "true"
+  register: osdsdock_exists
+
+- name: start osdsdock daemon
+  remote_user: root
+  shell: |
+    /opt/opensds-hotpot-linux-amd64/bin/osdsdock -daemon
+  ignore_errors: "true"
+  when:
+    - osdsdock_exists.stat.exists
+
+- name: ensure osdsctl exists
+  stat:
+    path: /opt/opensds-hotpot-linux-amd64/bin/osdsctl
+  ignore_errors: "true"
+  register: osdsctl_exists
+
+- 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"}'
+  ignore_errors: "true"
+  when:
+    - osdsctl_exists.stat.exists