bugfix: opencontrail add force parameter for apt-get install 45/5345/4
authorchenshuai@huawei.com <chenshuai@huawei.com>
Tue, 29 Dec 2015 09:27:25 +0000 (17:27 +0800)
committerchenshuai@huawei.com <chenshuai@huawei.com>
Thu, 31 Dec 2015 01:28:36 +0000 (09:28 +0800)
JIRA: COMPASS-227

Change-Id: I4e9ae9dfed29f6d58c9200d21f09cf2a71961ca1
Signed-off-by: chenshuai@huawei.com <chenshuai@huawei.com>
29 files changed:
deploy/adapters/ansible/roles/open-contrail/1 [new file with mode: 0644]
deploy/adapters/ansible/roles/open-contrail/tasks/install/install-collector.yml
deploy/adapters/ansible/roles/open-contrail/tasks/install/install-common.yml
deploy/adapters/ansible/roles/open-contrail/tasks/install/install-compute.yml
deploy/adapters/ansible/roles/open-contrail/tasks/install/install-config.yml
deploy/adapters/ansible/roles/open-contrail/tasks/install/install-control.yml
deploy/adapters/ansible/roles/open-contrail/tasks/install/install-database.yml
deploy/adapters/ansible/roles/open-contrail/tasks/install/install-kernel.yml
deploy/adapters/ansible/roles/open-contrail/tasks/install/install-webui.yml
deploy/adapters/ansible/roles/open-contrail/tasks/provision/-vrouter-compute-setup.yml
deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-control.yml
deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-database.yml
deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-rabbitmq.yml
deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-toragent.yml
deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-webui.yml
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-analytics-api-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-api-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-collector-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-device-manager-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-discovery-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-dns-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-query-engine-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-schema-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-svc-monitor-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/contrail-tor-agent-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/haproxy-contrail-cfg.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-env-conf.j2
deploy/adapters/ansible/roles/open-contrail/templates/provision/vrouter-nodemgr-param.j2
deploy/adapters/ansible/roles/open-contrail/vars/main.yml

diff --git a/deploy/adapters/ansible/roles/open-contrail/1 b/deploy/adapters/ansible/roles/open-contrail/1
new file mode 100644 (file)
index 0000000..70159af
--- /dev/null
@@ -0,0 +1,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"
index 5dbf924..cac370e 100755 (executable)
@@ -12,5 +12,5 @@
 - name: "install contrail openstack analytics package"
 #   apt:
 #   name: "contrail-openstack-analytics"
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
   with_items: collector_packages
index 3a57fdf..e963e16 100755 (executable)
@@ -20,6 +20,7 @@
 #  sudo: True
   apt:
     deb: "/tmp/{{ package }}"
+    force: yes
 
 - name: "delete temporary contrail install package"
 #  sudo: True
@@ -56,6 +57,7 @@
 #  sudo: True
   apt:
     deb: "{{ item }}"
+    force: yes
   with_items: required_packages.stdout_lines
   ignore_errors: True
 
@@ -91,3 +93,4 @@
   apt:
     name: "contrail-setup"
     update_cache: yes
+    force: yes
index 6c85ce5..3703522 100755 (executable)
@@ -18,7 +18,7 @@
 #        name: "contrail-vrouter-3.13.0-40-generic"
 #      when: ansible_kernel == "3.13.0-40-generic"
 #  sudo: True
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
   with_items: vrouter_packages
   when: ansible_kernel == kernel_required
 
@@ -27,7 +27,7 @@
 #        name: "contrail-vrouter-dkms"
 #      when: ansible_kernel != "3.13.0-40-generic"
 #  sudo: True
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
   with_items: dkms_packages
   when: ansible_kernel != kernel_required
 
index 1d493f5..e8d4f04 100755 (executable)
@@ -20,5 +20,5 @@
 #  sudo: True
 #      apt:
 #        name: "contrail-openstack-config"
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
   with_items: config_packages
index 7e917d1..a1f5307 100755 (executable)
@@ -20,5 +20,5 @@
 #  sudo: True
 #      apt:
 #        name: "contrail-openstack-control"
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
   with_items: control_packages
