From c7f0de11b9272fcd2248e259780e744b1ad25532 Mon Sep 17 00:00:00 2001 From: ramamani yeleswarapu Date: Thu, 6 Sep 2018 00:26:34 -0700 Subject: [stor4nfv] Update os-stor4nfv role for OpenStack deploy Installs osdsdock in ceph-mon_container. Configures the endpoints for Ceph, OpenSDS and Cindercompatibleapi. Change-Id: I23143a5f53974bf342208b6a801dad05ccb03bfa Signed-off-by: ramamani yeleswarapu --- .../ansible/openstack/HA-ansible-multinodes.yml | 1 + .../roles/os-stor4nfv/files/os_configure_vars.sh | 3 + .../stor4nfv/roles/os-stor4nfv/tasks/opensds.yml | 2 +- .../roles/os-stor4nfv/tasks/post-install.yml | 88 ++++++++++++++++++---- .../stor4nfv/roles/os-stor4nfv/tasks/stor4nfv.yml | 2 + 5 files changed, 80 insertions(+), 16 deletions(-) diff --git a/deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml b/deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml index 1d4ec9ef..874fcfb5 100644 --- a/deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml +++ b/deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml @@ -123,6 +123,7 @@ - hosts: - ceph_adm + - ceph-mon remote_user: root roles: - os-stor4nfv diff --git a/plugins/stor4nfv/roles/os-stor4nfv/files/os_configure_vars.sh b/plugins/stor4nfv/roles/os-stor4nfv/files/os_configure_vars.sh index 7d497598..a081c0bd 100644 --- a/plugins/stor4nfv/roles/os-stor4nfv/files/os_configure_vars.sh +++ b/plugins/stor4nfv/roles/os-stor4nfv/files/os_configure_vars.sh @@ -23,3 +23,6 @@ sed -i 's/^opensds_auth_strategy.*/opensds_auth_strategy: noauth/g' group_vars/a # opensds_endpoint sed -i 's/^opensds_endpoint.*/opensds_endpoint: http:\/\/'"$1"':50040/g' group_vars/common.yml + +# etcd_host +sed -i 's/^etcd_host.*/etcd_host: '"$2"'/g' group_vars/osdsdb.yml diff --git a/plugins/stor4nfv/roles/os-stor4nfv/tasks/opensds.yml b/plugins/stor4nfv/roles/os-stor4nfv/tasks/opensds.yml index 2d0f05cc..fd9756a4 100644 --- a/plugins/stor4nfv/roles/os-stor4nfv/tasks/opensds.yml +++ b/plugins/stor4nfv/roles/os-stor4nfv/tasks/opensds.yml @@ -63,7 +63,7 @@ remote_user: root shell: | cd /opt; - ./os_configure_vars.sh {{ public_vip.ip }} + ./os_configure_vars.sh {{ public_vip.ip }} {{ internal_vip.ip }} - name: run playbook remote_user: root diff --git a/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml b/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml index c549566a..d14c0c68 100644 --- a/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml +++ b/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml @@ -11,17 +11,16 @@ - name: ensure opensds.conf exists stat: path: /etc/opensds/opensds.conf - ignore_errors: "true" 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] @@ -31,36 +30,96 @@ config_path = /etc/opensds/driver/ceph.yaml OPENSDS_GLOABL_CONFIG_DOC when: - - opensds_exists.stat.exists + - 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/^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 + 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 + - 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'] + +- 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'] + +- 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'] - name: ensure osdsdock exists stat: - path: /opt/opensds-hotpot-linux-amd64/bin/osdsdock - ignore_errors: "true" - register: osdsdock_exists + path: /opt/bin/osdsdock + register: opensds_exists + when: + - inventory_hostname in groups['ceph-mon'] - name: start osdsdock daemon remote_user: root shell: | - /opt/opensds-hotpot-linux-amd64/bin/osdsdock -daemon - ignore_errors: "true" + cd /opt && ./bin/osdsdock -daemon when: - - osdsdock_exists.stat.exists + - inventory_hostname in groups['ceph-mon'] - name: ensure osdsctl exists stat: path: /opt/opensds-hotpot-linux-amd64/bin/osdsctl - ignore_errors: "true" register: osdsctl_exists + when: + - inventory_hostname in groups['ceph_adm'] - name: run cinder-compatible-api, create opensds default profile remote_user: root @@ -73,6 +132,5 @@ 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 + - inventory_hostname in groups['ceph_adm'] diff --git a/plugins/stor4nfv/roles/os-stor4nfv/tasks/stor4nfv.yml b/plugins/stor4nfv/roles/os-stor4nfv/tasks/stor4nfv.yml index 57bae793..05ada67a 100644 --- a/plugins/stor4nfv/roles/os-stor4nfv/tasks/stor4nfv.yml +++ b/plugins/stor4nfv/roles/os-stor4nfv/tasks/stor4nfv.yml @@ -8,5 +8,7 @@ # ############################################################################# --- - include: opensds.yml + when: + - inventory_hostname in groups['ceph_adm'] - include: post-install.yml -- cgit 1.2.3-korg