diff options
author | Fatih Degirmenci <fdegir@gmail.com> | 2019-09-01 11:03:25 +0200 |
---|---|---|
committer | Fatih Degirmenci <fdegir@gmail.com> | 2019-09-01 12:19:56 +0200 |
commit | 2f711d43c322abc597ed2a53a1ce461229039960 (patch) | |
tree | 2316847fb583274655ed9251b19b229e2c1e68aa /xci/installer/osh | |
parent | f098d178cbbaa1096786c0d181d6693461fe4eb5 (diff) |
Adapt OSH to new scenario logic, ansible and k8s versions
installer-type:osh
deploy-scenario:k8-calico-nofeature
JIRA: XCI-5
JIRA: XCI-6
JIRA: XCI-20
Signed-off-by: Fatih Degirmenci <fdegir@gmail.com>
Change-Id: I0f2b577f7535050e6c65ca0e0bc209b7403c67ba
Signed-off-by: Fatih Degirmenci <fdegir@gmail.com>
Diffstat (limited to 'xci/installer/osh')
-rwxr-xr-x | xci/installer/osh/deploy.sh | 27 | ||||
-rw-r--r-- | xci/installer/osh/playbooks/configure-installer.yml | 47 | ||||
-rw-r--r-- | xci/installer/osh/playbooks/configure-opnfvhost.yml | 28 | ||||
-rw-r--r-- | xci/installer/osh/playbooks/roles/prepare-osh/tasks/main.yml | 2 |
4 files changed, 77 insertions, 27 deletions
diff --git a/xci/installer/osh/deploy.sh b/xci/installer/osh/deploy.sh index 73e71303..e56845b8 100755 --- a/xci/installer/osh/deploy.sh +++ b/xci/installer/osh/deploy.sh @@ -33,6 +33,20 @@ echo "-----------------------------------------------------------------------" echo "Info: Configured localhost for kubespray" #------------------------------------------------------------------------------- +# Configure installer +#------------------------------------------------------------------------------- +# TODO: summarize what this playbook does +#------------------------------------------------------------------------------- + +echo "Info: Configuring kubespray installer" +echo "-----------------------------------------------------------------------" +cd $OSH_XCI_PLAYBOOKS +ansible-playbook ${XCI_ANSIBLE_PARAMS} \ + -i ${XCI_PLAYBOOKS}/dynamic_inventory.py configure-installer.yml +echo "-----------------------------------------------------------------------" +echo "Info: Configured kubespray installer" + +#------------------------------------------------------------------------------- # Configure deployment host, opnfv #------------------------------------------------------------------------------- # This playbook @@ -75,7 +89,7 @@ echo "-----------------------------------------------------------------------" ssh root@$OPNFV_HOST_IP "set -o pipefail; export XCI_FLAVOR=$XCI_FLAVOR; export INSTALLER_TYPE=$INSTALLER_TYPE; \ export IDF=/root/releng-xci/xci/var/idf.yml; export PDF=/root/releng-xci/xci/var/pdf.yml; \ cd releng-xci/.cache/repos/kubespray/; ansible-playbook \ - -i opnfv_inventory/dynamic_inventory.py cluster.yml -b | tee setup-kubernetes.log" + -i inventory/opnfv/dynamic_inventory.py cluster.yml -b | tee setup-kubernetes.log" scp root@$OPNFV_HOST_IP:~/releng-xci/.cache/repos/kubespray/setup-kubernetes.log \ $LOG_PATH/setup-kubernetes.log @@ -88,19 +102,16 @@ echo "-----------------------------------------------------------------------" echo "Info: Kubernetes installation is successfully completed!" echo "-----------------------------------------------------------------------" -# Configure the kubernetes authentication in opnfv host. In future releases -# kubectl is no longer an artifact so we should not fail if it's not available. -# This needs to be removed in the future -ssh root@$OPNFV_HOST_IP "mkdir -p ~/.kube/;\ - cp -f ~/admin.conf ~/.kube/config; \ - cp -f ~/kubectl /usr/local/bin || true" - #------------------------------------------------------------------------------- # Execute post-installation tasks #------------------------------------------------------------------------------- # Playbook post.yml is used in order to execute any post-deployment tasks that # are required for the scenario under test. #------------------------------------------------------------------------------- +# copy admin.conf +ssh root@$OPNFV_HOST_IP "mkdir -p ~/.kube/;\ + cp -f ~/admin.conf ~/.kube/config;" + echo "-----------------------------------------------------------------------" echo "Info: Running post-deployment scenario role" echo "-----------------------------------------------------------------------" diff --git a/xci/installer/osh/playbooks/configure-installer.yml b/xci/installer/osh/playbooks/configure-installer.yml new file mode 100644 index 00000000..905777d0 --- /dev/null +++ b/xci/installer/osh/playbooks/configure-installer.yml @@ -0,0 +1,47 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2019 Ericsson Software Technology 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 +############################################################################## +- hosts: localhost + connection: local + vars_files: + - "{{ xci_path }}/xci/var/opnfv.yml" + + tasks: + - name: delete existing kubespray/inventory/opnfv directory + file: + path: "{{ xci_path }}/.cache/repos/kubespray/inventory/opnfv" + state: absent + + - name: copy kubespray/inventory/sample as kubespray/inventory/opnfv + copy: + src: "{{ xci_path }}/.cache/repos/kubespray/inventory/sample/" + dest: "{{ xci_path }}/.cache/repos/kubespray/inventory/opnfv" + + - name: update kubespray k8s-cluster.yml for xci + lineinfile: + path: "{{ xci_path }}/.cache/repos/kubespray/inventory/opnfv/group_vars/k8s-cluster/k8s-cluster.yml" + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" + with_items: + - { regexp: "kube_version:.*", line: "kube_version: {{ kubernetes_version }}" } + - { regexp: "kubeconfig_localhost:.*", line: "kubeconfig_localhost: true" } + - { regexp: "kube_basic_auth:.*", line: "kube_basic_auth: true" } + - { regexp: "dashboard_enabled:.*", line: "dashboard_enabled: true" } + + - name: update kubespray artifacts_dir + lineinfile: + path: "{{ xci_path }}/.cache/repos/kubespray/inventory/opnfv/group_vars/k8s-cluster/k8s-cluster.yml" + regexp: "artifacts_dir:.*" + line: "artifacts_dir: '{{ '{{' }} ansible_env.HOME {{ '}}' }}'" + + - name: change dashboard server type to NodePort + lineinfile: + path: "{{ xci_path }}/.cache/repos/kubespray/roles/kubernetes-apps/ansible/templates/dashboard.yml.j2" + insertafter: 'targetPort' + line: " type: NodePort" diff --git a/xci/installer/osh/playbooks/configure-opnfvhost.yml b/xci/installer/osh/playbooks/configure-opnfvhost.yml index 54e32149..52e42b06 100644 --- a/xci/installer/osh/playbooks/configure-opnfvhost.yml +++ b/xci/installer/osh/playbooks/configure-opnfvhost.yml @@ -52,22 +52,20 @@ - "--recursive" - "--files-from={{ xci_cache }}/releng-xci.files" - - name: delete the opnfv_inventory directory - file: - path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory" - state: absent - - - name: make sure kubespray/opnfv_inventory/group_vars/ exist - file: - path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/group_vars" - state: directory - - - name: copy kubespray inventory directory + - name: link xci dynamic inventory to kubespray/inventory/opnfv directory file: src: "{{ remote_xci_playbooks }}/dynamic_inventory.py" - path: "{{ remote_xci_path }}/.cache/repos/kubespray/opnfv_inventory/dynamic_inventory.py" + path: "{{ remote_xci_path }}/.cache/repos/kubespray/inventory/opnfv/dynamic_inventory.py" state: link + - name: Download kubectl and place it to /usr/local/bin + get_url: + url: "https://storage.googleapis.com/kubernetes-release/release/{{ kubernetes_version }}/bin/linux/amd64/kubectl" + dest: /usr/local/bin/kubectl + owner: root + group: root + mode: 0755 + - name: Reload XCI deployment host facts setup: filter: ansible_local @@ -85,12 +83,6 @@ update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}" when: xci_flavor == 'aio' - - name: change dashboard server type to NodePort - lineinfile: - path: "{{ remote_xci_path }}/.cache/repos/kubespray/roles/kubernetes-apps/ansible/templates/dashboard.yml.j2" - insertafter: 'targetPort' - line: " type: NodePort" - - name: pip install required packages pip: name: "{{ item.name }}" diff --git a/xci/installer/osh/playbooks/roles/prepare-osh/tasks/main.yml b/xci/installer/osh/playbooks/roles/prepare-osh/tasks/main.yml index aeaca6be..453a815c 100644 --- a/xci/installer/osh/playbooks/roles/prepare-osh/tasks/main.yml +++ b/xci/installer/osh/playbooks/roles/prepare-osh/tasks/main.yml @@ -14,7 +14,7 @@ #TODO Fetch the value from a file generated by k8s deployer - name: Get kube service addresses - shell: "grep -r 'kube_service_addresses:' /root/releng-xci/.cache/repos/kubespray/opnfv_inventory/group_vars/k8s-cluster.yml | awk '{print $2}'" + shell: "grep -r 'kube_service_addresses:' /root/releng-xci/.cache/repos/kubespray/inventory/opnfv/group_vars/k8s-cluster/k8s-cluster.yml | awk '{print $2}'" changed_when: false args: executable: /bin/bash |