index 68c5946..364fc8e 100755 (executable)
@@ -13,5 +13,5 @@
 #  sudo: True
 #      apt:
 #        name: "contrail-openstack-database"
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
   with_items: database_packages 
index 8b0e334..f1ccfed 100755 (executable)
@@ -11,7 +11,7 @@
 #        name: "linux-image-3.13.0-40-generic"
 #        name: "linux-image-extra-3.13.0-40-generic"
 #      when: (kernel_install) and (ansible_kernel != "3.13.0-40-generic")
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
   with_items: kernel_packages | union(kernel_packages_noarch)
   when: (kernel_install) and (ansible_kernel != kernel_required)
 
index 22156ca..727c494 100755 (executable)
@@ -14,5 +14,5 @@
 #  sudo: True
 #      apt:
 #        name: "contrail-openstack-webui"
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
   with_items: webui_packages
index 77ee20e..f53e38e 100755 (executable)
     - { section: "DEFAULT", option: "auth_strategy", value: "keystone" }
     - { section: "DEFAULT", option: "libvirt_nonblocking", value: "True" }
     - { section: "DEFAULT", option: "libvirt_inject_partition", value: "-1" }
-    - { section: "DEFAULT", option: "rabbit_host", value: "{{ hostvars[groups['config'][0]]['contrail_address'] }}" }
+    - { section: "DEFAULT", option: "rabbit_host", value: "{{ contrail_haproxy_address }}" }
     - { section: "DEFAULT", option: "rabbit_port", value: "5672" }
-    - { section: "DEFAULT", option: "glance_host", value: "{{ hostvars[groups['openstack'][0]]['contrail_address'] }}" }
+    - { section: "DEFAULT", option: "glance_host", value: "{{ contrail_haproxy_address }}" }
     - { section: "DEFAULT", option: "glance_port", value: "9292" }  
     - { section: "DEFAULT", option: "neutron_admin_tenant_name", value: "service" }
     - { section: "DEFAULT", option: "neutron_admin_username", value: "neutron" }
     - { section: "DEFAULT", option: "neutron_admin_password", value: "{{ contrail_admin_password }}" }
-    - { section: "DEFAULT", option: "neutron_admin_auth_url", value: "http://{{ hostvars[groups['openstack'][0]]['contrail_address'] }}:35357/v2.0/" }
-    - { section: "DEFAULT", option: "neutron_url", value: "http://{{ hostvars[groups['config'][0]]['contrail_address'] }}:9696/" }
+    - { section: "DEFAULT", option: "neutron_admin_auth_url", value: "http://{{ contrail_haproxy_address }}:35357/v2.0/" }
+    - { section: "DEFAULT", option: "neutron_url", value: "http://{{ contrail_haproxy_address }}:9696/" }
     - { section: "DEFAULT", option: "neutron_url_timeout", value: "300" }
     - { section: "DEFAULT", option: "network_api_class", value: "nova.network.neutronv2.api.API" }
     - { section: "DEFAULT", option: "compute_driver", value: "libvirt.LibvirtDriver" }
     - { section: "DEFAULT", option: "network_api_class", value: " nova_contrail_vif.contrailvif.ContrailNetworkAPI" }
     - { section: "DEFAULT", option: "ec2_private_dns_show_ip", value: "False" }
-    - { section: "DEFAULT", option: "novncproxy_base_url", value: "http://{{ hostvars[groups['openstack'][0]]['contrail_mgmt_address'] }}:5999/vnc_auto.html" }
+    - { section: "DEFAULT", option: "novncproxy_base_url", value: "http://{{ contrail_haproxy_address }}:5999/vnc_auto.html" }
     - { section: "DEFAULT", option: "vncserver_enabled", value: "True" }
     - { section: "DEFAULT", option: "vncserver_listen", value: "{{ contrail_address }}" }
     - { section: "DEFAULT", option: "vncserver_proxyclient_address", value: "{{ contrail_address }}" }
     - { section: "DEFAULT", option: "image_cache_manager_interval", value: "0" }
     - { section: "DEFAULT", option: "libvirt_cpu_mode", value: "none" }
     - { section: "DEFAULT", option: "libvirt_vif_driver", value: "nova_contrail_vif.contrailvif.VRouterVIFDriver" }
