aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/open-contrail/1
blob: 70159aff6453564baf9b7fc5a4353563794990ea (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
---
#- hosts: database
#  sudo: yes
#  tasks:


- name: "enable supervisor database"
#  sudo: True
  file:
    path: "/etc/init/supervisor-database.override"
    state: "absent"


- name: "-node-common"
#  sudo: True
  include: -node-common.yml


- name: "update hosts"
#  sudo: True
  lineinfile:
    dest: "/etc/hosts"
#    regexp: "^{{ contrail_address }}\t{{ ansible_hostname }}( .*)?$"
#    line: "{{ contrail_address }}\t{{ ansible_hostname }}\\1"
    regexp: "^{{ contrail_address }}\t{{ inventory_hostname }}( .*)?$"
    line: "{{ contrail_address }}\t{{ inventory_hostname }}\\1"
    backrefs: yes


- name: "make directory for contrail analytics"
#  sudo: True
  file:
    path: "/var/lib/cassandra/data/ContrailAnalytics"
    state: "directory"


- name: "modify cassandra conf"
#  sudo: True
  lineinfile:
    dest: "/etc/cassandra/cassandra.yaml"
    regexp: "{{ item.regexp }}"
    line: "{{ item.line }}"
  with_items:
    - { regexp: "^(#(\\s*)?)?listen_address:", line: "listen_address: {{ contrail_address }}"}
    - { regexp: "^(#(\\s*)?)?cluster_name:", line: "cluster_name: \"Contrail\"" }
    - { regexp: "^(#(\\s*)?)?rpc_address:", line: "rpc_address: {{ contrail_address }}" }
    - { regexp: "^(#(\\s*)?)?num_tokens:", line: "num_tokens: 256" }
    - { regexp: "^(#(\\s*)?)?initial_token:", line: "# initial_token:" }



- name: "set first database host seed"
#  sudo: True
  set_fact:
#    dbseeds: "{{ hostvars[item.1][ contrail_address ] }}"
     dbseeds: "{{ haproxy_hosts.values()[0] }}"
  with_indexed_items: groups['opencontrail_database']
  when: item.0 == 0





- name: "set second database host seed"
#  sudo: True
  set_fact:
#    dbseeds: "{{ dbseeds }},{{ hostvars[item.1]['contrail_address'] }}"
    dbseeds: "{{ dbseeds }},{{ haproxy_hosts.values()[0] }}"
  with_indexed_items: groups['opencontrail_database']
  when: item.0 == 1


- name: "modify seeds list in cassandra conf"
#  sudo: True
  replace:
    dest: "/etc/cassandra/cassandra.yaml"
    regexp: "- seeds:.*$"
    replace: "- seeds: {{ dbseeds }}"


- name: "modify cassandra env"
#  sudo: True
  replace:
    dest: "/etc/cassandra/cassandra-env.sh"
    regexp: "{{ item.regexp }}"
    replace: "{{ item.replace }}"
  with_items:
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -XX:\\+PrintGCDetails\"", replace: "JVM_OPTS=\"$JVM_OPTS -XX:+PrintGCDetails\"" }
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -Xss\\d+k\"", replace: "JVM_OPTS=\"$JVM_OPTS -Xss512k\"" }
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -XX:\\+PrintGCDateStamps\"", replace: "JVM_OPTS=\"$JVM_OPTS -XX:+PrintGCDateStamps\"" }
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -XX:\\+PrintHeapAtGC\"", replace: "JVM_OPTS=\"$JVM_OPTS -XX:+PrintHeapAtGC\"" }
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -XX:\\+PrintTenuringDistribution\"", replace: "JVM_OPTS=\"$JVM_OPTS -XX:+PrintTenuringDistribution\"" }
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -XX:\\+PrintGCApplicationStoppedTime\"", replace: "JVM_OPTS=\"$JVM_OPTS -XX:+PrintGCApplicationStoppedTime\"" }
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -XX:\\+PrintPromotionFailure\"", replace: "JVM_OPTS=\"$JVM_OPTS -XX:+PrintPromotionFailure\"" }
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -XX:PrintFLSStatistics=1\"", replace: "JVM_OPTS=\"$JVM_OPTS -XX:PrintFLSStatistics=1\"" }
    - { regexp: "(#(\\s*)?)?JVM_OPTS=\"\\$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date \\+%s`\\.log\"", replace: "JVM_OPTS=\"$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log\"" }


