From: Dimitrios Markou Date: Thu, 17 Aug 2017 15:35:34 +0000 (+0300) Subject: Add clustering capabilities to Opendaylight role X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ca835bb5fe44340e6d5ab878d3f76e842aa2f4ab;p=integration%2Fpackaging%2Fansible-opendaylight.git Add clustering capabilities to Opendaylight role When the variable 'cluster' is true then the Opendaylight controller will be deployed in a clustering mode. Change-Id: I8a1085bae933ad07eab33fc677d199ef613bc040 Signed-off-by: Dimitrios Markou Signed-off-by: Daniel Farrell Signed-off-by: Periyasamy Palanisamy --- diff --git a/tasks/configure_cluster.yml b/tasks/configure_cluster.yml new file mode 100644 index 0000000..3f013c6 --- /dev/null +++ b/tasks/configure_cluster.yml @@ -0,0 +1,16 @@ +- name: Create initial folder in Opendaylight + file: + path: /opt/opendaylight/configuration/initial + state: directory + mode: 0777 + +- name: Add module-shards.conf file + template: + src: "module-shards.conf.j2" + dest: "/opt/opendaylight/configuration/initial/module-shards.conf" + +- name: Add akka.conf file + template: + src: "akka.conf.j2" + dest: "/opt/opendaylight/configuration/initial/akka.conf" + diff --git a/tasks/configure_karaf_features.yml b/tasks/configure_karaf_features.yml index 9bdcb27..7de179e 100644 --- a/tasks/configure_karaf_features.yml +++ b/tasks/configure_karaf_features.yml @@ -1,6 +1,6 @@ - name: Build Karaf feature list set_fact: - features: "{{ default_features + extra_features }}" + features: "{{ default_features + extra_features + cluster_features if cluster else default_features + extra_features }}" - name: Configure ODL Karaf features lineinfile: diff --git a/tasks/main.yml b/tasks/main.yml index 48c91c7..de73435 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,9 @@ --- - include: install_odl.yml +- include: configure_cluster.yml + when: + - cluster + - include: configure_karaf_features.yml - include: configure_nb_rest_port.yml - include: open_nb_rest_port.yml diff --git a/templates/akka.conf.j2 b/templates/akka.conf.j2 new file mode 100644 index 0000000..d584f18 --- /dev/null +++ b/templates/akka.conf.j2 @@ -0,0 +1,62 @@ +# {{ ansible_managed }} + +{%- set odl_cluster_list = [] %} +{% set vars = {'host_ip': None,'member_index': None} %} + +{% for host in groups["neutron_server_container"] %} + {% if inventory_hostname == host %} + {% set _ = vars.update({'host_ip': hostvars[host]['container_address']|string}) %} + {% set _ = vars.update({'member_index': '"' + "member-" + loop.index|string + '"'}) %} + {% endif %} + {% set ip_address = hostvars[host]['container_address']|string %} + {% set _ = odl_cluster_list.append('"' + "akka.tcp://opendaylight-cluster-data@" + ip_address + ":" + {{ akka_remoting_port }} + '"') %} +{%- endfor %} + +odl-cluster-data { + akka { + remote { + artery { + enabled = off + canonical.hostname = "{{vars.host_ip}}" + canonical.port = { akka_remoting_port }} + } + netty.tcp { + hostname = "{{vars.host_ip}}" + port = { akka_remoting_port }} + } + # when under load we might trip a false positive on the failure detector + # transport-failure-detector { + # heartbeat-interval = 4 s + # acceptable-heartbeat-pause = 16s + # } + } + + cluster { + # Remove ".tcp" when using artery. + seed-nodes = [{{ odl_cluster_list | join(',') }}] + roles = [ + {{vars.member_index}} + ] + + } + + persistence { + # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by + # modifying the following two properties. The directory location specified may be a relative or absolute path. + # The relative path is always relative to KARAF_HOME. + + # snapshot-store.local.dir = "target/snapshots" + # journal.leveldb.dir = "target/journal" + + journal { + leveldb { + # Set native = off to use a Java-only implementation of leveldb. + # Note that the Java-only version is not currently considered by Akka to be production quality. + + # native = off + } + } + } + } +} + diff --git a/templates/module-shards.conf.j2 b/templates/module-shards.conf.j2 new file mode 100644 index 0000000..1217ecc --- /dev/null +++ b/templates/module-shards.conf.j2 @@ -0,0 +1,45 @@ +# {{ ansible_managed }} + +{%- set members_list = [] %} + +{% for host in groups["neutron_server_container"] %} + {% set indexing = loop.index|string %} + {% set _ = members_list.append('"' + "member-" + indexing + '"') %} +{% endfor %} + +module-shards = [ + { + name = "default" + shards = [ + { + name="default" + replicas = [ + {{ members_list | join(',') }} + ] + } + ] + }, + { + name = "topology" + shards = [ + { + name="topology" + replicas = [ + {{ members_list | join(',') }} + ] + } + ] + }, + { + name = "inventory" + shards = [ + { + name="inventory" + replicas = [ + {{ members_list | join(',') }} + ] + } + ] + } +] + diff --git a/vars/main.yml b/vars/main.yml index bfddb23..0bc4691 100755 --- a/vars/main.yml +++ b/vars/main.yml @@ -31,10 +31,27 @@ default_features: # CLIs is an anti-goal for CI/CD and automated deployments generally. extra_features: [] +# Deploying Opendaylight in a clustering mode is a feature +# which is only supported when the current role is consumed +# by the OSA project. +# https://github.com/openstack/openstack-ansible + +# Enable or disable deploying OpenDaylight as a cluster. +cluster: false + +# If OpenDaylight is deployed as a cluster, these features are required. +cluster_features: + - 'odl-mdsal-clustering' + - 'odl-jolokia' + # Specifies the port for the ODL northbound REST interface to listen on. # This was added because OpenStack's Swift project uses a conflicting port. nb_rest_port: 8080 +# Specifies the port for the ODL clustering which is being used by Akka +# remoting for east-west communication. +akka_remoting_port: 2550 + # Method to install ODL # Valid options: # rpm_repo: Install ODL using its Yum repo config