-    - { section: "database", option: "connection", value: "mysql://nova:nova@{{ hostvars[groups['openstack'][0]]['contrail_address'] }}/nova?charset=utf8" }
+    - { section: "database", option: "connection", value: "mysql://nova:nova@{{ contrail_haproxy_address }}/nova?charset=utf8" }
     - { section: "database", option: "idle_timeout", value: "180" }
     - { section: "database", option: "max_retries", value: "-1" }
     - { section: "keystone_authtoken", option: "admin_tenant_name", value: "service" }
     - { section: "keystone_authtoken", option: "admin_user", value: "nova" }
     - { section: "keystone_authtoken", option: "admin_password", value: "{{ contrail_admin_password }}" }
     - { section: "keystone_authtoken", option: "auth_protocol", value: "http" }
-    - { section: "keystone_authtoken", option: "auth_host", value: "{{ hostvars[groups['openstack'][0]]['contrail_address'] }}" }
+    - { section: "keystone_authtoken", option: "auth_host", value: "{{ contrail_haproxy_address }}" }
     - { section: "keystone_authtoken", option: "signing_dir", value: "/tmp/keystone-signing-nova" }
 
+
+
+#- { section: "DEFAULT", option: "rabbit_host", value: "{{ hostvars[groups['config'][0]]['contrail_address'] }}" }
+#- { section: "DEFAULT", option: "glance_host", value: "{{ hostvars[groups['openstack'][0]]['contrail_address'] }}" }
+#- { section: "DEFAULT", option: "neutron_admin_auth_url", value: "http://{{ hostvars[groups['openstack'][0]]['contrail_address'] }}:35357/v2.0/" }
+#- { section: "DEFAULT", option: "neutron_url", value: "http://{{ hostvars[groups['config'][0]]['contrail_address'] }}:9696/" }
+#- { section: "DEFAULT", option: "novncproxy_base_url", value: "http://{{ hostvars[groups['openstack'][0]]['contrail_mgmt_address'] }}:5999/vnc_auto.html" }
+#- { section: "database", option: "connection", value: "mysql://nova:nova@{{ hostvars[groups['openstack'][0]]['contrail_address'] }}/nova?charset=utf8" }
+#- { section: "keystone_authtoken", option: "auth_host", value: "{{ hostvars[groups['openstack'][0]]['contrail_address'] }}" }
+
+
+
 - name: "change database address if same node as first openstack node"
   ini_file:
     dest: "/etc/nova/nova.conf"
index 1a5ddf7..3da783e 100755 (executable)
   lineinfile:
     dest: "/etc/ifmap-server/basicauthusers.properties"
 #    line: "{{ hostvars[item]['contrail_address' ] }}:{{ hostvars[item]['contrail_address' ] }}"
-    line: "{{ contrail_address }}:{{ contrail_address }}"
+    line: "{{ haproxy_hosts[item] }}:{{ haproxy_hosts[item] }}"
   with_items: groups['opencontrail_control']
 
 - name: "modify ifmap server basicauthusers properties for dns"
   lineinfile:
     dest: "/etc/ifmap-server/basicauthusers.properties"
 #    line: "{{ hostvars[item]['contrail_address' ] }}.dns:{{ hostvars[item]['contrail_address' ] }}.dns"
-    line: "{{ contrail_address }}.dns:{{ contrail_address }}.dns"
+    line: "{{ haproxy_hosts[item] }}.dns:{{ haproxy_hosts[item] }}.dns"
   with_items: groups['opencontrail_control']
 
 - name: "node-common"
index f95e7fe..04a1c99 100755 (executable)
 #  sudo: True
   lineinfile:
     dest: "/etc/hosts"
-    regexp: "^{{ contrail_address }}\t{{ ansible_hostname }}( .*)?$"
-    line: "{{ contrail_address }}\t{{ ansible_hostname }}\\1"
+#    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
 
 
@@ -51,7 +53,7 @@
 #  sudo: True
   set_fact:
 #    dbseeds: "{{ hostvars[item.1][ contrail_address ] }}"
