Stephane Barbarie | 2cbffca | 2018-03-26 16:20:03 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Zack Williams | 41513bf | 2018-07-07 20:08:35 -0700 | [diff] [blame] | 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
Stephane Barbarie | 2cbffca | 2018-03-26 16:20:03 -0400 | [diff] [blame] | 15 | |
| 16 | uId=`id -u` |
| 17 | vmName="voltha_voltha${uId}" |
| 18 | |
| 19 | # Get the VM's ip address |
| 20 | ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'` |
| 21 | |
| 22 | # Retrieve stable kubespray repo |
| 23 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 24 | ../.vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
Stephane Barbarie | 78d9fa6 | 2018-04-19 14:11:05 -0400 | [diff] [blame] | 25 | "git clone --branch v2.5.0 https://github.com/kubernetes-incubator/kubespray.git" |
Stephane Barbarie | 2cbffca | 2018-03-26 16:20:03 -0400 | [diff] [blame] | 26 | |
| 27 | # Setup a new ansible manifest to only download files |
| 28 | cat <<HERE > download.yml |
| 29 | --- |
| 30 | - hosts: k8s-cluster |
| 31 | any_errors_fatal: "{{ any_errors_fatal | default(true) }}" |
| 32 | roles: |
| 33 | - { role: kubespray-defaults} |
| 34 | - { role: download, tags: download, skip_downloads: false} |
| 35 | HERE |
| 36 | |
| 37 | # Copy the manifest over to the voltha instance |
| 38 | scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 39 | ../.vagrant/machines/voltha${uId}/libvirt/private_key \ |
| 40 | download.yml vagrant@$ipAddr:kubespray/download.yml |
| 41 | |
| 42 | # Run the manifest |
| 43 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 44 | ../.vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
Stephane Barbarie | 78d9fa6 | 2018-04-19 14:11:05 -0400 | [diff] [blame] | 45 | "mkdir -p releases && cd kubespray && ANSIBLE_CONFIG=ansible.cfg ansible-playbook -v -u root -i inventory/local/hosts.ini download.yml" |
Stephane Barbarie | 2cbffca | 2018-03-26 16:20:03 -0400 | [diff] [blame] | 46 | |
| 47 | rtrn=$? |
| 48 | |
| 49 | echo "Preload return code: $rtrn" |
| 50 | |
| 51 | exit $rtrn |
| 52 | |