Write ODL ansible script for Ubuntu14.04 50/1350/2
authorchenshuai@huawei.com <chenshuai@huawei.com>
Mon, 31 Aug 2015 01:47:49 +0000 (21:47 -0400)
committerchenshuai@huawei.com <chenshuai@huawei.com>
Wed, 2 Sep 2015 06:26:24 +0000 (02:26 -0400)
JIRA: COMPASS-23

Change-Id: Iad692c8f77492989e29d0a4862989edea1d48fc5
Signed-off-by: chenshuai@huawei.com <chenshuai@huawei.com>
17 files changed:
deploy/adapters/ansible/openstack_juno/HA-ansible-multinodes.yml
deploy/adapters/ansible/roles/odl_cluster/handlers/main.yml
deploy/adapters/ansible/roles/odl_cluster/tasks/main.yml
deploy/adapters/ansible/roles/odl_cluster/tasks/main_compute.yml [deleted file]
deploy/adapters/ansible/roles/odl_cluster/tasks/odl_controller.yml [moved from deploy/adapters/ansible/roles/odl_cluster/tasks/main_controller.yml with 55% similarity]
deploy/adapters/ansible/roles/odl_cluster/tasks/openvswitch.yml [new file with mode: 0644]
deploy/adapters/ansible/roles/odl_cluster/templates/akka.conf
deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5-features.xml [deleted file]
deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar [deleted file]
deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar.sha1 [deleted file]
deploy/adapters/ansible/roles/odl_cluster/templates/ml2_conf.sh
deploy/adapters/ansible/roles/odl_cluster/templates/module-shards.conf
deploy/adapters/ansible/roles/odl_cluster/templates/opendaylight.service
deploy/adapters/ansible/roles/odl_cluster/templates/org.apache.karaf.features.cfg
deploy/adapters/ansible/roles/odl_cluster/vars/Debian.yml
deploy/adapters/ansible/roles/odl_cluster/vars/RedHat.yml
deploy/adapters/ansible/roles/odl_cluster/vars/main.yml

index c330172..f8f8b44 100644 (file)
@@ -34,7 +34,7 @@
     - neutron-compute
     - cinder-volume
 
-- hosts: odl
+- hosts: all
   remote_user: root
   sudo: True
   roles:
index 017700b..81e6c65 100644 (file)
@@ -1,4 +1,4 @@
 ---
 - name: restart odl service
-  #service: name=opendaylight state=restarted
-  command: su -s /bin/sh -c "{{ odl_home }}/bin/stop;{{ odl_home }}/bin/start;"
+  service: name=opendaylight state=restarted
+  #command: su -s /bin/sh -c "{{ odl_home }}/bin/stop;{{ odl_home }}/bin/start;"
index 1b27ed1..5c6805c 100644 (file)
@@ -7,4 +7,4 @@
 
 - name: Install ODL Cluster on Compute
   include: main_compute.yml
