Congress support for Newton 61/27361/7
authorHarry Huang <huangxiangyu5@huawei.com>
Mon, 23 Jan 2017 07:38:52 +0000 (15:38 +0800)
committerHarry Huang <huangxiangyu5@huawei.com>
Sat, 4 Feb 2017 06:39:32 +0000 (14:39 +0800)
Modification:
  1.Add congress support in deploy/compass_conf
  2.Optimize congress role to be more independant.
    Separate congress role into install, keystone,
    database, start.
  3.Support both ubuntu and centos

Change-Id: I1c9a458addd84133652fb7c0563bc287d161d129
Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
16 files changed:
deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml
deploy/adapters/ansible/roles/congress/handlers/main.yml [changed mode: 0644->0755]
deploy/adapters/ansible/roles/congress/tasks/congress_database.yml [moved from deploy/adapters/ansible/roles/congress/tasks/congress_db.yml with 75% similarity, mode: 0755]
deploy/adapters/ansible/roles/congress/tasks/congress_install.yml [changed mode: 0644->0755]
deploy/adapters/ansible/roles/congress/tasks/congress_keystone.yml [new file with mode: 0755]
deploy/adapters/ansible/roles/congress/tasks/congress_start.yml [new file with mode: 0755]
deploy/adapters/ansible/roles/congress/tasks/main.yml [changed mode: 0644->0755]
deploy/adapters/ansible/roles/congress/templates/api-paste.ini [changed mode: 0644->0755]
deploy/adapters/ansible/roles/congress/templates/congress.conf [changed mode: 0644->0755]
deploy/adapters/ansible/roles/congress/templates/congress.service [moved from deploy/adapters/ansible/roles/congress/files/congress.service with 81% similarity, mode: 0755]
deploy/adapters/ansible/roles/congress/templates/policy.json [changed mode: 0644->0755]
deploy/adapters/ansible/roles/congress/vars/Debian.yml [changed mode: 0644->0755]
deploy/adapters/ansible/roles/congress/vars/RedHat.yml [moved from deploy/adapters/ansible/roles/congress/tasks/congress_config.yml with 63% similarity, mode: 0755]
deploy/adapters/ansible/roles/congress/vars/main.yml [changed mode: 0644->0755]
deploy/compass_conf/flavor_mapping/HA-ansible-multinodes-newton.conf
deploy/compass_conf/templates/ansible_installer/openstack_newton/vars/HA-ansible-multinodes.tmpl

index 8398ca7..5e729cf 100644 (file)
@@ -77,6 +77,7 @@
     - dashboard
     - heat
     - aodh
+    - congress
 
 - hosts: all
   remote_user: root
old mode 100644 (file)
new mode 100755 (executable)
similarity index 75%
rename from deploy/adapters/ansible/roles/congress/tasks/congress_db.yml
rename to deploy/adapters/ansible/roles/congress/tasks/congress_database.yml
index 16832ea..009e348
@@ -1,4 +1,4 @@
-##############################################################################
+#############################################################################
 # Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
 #
 # All rights reserved. This program and the accompanying materials
@@ -12,7 +12,7 @@
     login_unix_socket: /var/run/mysqld/mysqld.sock
     name: "{{ item.db }}"
     state: present
-  with_items: "{{ credentials }}"
+  with_items: "{{ congress_database }}"
 
 - name: create congress db user
   mysql_user:
     host: "{{ item[1] }}"
     state: present
   with_nested:
-    - "{{ credentials }}"
+    - "{{ congress_database }}"
     - ['%', 'localhost']
+
+- name: congress db sync
+  shell: |
+    "{{ congress_path }}"/congress-db-manage \
+        --config-file /etc/congress/congress.conf upgrade head
+  notify:
+    - restart congress services
old mode 100644 (file)
new mode 100755 (executable)
index 4269b5e..40d5d78
@@ -7,11 +7,9 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
-- include_vars: "{{ ansible_os_family }}.yml"
-
 - name: install congress packages
   pip: name={{ item }} state=present