- name: "modify zookeeper conf"
#  sudo: True
  lineinfile:
    dest: "/etc/zookeeper/conf/zoo.cfg"
    line: "{{ item }}"
  with_items:
    - "maxSessionTimeout=120000"
    - "autopurge.purgeInterval=3"


- name: "modify zookeeper log4j properties"
#  sudo: True
  lineinfile:
    dest: "/etc/zookeeper/conf/log4j.properties"
    regexp: "(log4j.appender.ROLLINGFILE.MaxBackupIndex=.*)$"
    line: "\\1"
    backrefs: yes


- name: "add server addresses to zookeeper config"
#  sudo: True
  lineinfile:
    dest: "/etc/zookeeper/conf/zoo.cfg"
    regexp: "server.{{ item.0 + 1 }}="
#    line: "server.{{ item.0 + 1 }}={{ hostvars[item.1]['contrail_address'] }}:2888:3888"
    line: "server.{{ item.0 + 1 }}={{ haproxy_hosts.values()[0] }}:2888:3888"
  with_indexed_items: groups['opencontrail_database']


- name: "set zookeeper unique id"
#  sudo: True
  template:
    src: "../../templates/provision/zookeeper-unique-id.j2"
    dest: "/var/lib/zookeeper/myid"
  with_indexed_items: groups['opencontrail_database']
  when: item.1 == inventory_hostname


- name: "remove kafka ini file"
#  sudo: True
  file:
    path: "/etc/contrail/supervisord_database_files/kafka.ini"
    state: "absent"


- name: "set first zookeeper host address"
#  sudo: True
  set_fact:
#    zkaddrs: "{{ hostvars[item.1]['contrail_address'] }}:2181"
    zkaddrs: "{{ haproxy_hosts.values()[0] }}:2181"
  with_indexed_items: groups['opencontrail_database']
  when: item.0 == 0


- name: "set second or more zookeeper host addresses"
#  sudo: True
  set_fact:
#    zkaddrs: "{{ zkaddrs }},{{ hostvars[item.1]['contrail_address'] }}:2181"
    zkaddrs: "{{ zkaddrs }},{{ haproxy_hosts.values()[0] }}:2181"
  with_indexed_items: groups['opencontrail_database']
  when: item.0 > 0


- name: "modify zookeeper host addresses in kafka properties"
#  sudo: True
  lineinfile:
    dest: "/usr/share/kafka/config/server.properties"
    regexp: "zookeeper.connect="
    line: "zookeeper.connect={{ zkaddrs }}"


- name: "modify kafka properties"
#  sudo: True
  lineinfile:
    dest: "/usr/share/kafka/config/server.properties"
    regexp: "default.replication.factor="
    line: "default.replication.factor=2"


- name: "fix up contrail database nodemgr config"
#  sudo: True
  ini_file:
    dest: "/etc/contrail/contrail-database-nodemgr.conf"
    section: "{{ item.section }}"
    option: "{{ item.option }}"
    value: "{{ item.value }}"
  with_items:
    - { section: "DEFAULT", option: "hostip", value: "{{ contrail_address }}" }
    - { section: "DISCOVERY", option: "server", value: "{{ contrail_haproxy_address }}" }


- name: "restart zookeeper"
#  sudo: True
  service:
    name: "zookeeper"
    state: "restarted"


- name: "restart supervisor database"
#  sudo: True
  service:
    name: "supervisor-database"
    state: "restarted"