Authored by chunhua.zhang

按照key排序

@@ -4,9 +4,14 @@ @@ -4,9 +4,14 @@
4 4
5 5
6 6
7 -[java-wechat]  
8 -10.66.70.139  
9 -10.66.70.12 7 +[java-activity]
  8 +10.66.70.89
  9 +10.66.70.142
  10 +
  11 +
  12 +[java-brower]
  13 +10.66.70.223
  14 +10.66.70.42
10 15
11 16
12 [java-erpgateway] 17 [java-erpgateway]
@@ -14,17 +19,40 @@ @@ -14,17 +19,40 @@
14 10.66.50.113 19 10.66.50.113
15 20
16 21
17 -[java-promotion] 22 +[java-gateway]
  23 +10.66.70.22
  24 +10.66.70.204
  25 +10.66.0.240
  26 +10.66.0.4
  27 +10.66.0.5
  28 +
  29 +
  30 +[java-message]
  31 +10.66.70.100
  32 +10.66.70.109
  33 +
  34 +
  35 +[java-order]
18 10.66.70.41 36 10.66.70.41
19 10.66.70.170 37 10.66.70.170
20 38
21 39
22 -[java-sns] 40 +[java-product]
23 10.66.70.47 41 10.66.70.47
24 10.66.70.96 42 10.66.70.96
25 43
26 44
27 -[java-product] 45 +[java-promotion]
  46 +10.66.70.41
  47 +10.66.70.170
  48 +
  49 +
  50 +[java-resources]
  51 +10.66.70.9
  52 +10.66.70.128
  53 +
  54 +
  55 +[java-sns]
28 10.66.70.47 56 10.66.70.47
29 10.66.70.96 57 10.66.70.96
30 58
@@ -35,40 +63,12 @@ @@ -35,40 +63,12 @@
35 10.66.103.20 63 10.66.103.20
36 64
37 65
38 -[java-brower]  
39 -10.66.70.223  
40 -10.66.70.42  
41 -  
42 -  
43 -[java-message]  
44 -10.66.70.100  
45 -10.66.70.109  
46 -  
47 -  
48 -[java-order]  
49 -10.66.70.41  
50 -10.66.70.170  
51 -  
52 -  
53 -[java-gateway]  
54 -10.66.70.22  
55 -10.66.70.204  
56 -10.66.0.240  
57 -10.66.0.4  
58 -10.66.0.5  
59 -  
60 -  
61 [java-users] 66 [java-users]
62 10.66.70.9 67 10.66.70.9
63 10.66.70.128 68 10.66.70.128
64 69
65 70
66 -[java-resources]  
67 -10.66.70.9  
68 -10.66.70.128  
69 -  
70 -  
71 -[java-activity]  
72 -10.66.70.89  
73 -10.66.70.142 71 +[java-wechat]
  72 +10.66.70.139
  73 +10.66.70.12
74 74
@@ -4,19 +4,27 @@ @@ -4,19 +4,27 @@
4 4
5 5
6 6
7 -[java-promotion]  
8 -10.66.70.41  
9 -10.66.70.170 7 +[java-activity]
  8 +10.66.70.89
  9 +10.66.70.142
10 10
11 11
12 -[java-sns]  
13 -10.66.70.47  
14 -10.66.70.96 12 +[java-brower]
  13 +10.66.70.223
  14 +10.66.70.42
15 15
16 16
17 -[java-product]  
18 -10.66.70.47  
19 -10.66.70.96 17 +[java-erpgateway]
  18 +10.66.50.140
  19 +10.66.50.113
  20 +
  21 +
  22 +[java-gateway]
  23 +10.66.70.22
  24 +10.66.70.204
  25 +10.66.0.240
  26 +10.66.0.4
  27 +10.66.0.5
20 28
21 29
22 [java-message] 30 [java-message]
@@ -29,20 +37,38 @@ @@ -29,20 +37,38 @@
29 10.66.70.170 37 10.66.70.170
30 38
31 39
32 -[java-gateway]  
33 -10.66.70.22  
34 -10.66.70.204  
35 -10.66.0.240  
36 -10.66.0.4  
37 -10.66.0.5 40 +[java-product]
  41 +10.66.70.47
  42 +10.66.70.96
38 43
39 44
40 -[java-users] 45 +[java-promotion]
  46 +10.66.70.41
  47 +10.66.70.170
  48 +
  49 +
  50 +[java-resources]
41 10.66.70.9 51 10.66.70.9
42 10.66.70.128 52 10.66.70.128
43 53
44 54
45 -[java-resources] 55 +[java-sns]
  56 +10.66.70.47
  57 +10.66.70.96
  58 +
  59 +
  60 +[java-union]
  61 +10.66.70.21
  62 +10.66.70.49
  63 +10.66.103.20
  64 +
  65 +
  66 +[java-users]
