forked from catalyst-cloud/catalystcloud-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch-instance.yml
More file actions
executable file
·83 lines (74 loc) · 3 KB
/
launch-instance.yml
File metadata and controls
executable file
·83 lines (74 loc) · 3 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
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
#!/usr/bin/env ansible-playbook
---
# This playbook demonstrates the basic interaction between Ansible's OpenStack
# cloud module and the Catalyst Cloud. Ansible will pick up the OpenStack
# environment variables from the operating system if an OpenStack RC file is
# sourced before running the playbook. Alternatively, you can specify the
# OpenStack authentication variables and refer to them when using the os_auth
# module.
- name: Deploy a cloud instance in OpenStack
hosts: localhost
vars:
# OpenStack authentication variables (not required if RC sourced)
os_auth_url: https://api.cloud.catalyst.net.nz:5000/v2.0
os_region: nz-por-1
os_az: nz-por-1a
os_project_name: projectname
os_username: username
os_password: password
# Attributes used for launching the compute instance (required)
image: ubuntu-14.04-x86_64
private_network_name: private-net
keypair_name: first-instance-key
instance_name: first-instance
flavor: c1.c1r1
security_group_name: first-instance-sg
tasks:
#- name: Fetch information about the Catalyst Cloud
# os_client_config:
# clouds:
# - catalyst_cloud
# If you have sourced an OpenStack RC file, connecting to the Catalyst
# Cloud is as simple as running the os_auth module with no additional
# parameters.
- name: Connect to the Catalyst Cloud
os_auth:
# If you have not sourced an OpenStack RC file, you will need to pass a few
# mandatory authentication attributes, as demonstrated below.
#- name: Connect to the Catalyst Cloud
# os_auth:
# auth:
# auth_url: "{{ os_auth_url }}"
# username: "{{ os_username }}"
# password: "{{ os_password }}"
# project_name: "{{ os_project_name }}"
# The service catalog is stored on a variable called service_catalog. The
# task below prints it out as debug information, in case you need it.
#- name: Print the service catalog as debug information
# debug: var=service_catalog
- name: Create a compute instance on the Catalyst Cloud
os_server:
# Since we have authenticated on the previous task, there is not need
# to authenticate again on this task. However, if this was the only
# task we intended to run, we could create the instance an authenticate
# all at once.
#auth:
# auth_url: "{{ os_auth_url }}"
# username: "{{ os_username }}"
# password: "{{ os_password }}"
# project_name: "{{ os_project_name }}"
state: present
name: "{{ instance_name }}"
image: "{{ image }}"
key_name: "{{ keypair_name }}"
flavor: "{{ flavor }}"
nics:
- net-name: "{{ private_network_name }}"
security_groups: "default,{{ security_group_name }}"
- name: Assign a floating IP
os_floating_ip:
server: "{{ instance_name }}"
register: floating_ip_info
- name: Output floating IP
debug:
var: floating_ip_info.floating_ip.floating_ip_address