-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenstack_compute.yml
More file actions
54 lines (50 loc) · 1.61 KB
/
openstack_compute.yml
File metadata and controls
54 lines (50 loc) · 1.61 KB
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
---
- hosts: localhost
vars:
- auth_url: https://labcloudftk.lnu.se:5000
- project: Group01_project
- network: coinflippers_lan
- key_name: openstack
vars_prompt:
- name: "username"
prompt: "Openstack Username"
- name: "password"
prompt: "Openstack Password"
tasks:
- name: Create ports with fixed ips
os_port:
auth:
auth_url: "{{ auth_url }}"
username: "{{ username }}"
password: "{{ password }}"
project_name: "{{ project }}"
name: "{{ item }}_port"
state: present
network: "{{ network }}"
fixed_ips:
- ip_address: "{{ hostvars[item]['ansible_host'] }}"
when: item != "mgmt"
with_items: "{{ groups['all'] }}"
- name: Create instances
os_server:
auth:
auth_url: "{{ auth_url }}"
username: "{{ username }}"
password: "{{ password }}"
project_name: "{{ project }}"
state: present
name: "{{ item }}"
image: "{{ hostvars[item]['image'] }}"
flavor: "{{ hostvars[item]['flavor'] }}"
nics:
- port-name: "{{ item }}_port"
security_groups: "{{ hostvars[item]['security_groups'] }}"
key_name: "{{ key_name }}"
auto_ip: "{{ hostvars[item]['public_ip'] }}"
userdata: |
{%- raw -%}#!/bin/bash
sudo apt-get update
sudo apt-get install -y python
{% endraw %}
when: item != "mgmt"
with_items: "{{ groups['all'] }}"