-     dbseeds: "{{ contrail_address }}"
+     dbseeds: "{{ haproxy_hosts[item] }}"
   with_indexed_items: groups['opencontrail_database']
   when: item.0 == 0
 
@@ -63,7 +65,7 @@
 #  sudo: True
   set_fact:
 #    dbseeds: "{{ dbseeds }},{{ hostvars[item.1]['contrail_address'] }}"
-    dbseeds: "{{ dbseeds }},{{ contrail_address }}"
+    dbseeds: "{{ dbseeds }},{{ haproxy_hosts[item] }}"
   with_indexed_items: groups['opencontrail_database']
   when: item.0 == 1
 
     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 }}={{ contrail_address }}:2888:3888"
+    line: "server.{{ item.0 + 1 }}={{ haproxy_hosts[item] }}:2888:3888"
   with_indexed_items: groups['opencontrail_database']
 
 
 #  sudo: True
   set_fact:
 #    zkaddrs: "{{ hostvars[item.1]['contrail_address'] }}:2181"
-    zkaddrs: "{{ contrail_address }}:2181"
+    zkaddrs: "{{ haproxy_hosts[item] }}:2181"
   with_indexed_items: groups['opencontrail_database']
   when: item.0 == 0
 
 #  sudo: True
   set_fact:
 #    zkaddrs: "{{ zkaddrs }},{{ hostvars[item.1]['contrail_address'] }}:2181"
-    zkaddrs: "{{ zkaddrs }},{{ contrail_address }}:2181"
+    zkaddrs: "{{ zkaddrs }},{{ haproxy_hosts[item] }}:2181"
   with_indexed_items: groups['opencontrail_database']
   when: item.0 > 0
 
index b2785d8..58037bc 100755 (executable)
@@ -29,7 +29,8 @@
 #  sudo: True
   lineinfile:
     dest: "/etc/hosts"
-    line: "{{ hostvars[item]['contrail_address'] }}\t{{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'] }}-ctrl"
+#    line: "{{ hostvars[item]['contrail_address'] }}\t{{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'] }}-ctrl"
+    line: "{{ contrail_address }}\t{{ inventory_hostname }} {{ inventory_hostname }}-ctrl"
   with_items: groups['opencontrail_config']
 
 
index 8781073..78b01e3 100755 (executable)
@@ -69,9 +69,9 @@
   run_once: yes
 
 - name: "add tor agent to contrail"
-  shell: "python /opt/contrail/utils/provision_vrouter.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --openstack_ip {{ contrail_keystone_address }} --oper add --host_name {{ ansible_hostname }}-{{ item.ansible_facts.toragent_index }} --host_ip {{ contrail_address }} --router_type tor-agent"
+  shell: "python /opt/contrail/utils/provision_vrouter.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --openstack_ip {{ contrail_keystone_address }} --oper add --host_name {{ inventory_hostname }}-{{ item.ansible_facts.toragent_index }} --host_ip {{ contrail_address }} --router_type tor-agent"
   with_items: contrail_toragent_list.results
 
 - name: "add device to contrail"
-  shell: "python /opt/contrail/utils/provision_physical_device.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --openstack_ip {{ contrail_keystone_address }} --oper add --device_name {{ item.ansible_facts.toragent_params.name }} --vendor_name {{ item.ansible_facts.toragent_params.vendor_name }} --product_name {{ item.ansible_facts.toragent_params.product_name }} --device_mgmt_ip {{ item.ansible_facts.toragent_params.address }} --device_tunnel_ip {{ item.ansible_facts.toragent_params.tunnel_address }} --device_tor_agent {{ ansible_hostname }}-{{ item.ansible_facts.toragent_index }} --device_tsn {{ ansible_hostname }}"
+  shell: "python /opt/contrail/utils/provision_physical_device.py --api_server_ip {{ contrail_haproxy_address }} --admin_user {{ contrail_admin_user }} --admin_password {{ contrail_admin_password }} --admin_tenant_name admin --openstack_ip {{ contrail_keystone_address }} --oper add --device_name {{ item.ansible_facts.toragent_params.name }} --vendor_name {{ item.ansible_facts.toragent_params.vendor_name }} --product_name {{ item.ansible_facts.toragent_params.product_name }} --device_mgmt_ip {{ item.ansible_facts.toragent_params.address }} --device_tunnel_ip {{ item.ansible_facts.toragent_params.tunnel_address }} --device_tor_agent {{ inventory_hostname }}-{{ item.ansible_facts.toragent_index }} --device_tsn {{ inventory_hostname }}"
   with_items: contrail_toragent_list.results