-  with_items: "{{ packages }}"
+  with_items: "{{ pip_packages | union(packages_noarch) }}"
 
 - name: create congress etc directory
   file: path=/etc/congress state=directory
     - congress.conf
     - api-paste.ini
     - policy.json
+  notify:
+    - restart congress services
 
 - name: create congress service
-  copy: src=congress.service dest=/lib/systemd/system/
+  template: src=congress.service dest=/lib/systemd/system/
+  notify:
+    - restart congress services
 
 - name: create congress service work dir
   file: path=/var/lib/congress state=directory
diff --git a/deploy/adapters/ansible/roles/congress/tasks/congress_keystone.yml b/deploy/adapters/ansible/roles/congress/tasks/congress_keystone.yml
new file mode 100755 (executable)
index 0000000..b7f00b8
--- /dev/null
@@ -0,0 +1,70 @@
+##############################################################################
+# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+---
+- name: add service
+  os_keystone_service:
+    cloud: opnfv
+    name: "{{ item.name }}"
+    description: "{{ item.description }}"
+    service_type: "{{ item.type }}"
+  with_items: "{{ congress_service }}"
+
+- name: add user
+  os_user:
+    cloud: opnfv
+    domain: default
+    name: "{{ item.user }}"
+    password: "{{ item.password }}"
+    default_project: "{{ item.tenant }}"
+    email: "{{ item.email }}"
+  with_items: "{{ congress_user }}"
+
+- name: grant roles
+  os_user_role:
+    cloud: opnfv
+    user: "{{ item.user }}"
+    role: "{{ item.role }}"
+    project: "{{ item.tenant }}"
+  with_items: "{{ congress_user }}"
+
+- name: create admin url for service's endpoint
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: admin
+    region: "{{ item.region}}"
+    url: "{{ item.adminurl }}"
+  with_items: "{{ congress_service }}"
+
+- name: create internal url for service's endpoint
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: internal
+    region: "{{ item.region}}"
+    url: "{{ item.internalurl }}"
+  with_items: "{{ congress_service }}"
+
+- name: create public url for service'e endpoint
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: public
+    region: "{{ item.region}}"
+    url: "{{ item.publicurl }}"
+  with_items: "{{ congress_service }}"
diff --git a/deploy/adapters/ansible/roles/congress/tasks/congress_start.yml b/deploy/adapters/ansible/roles/congress/tasks/congress_start.yml
new file mode 100755 (executable)
index 0000000..1d7d5e5
--- /dev/null
@@ -0,0 +1,12 @@
+##############################################################################
+## Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+---
+- name: start congress services
+  service: name={{ item }} state=started enabled=yes
+  with_items: "{{ services | union(services_noarch) }}"
old mode 100644 (file)
new mode 100755 (executable)
index f8056d1..6aad108
@@ -7,10 +7,33 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
+- include_vars: "{{ ansible_os_family }}.yml"
+  tags:
+    - install
+    - start
+
 - include: congress_install.yml
+  tags:
+    - install
 
-- include: congress_db.yml
+- include: congress_keystone.yml
   when:
     - inventory_hostname == haproxy_hosts.keys()[0]
+  tags:
+    - keystone
+
+- include: congress_database.yml
+  when:
+    - inventory_hostname == haproxy_hosts.keys()[0]
+  tags:
+    - database
+
+- include: congress_start.yml
+  tags:
+    - start
 
-- include: congress_config.yml
+- meta: flush_handlers
+  tags:
+    - install
+    - keystone
+    - database
old mode 100644 (file)
new mode 100755 (executable)
similarity index 81%
rename from deploy/adapters/ansible/roles/congress/files/congress.service
rename to deploy/adapters/ansible/roles/congress/templates/congress.service
index 4ec26c8..f92ee1b
@@ -10,7 +10,7 @@ WorkingDirectory=/var/lib/congress
 PermissionsStartOnly=true
 ExecStartPre=/bin/mkdir -p /var/lock/congress /var/log/congress /var/lib/congress
 ExecStartPre=/usr/bin/touch /var/log/congress/congress.log
