Add onap installation role 17/94117/2
authorMichal Zegan <m.zegan@samsung.com>
Thu, 22 Aug 2019 12:53:46 +0000 (14:53 +0200)
committerMichal Zegan <m.zegan@samsung.com>
Wed, 4 Sep 2019 09:24:52 +0000 (11:24 +0200)
This role generates offline installer parameters and inventory, downloads
offline installer sw package, and initiates onap installation, waiting
for it to finish.

Change-Id: I5c79d9732b8d77f57278f5009f4e5089377fc2cf
Issue-ID: OOM-2042
Signed-off-by: Michal Zegan <m.zegan@samsung.com>
tools/cicdansible/roles/install/defaults/main.yml [new file with mode: 0644]
tools/cicdansible/roles/install/tasks/download_resources.yml [new file with mode: 0644]
tools/cicdansible/roles/install/tasks/install.yml [new file with mode: 0644]
tools/cicdansible/roles/install/tasks/main.yml [new file with mode: 0644]
tools/cicdansible/roles/install/templates/inventory.yml.j2 [new file with mode: 0644]

diff --git a/tools/cicdansible/roles/install/defaults/main.yml b/tools/cicdansible/roles/install/defaults/main.yml
new file mode 100644 (file)
index 0000000..b21e632
--- /dev/null
@@ -0,0 +1,3 @@
+---
+installer_deploy_path: "{{ ansible_user_dir }}/installer"
+install_timeout: 10600
diff --git a/tools/cicdansible/roles/install/tasks/download_resources.yml b/tools/cicdansible/roles/install/tasks/download_resources.yml
new file mode 100644 (file)
index 0000000..7f04259
--- /dev/null
@@ -0,0 +1,6 @@
+#Download resources/scripts to controller.
+- name: "Download software resources"
+  fetch:
+    src: "{{ resources_dir }}/{{ resources_sw_filename }}"
+    flat: yes
+    dest: "resources/"
diff --git a/tools/cicdansible/roles/install/tasks/install.yml b/tools/cicdansible/roles/install/tasks/install.yml
new file mode 100644 (file)
index 0000000..35df797
--- /dev/null
@@ -0,0 +1,48 @@
+#Onap installation tasks
+#Copy ssh private key used for resource server access
+- name: "Copy resource server access key"
+  copy:
+    src: "{{ hostvars[groups['resources'][0]].ansible_private_key_file }}"
+    dest: "{{ ansible_user_dir }}/.ssh/res.pem"
+    mode: 0600
+#Unarchive resources.
+- name: "Ensure {{ installer_deploy_path }} directory exists"
+  file:
+    path: "{{ installer_deploy_path }}"
+    state: directory
+- name: "Extract sw resources"
+  unarchive:
+    src: "resources/{{ hostvars[groups['resources'][0]].resources_sw_filename }}"
+    dest: "{{ installer_deploy_path }}"
+#Generate ansible inventory and extra vars.
+- name: "Generate ansible inventory for installer"
+  template:
+    src: inventory.yml.j2
+    dest: "{{ installer_deploy_path }}/ansible/inventory/hosts.yml"
+- name: "generate application specific config overrides"
+  copy:
+    content: "{{ application_config | b64decode }}"
+    dest: "{{ installer_deploy_path }}/ansible/application/application_overrides.yml"
+# This generates a file with locations of resource files in resource host, we
+# do it only to allow manually running offline installer without
+# typing them by hand. We cannot use
+# inventory template because it will be overridden
+# by application_configuration.yml.
+- name: Generate resource location file
+  copy:
+    content: |
+      resources_dir: {{ resources_dir }}
+      resources_filename: {{ resources_filename }}
+      aux_resources_filename: {{ aux_resources_filename }}
+      app_data_path: /opt/onap/resources
+    dest: "{{ installer_deploy_path }}/ansible/application/resources.yml"
+#Run script.
+- name: "Execute installation"
+  shell:
+    ./run_playbook.sh
+     -e @application/application_configuration.yml -e @application/application_overrides.yml
+     -e @application/resources.yml -i inventory/hosts.yml site.yml
+  args:
+    chdir: "{{ installer_deploy_path }}/ansible"
+  async: "{{ install_timeout }}"
+  when: install_app
diff --git a/tools/cicdansible/roles/install/tasks/main.yml b/tools/cicdansible/roles/install/tasks/main.yml
new file mode 100644 (file)
index 0000000..04ac4c3
--- /dev/null
@@ -0,0 +1 @@
+- include_tasks: "{{ mode }}.yml"
diff --git a/tools/cicdansible/roles/install/templates/inventory.yml.j2 b/tools/cicdansible/roles/install/templates/inventory.yml.j2
new file mode 100644 (file)
index 0000000..36bf3bd
--- /dev/null
@@ -0,0 +1,36 @@
+all:
+  vars:
+    ansible_ssh_private_key_file: /root/.ssh/id_rsa
+    ansible_ssh_common_args: "-o StrictHostKeyChecking=no"
+  children:
+    resources:
+      vars:
+        ansible_ssh_private_key_file: /root/.ssh/res.pem
+        ansible_user: "{{ hostvars[groups['resources'][0]].ansible_user }}"
+        ansible_become: "{{ hostvars[groups['resources'][0]].ansible_become }}"
+      hosts:
+        resource_host:
+          ansible_host: {{ resource_host }}
+    infrastructure:
+      hosts:
+        infra_host:
+          ansible_host: infra
+          cluster_ip: {{ hostvars['infra'].ansible_default_ipv4.address }}
+    kubernetes:
+      children:
+        kubernetes-node:
+          hosts:
+{% for h in groups['nodes'] %}
+            {{ h }}:
+              ansible_host: "{{ hostvars[h].ansible_default_ipv4.address }}"
+              cluster_ip: "{{ hostvars[h].ansible_default_ipv4.address }}"
+{% endfor %}
+        kubernetes-control-plane:
+          hosts:
+            infra_host
+        kubernetes-etcd:
+          hosts:
+            infra_host
+    nfs-server:
+      hosts:
+        node0