index 1090dda..515b10e 100755 (executable)
 - name: "set first cassandra host address"
   set_fact:
 #    cassandra_addrs: "'{{ hostvars[item.1]['contrail_address'] }}'"
-    cassandra_addrs: "'{{ contrail_address }}'"
+    cassandra_addrs: "'{{ haproxy_hosts[item]  }}'"
   with_indexed_items: groups['opencontrail_database']
   when: item.0 == 0
 
 - name: "set second or more cassandra host addresses"
   set_fact:
 #    cassandra_addrs: "{{ cassandra_addrs }}, '{{ hostvars[item.1]['contrail_address'] }}'"
-    cassandra_addrs: "{{ cassandra_addrs }}, '{{ contrail_address }}'"
+    cassandra_addrs: "{{ cassandra_addrs }}, '{{ haproxy_hosts[item] }}'"
   with_indexed_items: groups['opencontrail_database']
   when: item.0 > 0
 
index f558634..6e2bcce 100755 (executable)
@@ -1,8 +1,10 @@
 [DEFAULTS]
 host_ip = {{ contrail_address }}
-rest_api_ip = 0.0.0.0
+rest_api_ip = {{ contrail_haproxy_address }}
 rest_api_port = 9081
-cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+#cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+#chenshuai: This kind of written is also correct, but the following is better, this as record
+cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
 
 collectors = {{ contrail_address }}:8086
 http_server_port = 8090
index cb74763..e4acf3e 100755 (executable)
@@ -1,13 +1,13 @@
 [DEFAULTS]
-listen_ip_addr = 0.0.0.0
+listen_ip_addr = {{ contrail_haproxy_address }}
 listen_port = 8082
-ifmap_server_ip = {{ contrail_address }}
+ifmap_server_ip = {{ contrail_haproxy_address }}
 ifmap_server_port = 8443
 ifmap_username = api-server
 ifmap_password = api-server
-zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:2181{% if not loop.last %}, {% endif %}{% endfor %}
+zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %}
 
-cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
 
 disc_server_ip = {{ contrail_haproxy_address }}
 disc_server_port = 5998
index ea84388..da5cf2a 100755 (executable)
@@ -13,7 +13,7 @@ analytics_flow_ttl = -1
 
 # IP address and port to be used to connect to cassandra.
 # Multiple IP:port strings separated by space can be provided
-cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
 
 
 # IP address and port to be used to connect to kafka.
index 24575aa..7ab29f6 100755 (executable)
@@ -1,9 +1,9 @@
 [DEFAULTS]
 api_server_ip = {{ contrail_haproxy_address }}
 api_server_port = 8082
-zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:2181{% if not loop.last %}, {% endif %}{% endfor %}
+zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %}
 
-cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
 
 disc_server_ip = {{ contrail_haproxy_address }}
 disc_server_port = 5998
index 6abcb59..509b356 100755 (executable)
@@ -1,10 +1,10 @@
 [DEFAULTS]
-listen_ip_addr = 0.0.0.0
+listen_ip_addr = {{ contrail_haproxy_address }}
 listen_port = 5998
-zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}{% if not loop.last %}, {% endif %}{% endfor %}
+zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}{% if not loop.last %}, {% endif %}{% endfor %}
 
 zk_server_port = 2181
-cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
 
 log_file = /var/log/contrail/contrail-discovery.log
 log_level = SYS_NOTICE
index 0a2ab43..9d41556 100755 (executable)
@@ -1,6 +1,6 @@
 [DEFAULT]
 hostip = {{ contrail_address }}
-hostname = {{ ansible_hostname }}
+hostname = {{ inventory_hostname }}
 log_file = /var/log/contrail/contrail-dns.log
 log_level = SYS_NOTICE
 log_local = 1