-ExecStart=/usr/local/bin/congress-server --config-file /etc/congress/congress.conf
+ExecStart={{ congress_path }}/congress-server --config-file /etc/congress/congress.conf
 Restart=on-failure
 LimitNOFILE=65535
 TimeoutStopSec=15
old mode 100644 (file)
new mode 100755 (executable)
index 36aba73..1f0820c
@@ -7,15 +7,12 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
-packages:
+pip_packages:
   - congress
   - python-congressclient
   - python-cloudfoundryclient
 
-service:
+services:
   - congress
 
-credentials:
-  - user: congress
-    db: congress
-    password: "{{ CONGRESS_DBPASS }}"
+congress_path: /usr/local/bin
old mode 100644 (file)
new mode 100755 (executable)
similarity index 63%
rename from deploy/adapters/ansible/roles/congress/tasks/congress_config.yml
rename to deploy/adapters/ansible/roles/congress/vars/RedHat.yml
index c85057e..0b5e967
@@ -7,11 +7,12 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
-- name: congress db sync
-  shell: |
-    /usr/local/bin/congress-db-manage \
-        --config-file /etc/congress/congress.conf upgrade head
-  when: inventory_hostname == haproxy_hosts.keys()[0]
+pip_packages:
+  - congress
+  - python-congressclient
+  - python-cloudfoundryclient
 
-- name: start congress service
-  shell: systemctl start congress.service
+services:
+  - congress
+
+congress_path: /usr/bin
old mode 100644 (file)
new mode 100755 (executable)
index f6fef74..18c4c84
 packages_noarch: []
 
 services_noarch: []
+
+congress_service:
+  - name: congress
+    type: policy
+    region: RegionOne
+    description: "OpenStack Policy Service"
+    publicurl: "http://{{ public_vip.ip }}:1789"
+    internalurl: "http://{{ internal_vip.ip }}:1789"
+    adminurl: "http://{{ internal_vip.ip }}:1789"
+
+congress_user:
+  - user: congress
+    password: "{{ CONGRESS_PASS }}"
+    email: congress@admin.com
+    role: admin
+    tenant: service
+    tenant_description: "Service Tenant"
+
+congress_database:
+  - user: congress
+    db: congress
+    password: "{{ CONGRESS_DBPASS }}"
index 9dcdfc5..702f89c 100755 (executable)
@@ -54,6 +54,10 @@ CONFIG_MAPPING = {
                 "heat": {
                     "username": "heat",
                     "password": "heat"
+                },
+                "policy": {
+                    "username": "congress",
+                    "password": "congress"
                 }
             }
         }
index 2205431..b56a0b1 100755 (executable)
@@ -115,6 +115,8 @@ ERLANG_TOKEN: YOWSJSJIGGAUFZTIBRAD
 #set ceilometer_pass = $console_credentials.metering.password
 #set aodh_dbpass = $credentials.alarming.password
 #set aodh_pass = $console_credentials.alarming.password
+#set congress_dbpass = $credentials.policy.password
+#set congress_pass = $console_credentials.policy.password
 #set admin_pass = $console_credentials.admin.password
 #set demo_pass = $console_credentials.demo.password
 
@@ -153,6 +155,8 @@ NEUTRON_DBPASS: $neutron_dbpass
 NEUTRON_PASS: $neutron_pass
 HEAT_DBPASS: $heat_dbpass
 HEAT_PASS: $heat_pass
+CONGRESS_DBPASS: $congress_dbpass
+CONGRESS_PASS: $congress_pass
 DEMO_PASS: $demo_pass
 ADMIN_PASS: $admin_pass