aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2019-02-28 14:16:34 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2019-04-11 14:49:48 +0800
commit113fccee9efc558e90b0a62adedccb29347d7f18 (patch)
treea7190e67ed1cf278efab5d3fad01848da6e1975f /plugins
parent13b89da3652164ea1956d116c98fbe7db82eeda6 (diff)
Add ONAP scenarioHEADmaster
JIRA: - 1. Add ONAP plugin 2. Add ONAP scenario Change-Id: I80046811207f5786049fb9829e3d9f33ea31978a Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/onap/roles/tasks/Ubuntu.yml117
-rw-r--r--plugins/onap/roles/tasks/main.yml11
-rw-r--r--plugins/onap/roles/templates/exports.j21
-rw-r--r--plugins/onap/roles/vars/main.yml13
4 files changed, 142 insertions, 0 deletions
diff --git a/plugins/onap/roles/tasks/Ubuntu.yml b/plugins/onap/roles/tasks/Ubuntu.yml
new file mode 100644
index 00000000..a51e5f17
--- /dev/null
+++ b/plugins/onap/roles/tasks/Ubuntu.yml
@@ -0,0 +1,117 @@
+---
+- name: download helm
+ get_url:
+ url: "{{ helm_url }}"
+ dest: /tmp/helm.tar.gz
+ when: inventory_hostname == groups['kube_master'][0]
+ run_once: true
+
+- name: prepare helm
+ shell:
+ tar -zxf /tmp/helm.tar.gz -C /tmp;
+ mv /tmp/linux-amd64/helm /usr/local/bin/helm
+ when: inventory_hostname == groups['kube_master'][0]
+ run_once: true
+
+- name: install tiller
+ shell: >
+ kubectl create serviceaccount --namespace kube-system tiller;
+ kubectl create clusterrolebinding tiller-cluster-rule
+ --clusterrole=cluster-admin
+ --serviceaccount=kube-system:tiller;
+ helm init --service-account tiller
+ when: inventory_hostname == groups['kube_master'][0]
+ run_once: true
+
+- name: git clone oom
+ git:
+ repo: "{{ oom_repo }}"
+ dest: "{{ oom_dest }}"
+ version: "{{ oom_version }}"
+ when: inventory_hostname == groups['kube_master'][0]
+ run_once: true
+
+- name: prepare local repo
+ shell:
+ nohup /bin/sh -c "helm serve &"
+ while true; do curl -s 127.0.0.1:8879 > /dev/null; if [ $? -eq 0 ]; then break; fi; done
+ helm repo add local http://127.0.0.1:8879
+ when: inventory_hostname == groups['kube_master'][0]
+ run_once: true
+
+- name: add helm plugin
+ shell:
+ cp -rf "{{ oom_dest }}/kubernetes/helm/plugins" ~/.helm/
+ when: inventory_hostname == groups['kube_master'][0]
+ run_once: true
+
+- name: make
+ shell:
+ make all
+ args:
+ chdir: "{{ oom_dest }}/kubernetes"
+ when: inventory_hostname == groups['kube_master'][0]
+
+- name: install nfs master
+ apt:
+ pkg: "nfs-kernel-server"
+ state: "present"
+ update_cache: "yes"
+ when: inventory_hostname == groups['kube_master'][0]
+
+- name: create /dockerdata-nfs
+ file:
+ path: /dockerdata-nfs
+ owner: nobody
+ group: nogroup
+ state: directory
+ mode: 0777
+ when: inventory_hostname == groups['kube_master'][0]
+
+- name: install nfs slave
+ apt:
+ pkg: "nfs-common"
+ state: "present"
+ update_cache: "yes"
+ when: inventory_hostname != groups['kube_master'][0]
+
+- name: create /dockerdata-nfs
+ file:
+ path: /dockerdata-nfs
+ state: directory
+ when: inventory_hostname != groups['kube_master'][0]
+
+- name: render /etc/exports
+ template:
+ src: exports.j2
+ dest: /etc/exports
+ when: inventory_hostname == groups['kube_master'][0]
+
+- name: restart nfs service
+ shell:
+ exportfs -a;
+ systemctl restart nfs-kernel-server
+ when: inventory_hostname == groups['kube_master'][0]
+
+- name: register master hostname
+ debug:
+ msg: "{{ ip_settings[groups['kube_master'][0]]['external']['ip'] }}"
+ register: master_ip
+
+- name:
+ shell:
+ mount {{ master_ip.msg }}:/dockerdata-nfs /dockerdata-nfs/
+ when: inventory_hostname != groups['kube_master'][0]
+
+# yamllint disable rule:line-length
+- name: add mount info
+ lineinfile:
+ path: /etc/fstab
+ line: "{{ master_ip.msg }}:/dockerdata-nfs /dockerdata-nfs nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0"
+ when: inventory_hostname != groups['kube_master'][0]
+# yamllint enable rule:line-length
+
+- name: deploy onap
+ shell:
+ helm deploy dev local/onap --namespace onap
+ when: inventory_hostname == groups['kube_master'][0]
diff --git a/plugins/onap/roles/tasks/main.yml b/plugins/onap/roles/tasks/main.yml
new file mode 100644
index 00000000..c9e80427
--- /dev/null
+++ b/plugins/onap/roles/tasks/main.yml
@@ -0,0 +1,11 @@
+#############################################################################
+# Copyright (c) 2019 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: "{{ ansible_distribution }}.yml"
+ when: onap is defined and onap == "Enable"
diff --git a/plugins/onap/roles/templates/exports.j2 b/plugins/onap/roles/templates/exports.j2
new file mode 100644
index 00000000..8f5a3f65
--- /dev/null
+++ b/plugins/onap/roles/templates/exports.j2
@@ -0,0 +1 @@
+/dockerdata-nfs{% for host in groups.all %}{% if host != groups.kube_master[0] %} {{ ip_settings[host]['external']['ip'] }}(rw,sync,no_root_squash,no_subtree_check){% endif %}{% endfor %}
diff --git a/plugins/onap/roles/vars/main.yml b/plugins/onap/roles/vars/main.yml
new file mode 100644
index 00000000..83b591a5
--- /dev/null
+++ b/plugins/onap/roles/vars/main.yml
@@ -0,0 +1,13 @@
+#############################################################################
+# Copyright (c) 2019 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
+##############################################################################
+---
+helm_url: https://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-linux-amd64.tar.gz
+oom_repo: https://gerrit.onap.org/r/oom
+oom_dest: /home/oom
+oom_version: casablanca