-  when: inventory_hostname in groups['compute']
+  when: groups['odl']|length !=0 and inventory_hostname not in groups['odl']
diff --git a/deploy/adapters/ansible/roles/odl_cluster/tasks/main_compute.yml b/deploy/adapters/ansible/roles/odl_cluster/tasks/main_compute.yml
deleted file mode 100644 (file)
index 3994766..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
----
-- name: shut down and disable Neutron's agent services
-  service: name=neutron-plugin-openvswitch-agent state=stopped
-
-- name: Stop the Open vSwitch service and clear existing OVSDB
-  shell: >
-    service openvswitch-switch stop ;
-    rm -rf /var/log/openvswitch/* ;
-    rm -rf /etc/openvswitch/conf.db ;
-    service openvswitch-switch start ;
-
-- name: Set OpenDaylight as the manager
-  command: su -s /bin/sh -c "ovs-vsctl set-manager tcp:{{odl_controller}}:6640;"
-
-- name: start and disable Neutron's agent services
-  service: name=neutron-plugin-openvswitch-agent state=started
@@ -1,5 +1,5 @@
 ---
-- name: install jdk packages
+- name: install java packages
   action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
   with_items: packages | union(packages_noarch)
 
     system: "yes"
     shell: "/bin/false"
 
+- name: get image http server
+  shell: awk -F'=' '/compass_server/ {print $2}' /etc/compass.conf
+  register: http_server
+
 - name: download odl package
-  get_url: url={{ odl_pkg_url }} dest=/opt/{{ odl_pkg_name }}
+  get_url: url="http://{{ http_server.stdout_lines[0] }}/packages/odl/{{ odl_pkg_url }}"  dest=/opt/{{ odl_pkg_name }}
+
+#- name: download odl package
+#  get_url: url={{ odl_pkg_url }} dest=/opt/{{ odl_pkg_name }}
 
 # TODO: unarchive doesn't support strip-component at the moment
 # TODO: switch to use untar after support is added.
   notify:
     - restart odl service
 
-#- name: opendaylight systemd file
-#  template: src=opendaylight.service dest=/usr/lib/systemd/system/opendaylight.service mode=0644
-
-- name: create karaf config
+- name: opendaylight system file
   template:
-    src: org.apache.karaf.features.cfg
-    dest: "{{ odl_home }}/etc/org.apache.karaf.features.cfg"
-    owner: odl
-    group: odl
-    mode: 0775
-  notify:
-    - restart odl service
+    src: "{{ service_file.src }}"
+    dest: "{{ service_file.dst }}"
+    mode: 0644
+
+#- name: create karaf config
+#  template:
+#    src: org.apache.karaf.features.cfg
+#    dest: "{{ odl_home }}/etc/org.apache.karaf.features.cfg"
+#    owner: odl
+#    group: odl
+#    mode: 0775
+#  notify:
+#    - restart odl service
 
 - name: create tomcat config
   template:
   notify:
     - restart odl service
 
-- name: copy Jolokia-OSGi config
-  shell: >
-    cp -r jolokia {{ odl_home }}/system/org/;
+#- name: copy Jolokia-OSGi config
+#  shell: >
+#    cp -r jolokia {{ odl_home }}system/org/;
+
+#- name: copy Jolokia-OSGi config
+#  template:
+#    src: jolokia
+#    dest: "{{ odl_home }}/system/org/"
+#  notify:
+#    - restart odl service
+
+
+#- name: mkdir Jolokia-OSGi directory
+#  shell: >
+#     mkdir -p {{ odl_home }}system/org/jolokia;
+#     mkdir -p {{ odl_home }}system/org/jolokia/jolokia-osgi;
+#     mkdir -p {{ odl_home }}system/org/jolokia/jolokia-osgi/1.1.5;
+
+
+#- name: copy Jolokia-OSGi config
+#  template: src={{ item.src }} dest={{ item.dest }}
+#  with_items:
+#      - src: "jolokia-osgi-1.1.5-features.xml"
+#        dest: "{{ odl_home }}/system/org/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5-features.xml"
+#      - src: "jolokia-osgi-1.1.5.jar.sha1"
+#        dest: "{{ odl_home }}/system/org/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar.sha1"
+#      - src: "jolokia-osgi-1.1.5.jar"
+#        dest: "{{ odl_home }}/system/org/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar"
+
+#- name: copy Jolokia-OSGi jar config
+#  copy: src=roles/odl_cluster/templates/jolokia-osgi-1.1.5.jar  dest="{{ odl_home }}/system/org/jolokia/jolokia-osgi/1.1.5/"
 
 - name: remove KARAF Data Directory
   shell: >
     rm -rf {{ odl_home }}/data/*;
 
+- name: chown OpenDaylight Directory and Files
+  shell: >
+    chown -R odl:odl "{{ odl_home }}";
+    chown odl:odl "{{ service_file.dst }}";
+
 
 ##########################################################################################################
 ################################    OpenDayLight connect with OpenStack   ################################
 - name: Turn off neutron-server on control node
   service: name=neutron-server state=stopped
 
-- name: shut down and disable Neutron's agent services
-  service: name=neutron-plugin-openvswitch-agent state=stopped
-
-- name: Stop the Open vSwitch service and clear existing OVSDB
-  shell: >
-    service openvswitch-switch stop ;
-    rm -rf /var/log/openvswitch/* ;
-    rm -rf /etc/openvswitch/conf.db ;
-    service openvswitch-switch start ;
-
-- name: Set OpenDaylight as the manager
-  command: su -s /bin/sh -c "ovs-vsctl set-manager tcp:{{odl_controller}}:6640;"
-
-- name: start and disable Neutron's agent services
-  service: name=neutron-plugin-openvswitch-agent state=started
-
 - name: Install Crudini
   apt: name={{ item }} state=present
   with_items:
     - crudini
 
-- name: Configure Neutron1
-  shell: >
-    crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers opendaylight;
-    crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan;
+- name: Run OpenVSwitch Script
+  include: openvswitch.yml
 
-- name: Create ML2 Configuration File
-  template:
-    src: ml2_conf.sh
-    dest: "/opt/ml2_conf.sh"
-    mode: 0777
+#- name: Configure Neutron1
+#  shell: >
+#    crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers opendaylight;
+#    crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan;
 
-- name: Configure Neutron2
-  command: su -s /bin/sh -c "/opt/ml2_conf.sh;"
+#- name: Create ML2 Configuration File
+#  template:
+#    src: ml2_conf.sh
+#    dest: "/opt/ml2_conf.sh"
+#    mode: 0777
+
+#- name: Execute ML2 Configuration File
+#  command: su -s /bin/sh -c "/opt/ml2_conf.sh;"
 
-- name: Configure Neutron3
+- name: Configure Neutron2
   shell: >
     mysql -e "drop database if exists neutron_ml2;";
     mysql -e "create database neutron_ml2 character set utf8;";
 
 - name: Restart neutron-server
   service: name=neutron-server state=started
-
-
-
-
diff --git a/deploy/adapters/ansible/roles/odl_cluster/tasks/openvswitch.yml b/deploy/adapters/ansible/roles/odl_cluster/tasks/openvswitch.yml
new file mode 100644 (file)
index 0000000..e59ca37
--- /dev/null
@@ -0,0 +1,40 @@
+---
+
+- name: Install Crudini
+  apt: name={{ item }} state=present
+  with_items:
+    - crudini
+
+- name: shut down and disable Neutron's openvswitch  agent services
+  service: name=neutron-plugin-openvswitch-agent state=stopped
+
+- name: remove Neutron's openvswitch agent services
+  shell: >
+    update-rc.d neutron-plugin-openvswitch-agent remove
+
+#- name: Stop the Open vSwitch service and clear existing OVSDB
+#  shell: >
+#    service openvswitch-switch stop ;
+#    rm -rf /var/log/openvswitch/* ;
+#    rm -rf /etc/openvswitch/conf.db ;
+#    service openvswitch-switch start ;
+
+- name: Set OpenDaylight as the manager
+  command: su -s /bin/sh -c "ovs-vsctl set-manager tcp:{{ HA_VIP }}:6640;"
+
+- name: start and disable Neutron's agent services
+  service: name=neutron-plugin-openvswitch-agent state=started
+
+- name: Configure Neutron1
+  shell: >
+    crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers opendaylight;
+    crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vlan;
+
+- name: Create ML2 Configuration File
+  template:
+    src: ml2_conf.sh
+    dest: "/opt/ml2_conf.sh"
+    mode: 0777
+
+- name: Execute ML2 Configuration File
+  command: su -s /bin/sh -c "/opt/ml2_conf.sh;"
index 4818e34..318a872 100644 (file)
@@ -38,7 +38,7 @@ odl-cluster-data {
 
     cluster {
       seed-nodes = [
-{% for host in groups['odl_controller'] %}
+{% for host in groups['odl'] %}
     {% if loop.last %}
                     "akka.tcp://opendaylight-cluster-data@{{ hostvars[host]['ansible_' + INTERNAL_INTERFACE].ipv4.address }}:2550"
     {% else %}
@@ -51,7 +51,7 @@ odl-cluster-data {
 
       roles = [
 {% set key = 0 %}
-{% for host in groups['odl_controller'] %}
+{% for host in groups['odl'] %}
     {% set key = key + 1 %}
     {% if  hostvars[host]['ansible_' + INTERNAL_INTERFACE].ipv4.address  ==  hostvars[inventory_hostname]['ansible_' + INTERNAL_INTERFACE].ipv4.address  %}
         "member-{{ key }}"
@@ -90,7 +90,7 @@ odl-cluster-rpc {
 
     cluster {
       seed-nodes = [
-{% for host in groups['odl_controller'] %}
+{% for host in groups['odl'] %}
     {% if loop.last %}
                     "akka.tcp://odl-cluster-rpc@{{ hostvars[host]['ansible_' + INTERNAL_INTERFACE].ipv4.address }}:2551"
     {% else %}
diff --git a/deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5-features.xml b/deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5-features.xml
deleted file mode 100644 (file)
index 6242d78..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="framework-3.0.1">
-    <repository>mvn:org.jolokia/jolokia-osgi/1.1.5/xml/features</repository>
-    <feature name="jolokia-osgi" version="1.1.5" description="Jolokia Agent">
-        <bundle start-level="5" start="true">mvn:org.jolokia/jolokia-osgi/1.1.5</bundle>
-    </feature>
-</features>
-
diff --git a/deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar b/deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar
deleted file mode 100644 (file)
index 18e8710..0000000
Binary files a/deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar and /dev/null differ
diff --git a/deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar.sha1 b/deploy/adapters/ansible/roles/odl_cluster/templates/jolokia/jolokia-osgi/1.1.5/jolokia-osgi-1.1.5.jar.sha1
deleted file mode 100644 (file)
index 790e6ef..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ba513164178626519a6fb12ced4a3d6e1e07dd54
\ No newline at end of file
index 1ce1e41..7f61d36 100644 (file)
@@ -2,5 +2,5 @@ cat <<EOT>> /etc/neutron/plugins/ml2/ml2_conf.ini
 [ml2_odl]
 password = admin
 username = admin
-url = http://{{ hostvars[inventory_hostname]['ansible_' + INTERNAL_INTERFACE].ipv4.address }}:8080/controller/nb/v2/neutron
+url = http://{{ HA_VIP }}:8080/controller/nb/v2/neutron
 EOT
index 4477b39..9a5d4c3 100644 (file)
@@ -29,7 +29,7 @@ module-shards = [
                 name="default"
                 replicas = [
 {% set key = 0 %}
-{% for host in groups['controller'] %}
+{% for host in groups['odl'] %}
     {% set key = key + 1 %}
         {% if loop.last %}
             "member-{{ key }}"
@@ -48,7 +48,7 @@ module-shards = [
                 name="topology"
                 replicas = [
 {% set key = 0 %}
-{% for host in groups['controller'] %}
+{% for host in groups['odl'] %}
     {% set key = key + 1 %}
         {% if loop.last %}
             "member-{{ key }}"
@@ -67,7 +67,7 @@ module-shards = [
                 name="inventory"
                 replicas = [
 {% set key = 0 %}
-{% for host in groups['controller'] %}
+{% for host in groups['odl'] %}
     {% set key = key + 1 %}
         {% if loop.last %}
             "member-{{ key }}"
@@ -86,7 +86,7 @@ module-shards = [
                      name="toaster"
                      replicas = [
 {% set key = 0 %}
-{% for host in groups['controller'] %}
+{% for host in groups['odl'] %}
     {% set key = key + 1 %}
         {% if loop.last %}
             "member-{{ key }}"
index 61a1dbd..a4adeee 100644 (file)
@@ -5,7 +5,7 @@ After=network.service
 
 [Service]
 Type=forking
-ExecStart=/opt/opendaylight-0.2.2/bin/start
+ExecStart=/opt/opendaylight-0.3.0/bin/start
 User=odl
 Group=odl
 
index e53a07b..4f439c2 100644 (file)
@@ -38,7 +38,7 @@
 #
 #featuresRepositories = mvn:org.apache.karaf.features/standard/3.0.1/xml/features,mvn:org.apache.karaf.features/enterprise/3.0.1/xml/features,mvn:org.ops4j.pax.web/pax-web-features/3.1.0/xml/features,mvn:org.apache.karaf.features/spring/3.0.1/xml/features,mvn:org.opendaylight.integration/features-integration/0.2.2-Helium-SR2/xml/features,mvn:org.jolokia/jolokia-osgi/1.1.4/xml/features
 
-featuresRepositories = mvn:org.apache.karaf.features/standard/3.0.1/xml/features,mvn:org.apache.karaf.features/enterprise/3.0.1/xml/features,mvn:org.ops4j.pax.web/pax-web-features/3.1.0/xml/features,mvn:org.apache.karaf.features/spring/3.0.1/xml/features,mvn:org.opendaylight.integration/features-integration/0.2.2-Helium-SR2/xml/features,mvn:org.jolokia/jolokia-osgi/1.1.4/xml/features
+featuresRepositories = mvn:org.apache.karaf.features/standard/3.0.1/xml/features,mvn:org.apache.karaf.features/enterprise/3.0.1/xml/features,mvn:org.ops4j.pax.web/pax-web-features/3.1.0/xml/features,mvn:org.apache.karaf.features/spring/3.0.1/xml/features,mvn:org.opendaylight.integration/features-integration/0.2.2-Helium-SR2/xml/features,mvn:org.jolokia/jolokia-osgi/1.1.5/xml/features
 
 #
 # Comma separated list of features to install at startup
index c0e4901..a2a4795 100644 (file)
@@ -2,3 +2,8 @@
 
 packages:
   - openjdk-7-jdk
+  - crudini
+
+service_file:
+   src: opendaylight.conf
+   dst: /etc/init/opendaylight.conf
index 9c441d6..8becb8b 100644 (file)
@@ -2,3 +2,8 @@
 
 packages:
   - java-1.7.0-openjdk
+  - crudini
+
+service_file:
+  - src: opendaylight.service
+    dst: /usr/lib/systemd/system/opendaylight.service
index b98810a..73a3b02 100644 (file)
@@ -3,7 +3,8 @@ odl_username: admin
 odl_password: admin
 odl_api_port: 8080
 
-odl_pkg_url: https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.3.0-Lithium/distribution-karaf-0.3.0-Lithium.tar.gz
+#odl_pkg_url: https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.3.0-Lithium/distribution-karaf-0.3.0-Lithium.tar.gz
+odl_pkg_url: karaf.tar.gz
 odl_pkg_name: karaf.tar.gz
 odl_home: "/opt/opendaylight-0.3.0/"
 odl_base_features: ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management', 'odl-restconf','odl-l2switch-switch','odl-openflowplugin-all','odl-mdsal-apidocs','odl-dlux-all','odl-adsal-northbound','odl-nsf-all','odl-ovsdb-openstack','odl-ovsdb-northbound','odl-dlux-core']