Update the latest version of ansible script
[stor4nfv.git] / ci / ansible / roles / common / tasks / main.yml
old mode 100755 (executable)
new mode 100644 (file)
index d6bef82..14a28d3
----
-# If we can't get golang installed before any module is used we will fail
-# so just try what we can to get it installed
-- name: check for golang
-  stat:
-    path: /usr/local/go
-  ignore_errors: yes
-  register: systemgolang
-
-- name: install golang for debian based systems
-  shell:
-    cmd: |
-      set -e
-      set -x
-
-      wget {{ golang_download_url }} -P /opt/
-      tar xvf /opt/{{ golang_tarball }} -C /usr/local/
-      cat >> /etc/profile <<GOLANG__CONFIG_DOC
-      export GOROOT=/usr/local/go
-      export GOPATH=\$HOME/gopath
-      export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin
-      GOLANG__CONFIG_DOC
-
-    executable: /bin/bash
-  ignore_errors: yes
-  when:
-    - systemgolang.stat.exists is undefined or systemgolang.stat.exists == false
-
-- name: Run the equivalent of "apt-get update" as a separate step
-  apt:
-    update_cache: yes
-
-- name: install librados-dev external package
-  apt:
-    name: librados-dev
-
-- name: install librbd-dev external package
-  apt:
-    name: librbd-dev
-
-- pip:
-    name: docker-py
-  when: container_enabled == true
-
-- name: check for opensds source code existed
-  stat:
-    path: "{{ opensds_root_dir }}"
-  ignore_errors: yes
-  register: opensdsexisted
-
-- name: download opensds source code
-  git:
-    repo: "{{ remote_url }}"
-    dest: "{{ opensds_root_dir }}"
-  when:
-    - opensdsexisted.stat.exists is undefined or opensdsexisted.stat.exists == false
-
-- name: check for opensds binary file existed
-  stat:
-    path: "{{ opensds_build_dir }}"
-  ignore_errors: yes
-  register: opensdsbuilt
-
-- name: build opensds binary file
-  shell: . /etc/profile; make
-  args:
-    chdir: "{{ opensds_root_dir }}"
-  when:
-    - opensdsbuilt.stat.exists is undefined or opensdsbuilt.stat.exists == false
-
-- name: create opensds global config directory if it doesn't exist
-  file:
-    path: "{{ opensds_config_dir }}/driver"
-    state: directory
-    mode: 0755
-
-- name: create opensds log directory if it doesn't exist
-  file:
-    path: "{{ opensds_log_dir }}"
-    state: directory
-    mode: 0755
-
-- name: configure opensds global info
-  shell: |
-    cat > opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC
-    [osdslet]
-    api_endpoint = {{ controller_endpoint }}
-    graceful = True
-    log_file = {{ controller_log_file }}
-    socket_order = inc
-
-    [osdsdock]
-    api_endpoint = {{ dock_endpoint }}
-    log_file = {{ dock_log_file }}
-    # Specify which backends should be enabled, sample,ceph,cinder,lvm and so on.
-    enabled_backends = {{ enabled_backend }}
-
-    [lvm]
-    name = {{ lvm_name }}
-    description = {{ lvm_description }}
-    driver_name = {{ lvm_driver_name }}
-    config_path = {{ lvm_config_path }}
-
-    [ceph]
-    name = {{ ceph_name }}
-    description = {{ ceph_description }}
-    driver_name = {{ ceph_driver_name }}
-    config_path = {{ ceph_config_path }}
-
-    [cinder]
-    name = {{ cinder_name }}
-    description = {{ cinder_description }}
-    driver_name = {{ cinder_driver_name }}
-    config_path = {{ cinder_config_path }}
-
-    [database]
-    endpoint = {{ db_endpoint }}
-    driver = {{ db_driver }}
-  args:
-    chdir: "{{ opensds_config_dir }}"
-  ignore_errors: yes
+# Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#     http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+---\r
+- name: set script dir permissions\r
+  file:\r
+    path: ./script\r
+    mode: 0755\r
+    recurse: yes\r
+  ignore_errors: yes\r
+  become: yes\r
+    \r
+- name: check ansible version\r
+  shell: "{{ item }}"\r
+  with_items:\r
+    - bash ./script/check_ansible_version.sh\r
+  become: yes\r
+\r
+- name: run the equivalent of "apt-get update" as a separate step\r
+  apt:\r
+    update_cache: yes\r
+\r
+- name: install system packages\r
+  package:\r
+    name: "{{ item }}"\r
+    state: present\r
+  with_items:\r
+    - make\r
+    - gcc\r
+    - python-pip\r
+\r
+- name: install Red Hat system packages\r
+  package:\r
+    name: "{{ item }}"\r
+    state: present\r
+  with_items:\r
+    - librados-devel\r
+    - librbd-devel\r
+  when: ansible_os_family == "RedHat"\r
+\r
+- name: install Ubuntu system packages\r
+  package:\r
+    name: "{{ item }}"\r
+    state: present\r
+  with_items:\r
+    - librados-dev\r
+    - librbd-dev\r
+  when: ansible_os_family == "Debian"\r
+\r
+- name: create opensds work directory if it doesn't exist\r
+  file:\r
+    path: "{{ item }}"\r
+    state: directory\r
+    mode: 0755\r
+  with_items:\r
+    - "{{ opensds_work_dir }}"\r
+    - "{{ opensds_config_dir }}"\r
+    - "{{ opensds_driver_config_dir }}"\r
+    - "{{ opensds_log_dir }}"\r
+\r
+- name: include scenarios/repository.yml when installing from repository\r
+  include: scenarios/repository.yml\r
+  when: install_from == "repository"\r
+\r
+- name: include scenarios/release.yml when installing from release\r
+  include: scenarios/release.yml\r
+  when: install_from == "release"\r
+\r
+- name: include scenarios/container.yml when installing from container\r
+  include: scenarios/container.yml\r
+  when: install_from == "container"\r
+\r
+- name: copy config templates into opensds global config folder\r
+  copy:\r
+    src: ../../../../conf/\r
+    dest: "{{ opensds_config_dir }}"\r
+\r
+- name: configure opensds global info\r
+  shell: |\r
+    cat > opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC\r
+    [osdslet]\r
+    api_endpoint = {{ controller_endpoint }}\r
+    graceful = True\r
+    log_file = {{ controller_log_file }}\r
+    socket_order = inc\r
+    auth_strategy = {{ opensds_auth_strategy }}\r
+\r
+    [osdsdock]\r
+    api_endpoint = {{ dock_endpoint }}\r
+    log_file = {{ dock_log_file }}\r
+    # Choose the type of dock resource, only support 'provisioner' and 'attacher'.\r
+    dock_type = {{ dock_type }}\r
+    # Specify which backends should be enabled, sample,ceph,cinder,lvm and so on.\r
+    enabled_backends = {{ enabled_backend }}\r
+\r
+    [database]\r
+    endpoint = {{ db_endpoint }}\r
+    driver = {{ db_driver }}\r
+  args:\r
+    chdir: "{{ opensds_config_dir }}"\r
+  ignore_errors: yes\r
+\r
+- name: include nbp-installer role if nbp_plugin_type != hotpot_only\r
+  include_role:\r
+    name: nbp-installer\r
+  when: nbp_plugin_type != "hotpot_only"\r