forked from catalyst-cloud/catalystcloud-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-network.yml
More file actions
executable file
·96 lines (85 loc) · 3.12 KB
/
create-network.yml
File metadata and controls
executable file
·96 lines (85 loc) · 3.12 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
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env ansible-playbook
---
# This playbook demonstrates how to create a network, subnet and router on 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
# Required variables
ssh_public_key: /home/youruser/.ssh/id_rsa.pub
private_network_name: private-net
private_subnet_name: private-subnet
subnet_cidr: 10.0.0.0/24
subnet_pool_start: 10.0.0.10
subnet_pool_end: 10.0.0.200
nameservers: [202.78.247.197, 202.78.247.198, 202.78.247.199]
router_name: border-router
security_group_name: first-instance-sg
keypair_name: first-instance-key
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 }}"
- name: Create a network
os_network:
state: present
name: "{{ private_network_name }}"
- name: Create a subnet
os_subnet:
state: present
name: "{{ private_subnet_name }}"
network_name: "{{ private_network_name }}"
cidr: "{{ subnet_cidr }}"
dns_nameservers: "{{ nameservers }}"
allocation_pool_start: "{{ subnet_pool_start }}"
allocation_pool_end: "{{ subnet_pool_end }}"
- name: Create a router
os_router:
state: present
name: "{{ router_name }}"
network: public-net
interfaces:
- "{{ private_subnet_name }}"
- name: Create a security group
os_security_group:
state: present
name: "{{ security_group_name }}"
description: Network access for our first instance.
- name: Create a security group rule for SSH access
os_security_group_rule:
state: present
security_group: "{{ security_group_name }}"
protocol: tcp
port_range_min: 22
port_range_max: 22
remote_ip_prefix: 0.0.0.0/0
- name: Import an SSH keypair
os_keypair:
state: present
name: "{{ keypair_name }}"
public_key_file: "{{ ssh_public_key }}"