summaryrefslogtreecommitdiffstats
path: root/resources/ansible_roles/openstack/tasks/main.yml
blob: ed04383187f93d48cc39d65619f5c5fb40746562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
##############################################################################
# Copyright (c) 2018 ZTE Corporation 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
##############################################################################

---

- name: Delete QTIP stack
  os_stack:
    name: "{{ stack_name }}"
    state: absent

- name: Delete QTIP keypair
  os_keypair:
      name: QtipKey
      state: absent

- name: Delete QTIP flavor
  os_nova_flavor:
    name: "{{ flavor_name }}"
    state: absent

- name: Delete qtip image
  os_image:
    name: "{{ image_name }}"
    state: absent

- name: Create temp directory for QTIP
  file:
    path: "{{ temp_dir }}"
    state: directory

- name: Clean the existing SSH keypair
  file:
    state: absent
    path: "{{ temp_dir }}/{{ item }}"
  with_items:
    - QtipKey.pub
    - QtipKey

- name: Generate a SSH key for QTIP VM
  shell: ssh-keygen -t rsa -N "" -f "{{ temp_dir }}/QtipKey" -q

- name: Create QTIP keypair
  os_keypair:
      name: QtipKey
      public_key_file: "{{ temp_dir }}/QtipKey.pub"
      state: present

- name: Create QTIP flavor
  os_nova_flavor:
    name: "{{ flavor_name }}"
    ram: 2048
    vcpus: 3
    disk: 4
    state: present

- name: Download image as qtip image
  get_url:
    url: "{{ image_url }}"
    dest: "{{ temp_dir }}/{{ image_name }}.img"
    checksum: "md5:{{ checksum }}"
  when: image_url | search("https://")

- name: Upload qtip image
  os_image:
    name: "{{ image_name }}"
    container_format: bare
    disk_format: qcow2
    state: present
    filename: "{{ temp_dir }}/{{ image_name }}.img"

- name: create qtip stack
  os_stack:
    name: "{{ stack_name }}"
    state: present
    template: "{{ heat_template }}"
    parameters:
      image: "{{ image_name }}"
      flavor: "{{ flavor_name }}"
      keypair: QtipKey
      external_network: "{{ external_network }}"