This repository has been archived by the owner on Dec 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathprovyfile.py
93 lines (77 loc) · 2.11 KB
/
provyfile.py
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
from provy.core import Role, AskFor
provisions = []
cleanups = []
contexts = {}
class Role1(Role):
def provision(self):
provisions.append(self.__class__)
contexts[self.__class__] = self.context
self.context['cleanup'].extend([
Role2(self.prov, self.context),
Role3(self.prov, self.context),
])
def cleanup(self):
super(Role1, self).cleanup()
cleanups.append(self.__class__)
class Role2(Role):
def provision(self):
provisions.append(self.__class__)
contexts[self.__class__] = self.context
def cleanup(self):
super(Role2, self).cleanup()
cleanups.append(self.__class__)
class Role3(Role):
def provision(self):
provisions.append(self.__class__)
contexts[self.__class__] = self.context
def cleanup(self):
super(Role3, self).cleanup()
cleanups.append(self.__class__)
class Role4(Role):
def provision(self):
provisions.append(self.__class__)
contexts[self.__class__] = self.context
def cleanup(self):
super(Role4, self).cleanup()
cleanups.append(self.__class__)
servers = {
'test': {
'role1': {
'address': '33.33.33.33',
'user': 'vagrant',
'roles': [
Role1,
],
'options': {
'foo': 'FOO',
'password': AskFor('password', 'Provide a password'),
'another-password': AskFor('another-password', 'Provide another password'),
},
'ssh_key': '/some/key.pub',
},
'roles2and3': {
'address': '33.33.33.34',
'user': 'vagrant',
'roles': [
Role2,
Role3,
],
'options': {
'bar': 'BAR',
'baz': 'BAZ',
},
},
},
'test2': {
'address': '33.33.33.35',
'user': 'vagrant',
'roles': [
Role4,
],
'options': {
'foo': 'FOO',
},
},
}