index a9f7c28..7564d26 100755 (executable)
@@ -1,8 +1,9 @@
 [DEFAULT]
 hostip = {{ contrail_address }}
-cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+#cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ ip_settings[cur_host]['mgmt']['ip'] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
 
-collectors = {{ contrail_address }}:8086
+collectors = {{ contrail_haproxy_address }}:8086
 http_server_port = 8091
 log_file = /var/log/contrail/contrail-query-engine.log
 log_level = SYS_NOTICE
index f394948..cf5dead 100755 (executable)
@@ -1,13 +1,15 @@
 [DEFAULTS]
-ifmap_server_ip = {{ ip_settings[haproxy_hosts.keys()[0]]['mgmt']['ip'] }}
+#ifmap_server_ip = {{ ip_settings[haproxy_hosts.keys()[0]]['mgmt']['ip'] }}
+ifmap_server_ip = {{ haproxy_hosts.values()[0] }}
 ifmap_server_port = 8443
 ifmap_username = schema-transformer
 ifmap_password = schema-transformer
-api_server_ip = {{ ip_settings[haproxy_hosts.keys()[0]]['mgmt']['ip'] }}
+#api_server_ip = {{ ip_settings[haproxy_hosts.keys()[0]]['mgmt']['ip'] }}
+api_server_ip = {{ haproxy_hosts.values()[0] }}
 api_server_port = 8082
-zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:2181{% if not loop.last %}, {% endif %}{% endfor %}
+zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host]  }}:2181{% if not loop.last %}, {% endif %}{% endfor %}
 
-cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
 
 disc_server_ip = {{ contrail_haproxy_address }}
 disc_server_port = 5998
index 070a60c..6ad5ec2 100755 (executable)
@@ -1,13 +1,13 @@
 [DEFAULTS]
-ifmap_server_ip = {{ contrail_address }}
+ifmap_server_ip = {{ contrail_haproxy_address }}
 ifmap_server_port = 8443
 ifmap_username = svc-monitor
 ifmap_password = svc-monitor
 api_server_ip = {{ contrail_haproxy_address }}
 api_server_port = 8082
-zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:2181{% if not loop.last %}, {% endif %}{% endfor %}
+zk_server_ip = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:2181{% if not loop.last %}, {% endif %}{% endfor %}
 
-cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9160{% if not loop.last %} {% endif %}{% endfor %}
+cassandra_server_list = {% for cur_host in groups['opencontrail_database'] %}{{ haproxy_hosts[cur_host] }}:9160{% if not loop.last %} {% endif %}{% endfor %}
 
 disc_server_ip = {{ contrail_haproxy_address }}
 disc_server_port = 5998
index fb483c3..8d336e5 100755 (executable)
@@ -78,7 +78,7 @@ server = {{ contrail_haproxy_address }}
 [NETWORKS]
 # control-channel IP address used by WEB-UI to connect to vnswad to fetch
 # required information (Optional)
-control_network_ip = {{ contrail_address }}
+control_network_ip = {{ contrail_haproxy_address }}
 
 [TOR]
 # IP address of the TOR to manage
index e99917b..d7691b6 100755 (executable)
@@ -1,57 +1,78 @@
 #contrail-marker-start
 
 listen contrail-stats
-       bind *:5937
+#      bind *:5937
+        bind {{ internal_vip.ip }}:5937
+        bind {{ public_vip.ip }}:5937
        mode http
        stats enable
        stats uri /
        stats auth haproxy:contrail123
 