46 10.66.70.9 67 10.66.70.9
47 10.66.70.128 68 10.66.70.128
48 69
  70 +
  71 +[java-wechat]
  72 +10.66.70.139
  73 +10.66.70.12
  74 +
  1 +[java-nginx]
  2 +10.66.104.15
  3 +10.66.104.13
  4 +
  5 +
  6 +
  7 +[java-activity]
  8 +10.66.104.17
  9 +10.66.104.26
  10 +
  11 +
  12 +[java-brower]
  13 +10.66.104.7
  14 +10.66.104.39
  15 +
  16 +
  17 +[java-erpgateway]
  18 +10.66.104.7
  19 +10.66.104.39
  20 +
  21 +
  22 +[java-gateway]
  23 +10.66.104.2
  24 +10.66.104.44
  25 +10.66.104.28
  26 +10.66.104.29
  27 +
  28 +
  29 +[java-message]
  30 +10.66.104.12
  31 +10.66.104.48
  32 +
  33 +
  34 +[java-order]
  35 +10.66.104.16
  36 +10.66.104.41
  37 +
  38 +
  39 +[java-product]
  40 +10.66.104.12
  41 +10.66.104.48
  42 +
  43 +
  44 +[java-promotion]
  45 +10.66.104.16
  46 +10.66.104.41
  47 +
  48 +
  49 +[java-resources]
  50 +10.66.104.10
  51 +10.66.104.43
  52 +
  53 +
  54 +[java-sns]
  55 +10.66.104.12
  56 +10.66.104.48
  57 +
  58 +
  59 +[java-union]
  60 +10.66.70.21
  61 +10.66.70.49
  62 +10.66.103.20
  63 +
  64 +
  65 +[java-users]
  66 +10.66.104.10
  67 +10.66.104.43
  68 +
  69 +
  70 +[java-wechat]
  71 +10.66.104.7
  72 +10.66.104.39
  73 +
@@ -4,7 +4,12 @@ @@ -4,7 +4,12 @@
4 4
5 5
6 6
7 -[java-wechat] 7 +[java-activity]
  8 +10.66.104.17
  9 +10.66.104.26
  10 +
  11 +
  12 +[java-brower]
8 10.66.104.7 13 10.66.104.7
9 10.66.104.39 14 10.66.104.39
10 15
@@ -14,47 +19,47 @@ @@ -14,47 +19,47 @@
14 10.66.104.39 19 10.66.104.39
15 20
16 21
17 -[java-promotion]  
18 -10.66.104.16  
19 -10.66.104.41 22 +[java-gateway]
  23 +10.66.104.2
  24 +10.66.104.44
  25 +10.66.104.28
  26 +10.66.104.29
20 27
21 28
22 -[java-sns] 29 +[java-message]
23 10.66.104.12 30 10.66.104.12
24 10.66.104.48 31 10.66.104.48
25 32
26 33
  34 +[java-order]
  35 +10.66.104.16
  36 +10.66.104.41
  37 +
  38 +
27 [java-product] 39 [java-product]
28 10.66.104.12 40 10.66.104.12
29 10.66.104.48 41 10.66.104.48
30 42
31 43
32 -[java-union]  
33 -10.66.70.21  
34 -10.66.70.49  
35 -10.66.103.20 44 +[java-promotion]
  45 +10.66.104.16
  46 +10.66.104.41
36 47
37 48
38 -[java-brower]  
39 -10.66.104.7  
40 -10.66.104.39 49 +[java-resources]
  50 +10.66.104.10
  51 +10.66.104.43
41 52
42 53
43 -[java-message] 54 +[java-sns]
44 10.66.104.12 55 10.66.104.12
45 10.66.104.48 56 10.66.104.48
46 57
47 58
48 -[java-order]  
49 -10.66.104.16  
50 -10.66.104.41  
51 -  
52 -  
53 -[java-gateway]  
54 -10.66.104.2  
55 -10.66.104.44  
56 -10.66.104.28  
57 -10.66.104.29 59 +[java-union]
  60 +10.66.70.21
  61 +10.66.70.49
  62 +10.66.103.20
58 63
59 64
60 [java-users] 65 [java-users]
@@ -62,12 +67,7 @@ @@ -62,12 +67,7 @@
62 10.66.104.43 67 10.66.104.43
63 68
64 69
65 -[java-resources]  
66 -10.66.104.10  
67 -10.66.104.43  
68 -  
69 -  
70 -[java-activity]  
71 -10.66.104.17  
72 -10.66.104.26 70 +[java-wechat]
  71 +10.66.104.7
  72 +10.66.104.39
73 73
@@ -3,7 +3,12 @@ @@ -3,7 +3,12 @@
3 10.66.202.12 3 10.66.202.12
4 4
5 5
6 -[java-wechat] 6 +[java-activity]
  7 +10.66.202.14
  8 +10.66.202.41
  9 +
  10 +
  11 +[java-brower]
7 10.66.202.7 12 10.66.202.7
8 10.66.202.32 13 10.66.202.32
9 14
@@ -13,46 +18,46 @@ @@ -13,46 +18,46 @@
13 10.66.202.32 18 10.66.202.32
14 19
15 20
16 -[java-promotion]  
17 -10.66.202.16  
18 -10.66.202.47 21 +[java-gateway]
  22 +10.66.202.13
  23 +10.66.202.15
  24 +10.66.202.8
