-
Notifications
You must be signed in to change notification settings - Fork 0
/
openstack-ansible
executable file
·88 lines (79 loc) · 4.31 KB
/
openstack-ansible
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
#!/usr/bin/env ansible-playbook -i ./scripts/openstack-inventory.py
############### An generic playbook to run roles on Openstack ##############
#
# you have to pass parameters using -e <PARAM1>=<VALUE1> -e <PARAMS2>=<VALUE2>
#
# mandatory parameters:
# role= the role you want to push
# os_cloud= your clouds.yaml cloud profile/account name
#
# optional parameters:
# node_count= the total number of node you want to create/maintain
# public_node_count= the number of node you want to be public facing
# action= a non-default action to trigger, can be :
# - delete: the script will then delete all existing instances
# - delete_all: the script will delete instance, local config files and keys in OS
# - delete_all_includinguserkey: the script will wipe keys
# and instances both in OS and locally
# key_filename= explicit SSH key file name to use
---
# Generic playbook for Openstack
- name: "________________________ Cleaning up (if asked) ________________________"
connection: local
hosts: localhost
vars:
master_role: "{{ role }}"
playbook_name: "{{ role }}-ansible"
vars_files:
- config/openstack-config.yaml
roles:
- { role: inventory, when: "action is defined and 'delete' in action and action != 'local'" }
- { role: inventory-cleanup, when: "action is defined and 'delete' in action and action != 'local'" }
- name: "_____________________ OpenStack instance management ____________________"
connection: local
hosts: localhost
vars:
master_role: "{{ role }}"
playbook_name: "{{ role }}-ansible"
vars_files:
- config/openstack-config.yaml
- "roles/{{ role }}/defaults/main.yaml"
roles:
- { role: inventory, when: "action is undefined or ( action != 'local' and 'delete' not in action )" }
- { role: inventory-keys, when: "action is undefined or ( action != 'skip_setup' and 'delete' not in action )" }
- { role: inventory-instance, when: "action is undefined or ( action != 'skip_setup' and 'delete' not in action )" }
- name: "____________________ Meta-roles local preparation _____________________"
connection: local
hosts: localhost
vars:
master_role: "{{ role }}"
playbook_name: "{{ role }}-ansible"
vars_files:
- config/openstack-config.yaml
- "roles/{{ role }}/defaults/main.yaml"
roles:
- { role: inventory, when: "( ( private_node_number | int ) > 0 ) and ( action is undefined or ( action != 'skip_setup' and 'delete' not in action ) )" }
- { role: meta-bastion, when: "( ( private_node_number | int ) > 0 ) and ( action is undefined or ( action != 'skip_setup' and 'delete' not in action ) )" }
- { role: meta-router, when: "( ( private_node_number | int ) > 0 ) and ( action is undefined or ( action != 'skip_setup' and 'delete' not in action ) )" }
- name: "____________________ Meta-roles remote execution ______________________"
hosts: "{{ master_role }}"
vars:
master_role: "{{ role }}"
playbook_name: "{{ role }}-ansible"
vars_files:
- config/openstack-config.yaml
- "roles/{{ role }}/defaults/main.yaml"
roles:
- { role: inventory, when: "( ( private_node_number | int ) > 0 ) and ( action is undefined or ( action != 'skip_setup' and 'delete' not in action ) )" }
- { role: meta-bastion, when: "( ( private_node_number | int ) > 0 ) and ( action is undefined or ( action != 'skip_setup' and 'delete' not in action ) )" }
- { role: meta-router, when: "( ( private_node_number | int ) > 0 ) and ( action is undefined or ( action != 'skip_setup' and 'delete' not in action ) )" }
- name: "______________________ {{ role }} role execution ______________________"
hosts: "{{ master_role }}"
vars:
master_role: "{{ role }}"
playbook_name: "{{ role }}-ansible"
vars_files:
- config/openstack-config.yaml
roles:
- inventory
- "{{ role }}"