-listen neutron-server
-       bind *:9696
-       balance roundrobin
-       option nolinger
-{% for cur_host in groups['opencontrail_config'] %}    server {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }} {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9697 check inter 2000 rise 2 fall 3
-{% endfor %}
+# compass has bind neutron-server
+#listen neutron-server
+#      bind *:9696
+#      balance roundrobin
+#      option nolinger
+#{% for host,ip in haproxy_hosts.items() %}
+#    server {{ host }} {{ ip }}:9697 weight 1 check inter 2000 rise 2 fall 3
+#{% endfor %}
+
+
 
 listen contrail-api
-       bind *:8082
+#      bind *:8082
+        bind {{ internal_vip.ip }}:8082
+        bind {{ public_vip.ip }}:8082
        balance roundrobin
        option nolinger
        timeout client 3m
        timeout server 3m
-{% for cur_host in groups['opencontrail_config'] %}    server {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }} {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9100 check inter 2000 rise 2 fall 3
+{% for host,ip in haproxy_hosts.items() %}
+    server {{ host }} {{ ip }}:9100 weight 1 check inter 2000 rise 2 fall 3
 {% endfor %}
 
+
+
 listen contrail-discovery
-       bind *:5998
+#      bind *:5998
+        bind {{ internal_vip.ip }}:5998
+        bind {{ public_vip.ip }}:5998
        balance roundrobin
        option nolinger
-{% for cur_host in groups['opencontrail_config'] %}    server {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }} {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9110 check inter 2000 rise 2 fall 3
+{% for host,ip in haproxy_hosts.items() %}
+    server {{ host }} {{ ip }}:9110 weight 1 check inter 2000 rise 2 fall 3
 {% endfor %}
 
+
+
 listen contrail-analytics-api
-       bind *:8081
+#      bind *:8081
+        bind {{ internal_vip.ip }}:8081
+        bind {{ public_vip.ip }}:8081
        balance roundrobin
        option nolinger
        option tcp-check
        tcp-check connect port 6379
        default-server error-limit 1 on-error mark-down
-{% for cur_host in groups['opencontrail_collector'] %} server {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }} {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:9081 check inter 2000 rise 2 fall 3
+{% for host,ip in haproxy_hosts.items() %}
+    server {{ host }} {{ ip }}:9081 weight 1 check inter 2000 rise 2 fall 5
 {% endfor %}
 
 
-listen rabbitmq
-       bind *:5673
-       mode tcp
-       balance roundrobin
-       maxconn 10000
-       option tcplog
-       option tcpka
-       option redispatch
-       timeout client 48h
-       timeout server 48h
-{% for cur_host in groups['opencontrail_config'] %}    server {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }} {{ hostvars[cur_host]['ansible_' + internal_nic].ipv4.address }}:5672 check inter 2000 rise 2 fall 3 weight 1 maxconn 500
+# compass doesn't use ha for rabbitmq, but use cluster mode
+#listen rabbitmq
+#      bind *:5673
+#      mode tcp
+#      balance roundrobin
+#      maxconn 10000
+#      option tcplog
+#      option tcpka
+#      option redispatch
+#      timeout client 48h
+#      timeout server 48h
+{% for host,ip in haproxy_hosts.items() %}
+    server {{ host }} {{ ip }}:5672 weight 1 check inter 2000 rise 2 fall 5
 {% endfor %}
 
 #contrail-marker-end
index a4e35d6..c81b07d 100755 (executable)
@@ -1 +1,2 @@
-DISCOVERY={{ ip_settings[haproxy_hosts.keys()[0]]['mgmt']['ip'] }}
\ No newline at end of file
+#DISCOVERY={{ ip_settings[haproxy_hosts.keys()[0]]['mgmt']['ip'] }}
+DISCOVERY={{ haproxy_hosts.value()[0] }}
index 22b3c82..0f47bd7 100755 (executable)
@@ -5,8 +5,19 @@ kernel_install: no
 #ansible_ssh_pass: "root"
 
 contrail_keystone_address: "{{ internal_vip.ip }}"
-contrail_admin_user: "keystone"
-contrail_admin_password: "service"
+contrail_admin_user: "admin"
+contrail_admin_password: "console"
+
+
+# network infor adapter for compass
+contrail_device: "mgmt"
+contrail_address: "{{ internal_ip }}"
+contrail_netmask: "255.255.255.0"
+#contrail_gateway: "10.84.50.254"
+contrail_gateway:
+#contrail_mgmt_address: "172.27.113.91"
+
+
 
 contrail_keepalived: no 
 #contrail_haproxy_address: "10.0.0.22" # 10.0.0.80
@@ -20,7 +31,7 @@ contrail_router_asn: "64512"
 ### Modify when need openstack provisioning
 keystone_provision: no
 install_nova: no
-rabbit_password: "password"
+rabbit_password: "console"
 
 contrail_tor_agents:
   - name: "test01"