19 25
20 26
21 -[java-sns] 27 +[java-message]
22 10.66.202.17 28 10.66.202.17
23 10.66.202.39 29 10.66.202.39
24 30
25 31
  32 +[java-order]
  33 +10.66.202.16
  34 +10.66.202.47
  35 +
  36 +
26 [java-product] 37 [java-product]
27 10.66.202.17 38 10.66.202.17
28 10.66.202.39 39 10.66.202.39
29 40
30 41
31 -[java-union]  
32 -10.66.70.21  
33 -10.66.70.49  
34 -10.66.103.20 42 +[java-promotion]
  43 +10.66.202.16
  44 +10.66.202.47
35 45
36 46
37 -[java-brower]  
38 -10.66.202.7  
39 -10.66.202.32 47 +[java-resources]
  48 +10.66.202.11
  49 +10.66.202.21
40 50
41 51
42 -[java-message] 52 +[java-sns]
43 10.66.202.17 53 10.66.202.17
44 10.66.202.39 54 10.66.202.39
45 55
46 56
47 -[java-order]  
48 -10.66.202.16  
49 -10.66.202.47  
50 -  
51 -  
52 -[java-gateway]  
53 -10.66.202.13  
54 -10.66.202.15  
55 -10.66.202.8 57 +[java-union]
  58 +10.66.70.21
  59 +10.66.70.49
  60 +10.66.103.20
56 61
57 62
58 [java-users] 63 [java-users]
@@ -60,12 +65,7 @@ @@ -60,12 +65,7 @@
60 10.66.202.21 65 10.66.202.21
61 66
62 67
63 -[java-resources]  
64 -10.66.202.11  
65 -10.66.202.21  
66 -  
67 -  
68 -[java-activity]  
69 -10.66.202.14  
70 -10.66.202.41 68 +[java-wechat]
  69 +10.66.202.7
  70 +10.66.202.32
71 71
@@ -3,19 +3,25 @@ @@ -3,19 +3,25 @@
3 10.66.202.12 3 10.66.202.12
4 4
5 5
6 -[java-promotion]  
7 -10.66.202.16  
8 -10.66.202.47 6 +[java-activity]
  7 +10.66.202.14
  8 +10.66.202.41
9 9
10 10
11 -[java-sns]  
12 -10.66.202.17  
13 -10.66.202.39 11 +[java-brower]
  12 +10.66.202.7
  13 +10.66.202.32
14 14
15 15
16 -[java-product]  
17 -10.66.202.17  
18 -10.66.202.39 16 +[java-erpgateway]
  17 +10.66.202.7
  18 +10.66.202.32
  19 +
  20 +
  21 +[java-gateway]
  22 +10.66.202.13
  23 +10.66.202.15
  24 +10.66.202.8
19 25
20 26
21 [java-message] 27 [java-message]
@@ -28,18 +34,38 @@ @@ -28,18 +34,38 @@
28 10.66.202.47 34 10.66.202.47
29 35
30 36
31 -[java-gateway]  
32 -10.66.202.13  
33 -10.66.202.15  
34 -10.66.202.8 37 +[java-product]
  38 +10.66.202.17
  39 +10.66.202.39
35 40
36 41
37 -[java-users] 42 +[java-promotion]
  43 +10.66.202.16
  44 +10.66.202.47
  45 +
  46 +
  47 +[java-resources]
38 10.66.202.11 48 10.66.202.11
39 10.66.202.21 49 10.66.202.21
40 50
41 51
42 -[java-resources] 52 +[java-sns]
  53 +10.66.202.17
  54 +10.66.202.39
  55 +
  56 +
  57 +[java-union]
  58 +10.66.70.21
  59 +10.66.70.49
  60 +10.66.103.20
  61 +
  62 +
  63 +[java-users]
43 10.66.202.11 64 10.66.202.11
44 10.66.202.21 65 10.66.202.21
45 66
  67 +
  68 +[java-wechat]
  69 +10.66.202.7
  70 +10.66.202.32
  71 +
@@ -73,8 +73,8 @@ for _az in azs_mappings.keys(): @@ -73,8 +73,8 @@ for _az in azs_mappings.keys():
73 call("mv %s %s" % (hosts, os.path.join("./inventories", az, "hosts.bak")), shell=True) 73 call("mv %s %s" % (hosts, os.path.join("./inventories", az, "hosts.bak")), shell=True)
74 file = open(hosts, 'w') 74 file = open(hosts, 'w')
75 75
76 - #write template  
77 - sorted_dict = collections.OrderedDict(sorted(all_groups[az].keys())) 76 + #write template, sort the dict by key
  77 + sorted_dict = collections.OrderedDict(sorted(all_groups[az].items(), key=lambda t: t[0]))
78 template = env.get_template('inventory-%s.j2' % az) 78 template = env.get_template('inventory-%s.j2' % az)
79 file.write(template.render(groups = sorted_dict )) 79 file.write(template.render(groups = sorted_dict ))
80 file.close() 80 file.close()