Fatih Degirmenci | e799508 | 2019-03-24 20:49:21 +0000 | [diff] [blame] | 1 | --- |
| 2 | # ============LICENSE_START======================================================= |
| 3 | # Copyright (C) 2019 The Nordix Foundation. All rights reserved. |
| 4 | # ================================================================================ |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | # SPDX-License-Identifier: Apache-2.0 |
| 18 | # ============LICENSE_END========================================================= |
| 19 | |
Your Name | ddc40f8 | 2019-12-12 14:02:40 +0000 | [diff] [blame^] | 20 | # TODO: move these tasks to a more suitable place |
| 21 | # TODO: load only the necessary images in each node according to their node |
| 22 | - hosts: k8s-cluster |
| 23 | gather_facts: false |
| 24 | tasks: |
| 25 | - name: Execute preparation for post-deployment in offline mode |
| 26 | block: |
| 27 | # Load docker images in cache for offline installation |
| 28 | # TODO: we should set-up a Docker local repository in kickstart |
| 29 | - name: Find cached docker images |
| 30 | find: |
| 31 | paths: "/tmp/kubespray_cache/images" |
| 32 | patterns: '^.*\.tar' |
| 33 | use_regex: true |
| 34 | file_type: file |
| 35 | register: docker_images |
| 36 | |
| 37 | # TODO: use the docker_image Ansible module |
| 38 | - name: Load missing docker images into node's memory |
| 39 | shell: | |
| 40 | set -o pipefail |
| 41 | cat "{{ item.path }}" | docker load |
| 42 | changed_when: false |
| 43 | args: |
| 44 | executable: /bin/bash |
| 45 | with_items: "{{ docker_images.files }}" |
| 46 | when: offline_deployment|bool |
| 47 | |
Fatih Degirmenci | edec215 | 2019-07-27 16:21:49 +0000 | [diff] [blame] | 48 | # check if any post-deployment task defined for the scenario |
Fatih Degirmenci | 6e92573 | 2019-06-21 18:12:26 +0000 | [diff] [blame] | 49 | - hosts: localhost |
| 50 | connection: local |
Fatih Degirmenci | 87c986c | 2020-01-12 22:35:53 +0000 | [diff] [blame] | 51 | gather_facts: false |
| 52 | become: false |
Fatih Degirmenci | 6e92573 | 2019-06-21 18:12:26 +0000 | [diff] [blame] | 53 | |
| 54 | tasks: |
Fatih Degirmenci | edec215 | 2019-07-27 16:21:49 +0000 | [diff] [blame] | 55 | - name: Check if any post-deployment task defined for '{{ deploy_scenario }}' scenario |
Fatih Degirmenci | 6e92573 | 2019-06-21 18:12:26 +0000 | [diff] [blame] | 56 | stat: |
| 57 | path: "{{ engine_cache }}/repos/swconfig/{{ scenario[deploy_scenario].installers[installer_type].role }}/tasks/post-deployment.yml" |
| 58 | register: post_deployment_yml |
| 59 | |
| 60 | # run the scenario post-deployment tasks before running the common post-deployment tasks |
| 61 | - hosts: all |
Fatih Degirmenci | 87c986c | 2020-01-12 22:35:53 +0000 | [diff] [blame] | 62 | gather_facts: true |
| 63 | become: true |
Fatih Degirmenci | 6e92573 | 2019-06-21 18:12:26 +0000 | [diff] [blame] | 64 | |
| 65 | tasks: |
Fatih Degirmenci | edec215 | 2019-07-27 16:21:49 +0000 | [diff] [blame] | 66 | - name: Execute post-deployment tasks of '{{ deploy_scenario }}' scenario |
Fatih Degirmenci | 6e92573 | 2019-06-21 18:12:26 +0000 | [diff] [blame] | 67 | include_role: |
| 68 | name: "{{ engine_cache }}/repos/swconfig/{{ scenario[deploy_scenario].installers[installer_type].role }}" |
| 69 | tasks_from: post-deployment |
Fatih Degirmenci | 572223c | 2019-12-11 13:43:10 +0100 | [diff] [blame] | 70 | when: hostvars['localhost'].post_deployment_yml.stat.exists |
Fatih Degirmenci | 6e92573 | 2019-06-21 18:12:26 +0000 | [diff] [blame] | 71 | |
| 72 | # run common post-deployment tasks |
Sriram Yagnaraman | cf9daa0 | 2019-10-29 14:18:37 +0100 | [diff] [blame] | 73 | # NOTE: The common post-deployment tasks is currently applicable only to |
| 74 | # simple k8s and openstack scenarios. |
Fatih Degirmenci | edec215 | 2019-07-27 16:21:49 +0000 | [diff] [blame] | 75 | # in future, when statement could be moved to tasks in role if the current |
| 76 | # tasks become relevant or new tasks are added. |
| 77 | - hosts: all |
Fatih Degirmenci | 87c986c | 2020-01-12 22:35:53 +0000 | [diff] [blame] | 78 | gather_facts: true |
| 79 | become: true |
Fatih Degirmenci | e799508 | 2019-03-24 20:49:21 +0000 | [diff] [blame] | 80 | |
Fatih Degirmenci | e799508 | 2019-03-24 20:49:21 +0000 | [diff] [blame] | 81 | roles: |
| 82 | - role: post-deployment |
Sriram Yagnaraman | 8ecf7d3 | 2019-12-08 22:39:58 +0000 | [diff] [blame] | 83 | when: "'onap-' not in deploy_scenario" |
Fatih Degirmenci | e799508 | 2019-03-24 20:49:21 +0000 | [diff] [blame] | 84 | |
| 85 | # vim: set ts=2 sw=2 expandtab: |