X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=installers%2Fopenstack%2Froles%2Fcreate_instances%2Ftasks%2Fmain.yml;fp=installers%2Fopenstack%2Froles%2Fcreate_instances%2Ftasks%2Fmain.yml;h=03c0b4c14aa5dcd40406b3e9d1bae8f5aaca6baa;hb=f4ce57c319f95ce4306d9d65b9545361f7f2dfc6;hp=0000000000000000000000000000000000000000;hpb=d4277852fcaf03959bdd8efc37dd32b26fa3919f;p=osm%2Fdevops.git diff --git a/installers/openstack/roles/create_instances/tasks/main.yml b/installers/openstack/roles/create_instances/tasks/main.yml new file mode 100644 index 00000000..03c0b4c1 --- /dev/null +++ b/installers/openstack/roles/create_instances/tasks/main.yml @@ -0,0 +1,61 @@ +--- +# Copyright 2020 British Telecommunications plc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Author: Antonio Marsico (antonio.marsico@bt.com) + +- name: Launch OSM instances + os_server: + cloud: "{{ cloud_name }}" + name: "{{ prefix }}-{{ item.name }}" + state: present + key_name: "{{ item.key }}" + nics: "{{ item.nics }}" + image: "{{ item.image }}" + flavor: "{{ item.flavor }}" + security_groups: + - default + - "{{external_network_name}}_access" + with_items: "{{ servers }}" + register: "os_hosts" + when: setup_volume|bool == False + +- name: Launch OSM instances with a volume + os_server: + cloud: "{{ cloud_name }}" + name: "{{ prefix }}-{{ item.name }}" + state: present + key_name: "{{ item.key }}" + nics: "{{ item.nics }}" + image: "{{ item.image }}" + flavor: "{{ item.flavor }}" + boot_from_volume: yes + terminate_volume: yes + security_groups: + - default + - "{{external_network_name}}_access" + with_items: "{{ servers }}" + register: "os_hosts_with_volume" + when: setup_volume|bool == True + +- set_fact: + os_hosts: "{{ os_hosts_with_volume }}" + when: setup_volume|bool == True + +- name: Add OSM host to the local Ansible inventory + add_host: + name: "{{ item.openstack.accessIPv4 }}" + groups: "{{ item['item']['meta']['group'] }}" + ansible_private_key_file: "~/.ssh/{{ os_key_name }}" + ansible_user: "{{ item['item']['user'] }}" + with_items: "{{ os_hosts.results }}"