seperate apache2 installtion from dashboard 89/11289/12
authorcarey.xu <carey.xuhan@huawei.com>
Mon, 14 Mar 2016 07:38:33 +0000 (15:38 +0800)
committercarey xu <carey.xuhan@huawei.com>
Fri, 18 Mar 2016 06:41:56 +0000 (06:41 +0000)
JIRA: COMPASS-342

Change-Id: I8ddbef46486dbd22f1324bda2d04f7a192b2148e
Signed-off-by: carey.xu <carey.xuhan@huawei.com>
14 files changed:
deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml
deploy/adapters/ansible/roles/apache/handlers/main.yml [new file with mode: 0755]
deploy/adapters/ansible/roles/apache/tasks/main.yml [new file with mode: 0755]
deploy/adapters/ansible/roles/apache/templates/openstack-dashboard.conf.j2 [new file with mode: 0755]
deploy/adapters/ansible/roles/apache/templates/ports.conf.j2 [new file with mode: 0644]
deploy/adapters/ansible/roles/apache/vars/Debian.yml [new file with mode: 0755]
deploy/adapters/ansible/roles/apache/vars/RedHat.yml [new file with mode: 0755]
deploy/adapters/ansible/roles/apache/vars/main.yml [new file with mode: 0755]
deploy/adapters/ansible/roles/dashboard/handlers/main.yml [new file with mode: 0755]
deploy/adapters/ansible/roles/dashboard/tasks/main.yml
deploy/adapters/ansible/roles/dashboard/templates/openstack-dashboard.conf.j2 [new file with mode: 0755]
deploy/adapters/ansible/roles/dashboard/vars/Debian.yml
deploy/adapters/ansible/roles/dashboard/vars/RedHat.yml
deploy/adapters/ansible/roles/memcached/handlers/main.yml [changed mode: 0644->0755]

index 787cf97..6df1d0d 100644 (file)
@@ -61,6 +61,7 @@
   max_fail_percentage: 0
   roles:
     - memcached
+    - apache
     - database
     - mq
     - keystone
diff --git a/deploy/adapters/ansible/roles/apache/handlers/main.yml b/deploy/adapters/ansible/roles/apache/handlers/main.yml
new file mode 100755 (executable)
index 0000000..0f28dc2
--- /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: restart apache related services
+  service: name={{ item }} state=restarted enabled=yes
+  with_items: services| union(services_noarch)
diff --git a/deploy/adapters/ansible/roles/apache/tasks/main.yml b/deploy/adapters/ansible/roles/apache/tasks/main.yml
new file mode 100755 (executable)
index 0000000..11e49c0
--- /dev/null
@@ -0,0 +1,30 @@
+##############################################################################
+# 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
+##############################################################################
+---
+- include_vars: "{{ ansible_os_family }}.yml"
+
+- name: install packages
+  action: "{{ ansible_pkg_mgr }} name={{ item }} state=latest update_cache=yes"
+  with_items: packages | union(packages_noarch)
+
+- name: assure listen port exist
+  template:
+    dest: '{{ apache_config_dir }}/ports.conf'
+    src: ports.conf.j2
+  notify:
+    - restart dashboard services
+
+- name: remove default listen port on centos
+  lineinfile:
+    dest: /etc/httpd/conf/httpd.conf
+    state: absent
+    regexp: 'Listen 80'
+  when: ansible_os_family == 'RedHat'
+
+- meta: flush_handlers
diff --git a/deploy/adapters/ansible/roles/apache/templates/openstack-dashboard.conf.j2 b/deploy/adapters/ansible/roles/apache/templates/openstack-dashboard.conf.j2
new file mode 100755 (executable)
index 0000000..403fcc2
--- /dev/null
@@ -0,0 +1,15 @@
+{% set work_threads = (ansible_processor_vcpus + 1) // 2 %}
+
+<VirtualHost {{ internal_ip }}:80>
+    WSGIScriptAlias /horizon {{ horizon_dir }}/wsgi/django.wsgi
+    WSGIDaemonProcess horizon user=horizon group=horizon processes={{ work_threads }} threads={{ work_threads }}
+    WSGIProcessGroup horizon
+    Alias /static {{ horizon_dir }}/static/
+    Alias /horizon/static {{ horizon_dir }}/static/
+    <Directory {{ horizon_dir }}/wsgi>
+        Order allow,deny
+        Allow from all
+    </Directory>
+</VirtualHost>
+
+
diff --git a/deploy/adapters/ansible/roles/apache/templates/ports.conf.j2 b/deploy/adapters/ansible/roles/apache/templates/ports.conf.j2
new file mode 100644 (file)
index 0000000..be27d19
--- /dev/null
@@ -0,0 +1 @@
+Listen {{ internal_ip }}:80
diff --git a/deploy/adapters/ansible/roles/apache/vars/Debian.yml b/deploy/adapters/ansible/roles/apache/vars/Debian.yml
new file mode 100755 (executable)
index 0000000..95e941e
--- /dev/null
@@ -0,0 +1,17 @@
+##############################################################################
+# 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
+##############################################################################
+---
+packages:
+  - apache2
+  - libapache2-mod-wsgi
+
+services:
+  - apache2
+
+apache_config_dir: /etc/apache2
diff --git a/deploy/adapters/ansible/roles/apache/vars/RedHat.yml b/deploy/adapters/ansible/roles/apache/vars/RedHat.yml
new file mode 100755 (executable)
index 0000000..5211a12
--- /dev/null
@@ -0,0 +1,17 @@
+##############################################################################
+# 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
+##############################################################################
+---
+packages:
+  - mod_wsgi
+  - httpd
+
+services:
+  - httpd
+
+apache_config_dir: /etc/httpd/conf.d
diff --git a/deploy/adapters/ansible/roles/apache/vars/main.yml b/deploy/adapters/ansible/roles/apache/vars/main.yml
new file mode 100755 (executable)
index 0000000..f6fef74
--- /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
+##############################################################################
+---
+packages_noarch: []
+
+services_noarch: []
diff --git a/deploy/adapters/ansible/roles/dashboard/handlers/main.yml b/deploy/adapters/ansible/roles/dashboard/handlers/main.yml
new file mode 100755 (executable)
index 0000000..62e0b8e
--- /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: restart dashboard services
+  service: name={{ item }} state=restarted enabled=yes
+  with_items: services | union(services_noarch)
index 6482017..ce4fd97 100644 (file)
@@ -9,25 +9,58 @@
 ---
 - include_vars: "{{ ansible_os_family }}.yml"
 
-- name: install http packages
-  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
-  with_items: http_packages
-
-- name: set http config
-  lineinfile: dest={{ http_config_file }} regexp='^Listen' line='Listen {{ internal_ip }}:80'
-
-- name: restart http services
-  service: name={{ http_service }} state=restarted enabled=yes
-
-- name: write services to monitor list
-  lineinfile: dest=/opt/service create=yes line='{{ http_service }}'
+- name: disable auto start
+  copy:
+    content: "#!/bin/sh\nexit 101"
+    dest: "/usr/sbin/policy-rc.d"
+    mode: 0755
+  when: ansible_os_family == "Debian"
 
 - name: install dashboard packages
   action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
   with_items: packages | union(packages_noarch)
 
+- name: enable auto start
+  file:
+    path=/usr/sbin/policy-rc.d
+    state=absent
+  when: ansible_os_family == "Debian"
+
 - name: remove ubuntu theme
   action: "{{ ansible_pkg_mgr }} name=openstack-dashboard-ubuntu-theme state=absent"
+  when: ansible_os_family == 'Debian'
+  notify:
+    - restart dashboard services
+
+- name: remove default apache2 config
+  file:
+    path: '{{ item }}'
+    state: absent
+  when: ansible_os_family == 'Debian'
+  with_items:
+    - '{{ apache_config_dir }}/conf-available/openstack-dashboard.conf'
+    - '{{ apache_config_dir }}/conf-enabled/openstack-dashboard.conf'
+    - '{{ apache_config_dir }}/sites-available/000-default.conf'
+    - '{{ apache_config_dir }}/sites-enabled/000-default.conf'
+  notify:
+    - restart dashboard services
+
+- name: update apache2 configs
+  template:
+    src: openstack-dashboard.conf.j2
+    dest: '{{ apache_config_dir }}/sites-available/openstack-dashboard.conf'
+  when: ansible_os_family == 'Debian'
+  notify:
+    - restart dashboard services
+
+- name: enable dashboard
+  file:
+    src: "/etc/apache2/sites-available/openstack-dashboard.conf"
+    dest: "/etc/apache2/sites-enabled/openstack-dashboard.conf"
+    state: "link"
+  when: ansible_os_family == 'Debian'
+  notify:
+    - restart dashboard services
 
 - name: update ubuntu horizon settings
   lineinfile:
     - regexp: '^OPENSTACK_HOST[ \t]*=.*'
       line: 'OPENSTACK_HOST = "{{ internal_ip }}"'
   when: ansible_os_family == 'Debian'
+  notify:
+    - restart dashboard services
 
 - name: precompile horizon css
   shell: /usr/bin/python /usr/share/openstack-dashboard/manage.py compress --force
   ignore_errors: True
   when: ansible_os_family == 'Debian'
+  notify:
+    - restart dashboard services
 
 - name: update redhat version horizon settings
   lineinfile:
     - regexp: '^OPENSTACK_HOST[ \t]*=.*'
       line: 'OPENSTACK_HOST = "{{ internal_ip }}"'
   when: ansible_os_family == 'RedHat'
+  notify:
+    - restart dashboard services
 
-- name: restart dashboard services
-  service: name={{ item }} state=restarted enabled=yes
-  with_items: services | union(services_noarch)
+- meta: flush_handlers
diff --git a/deploy/adapters/ansible/roles/dashboard/templates/openstack-dashboard.conf.j2 b/deploy/adapters/ansible/roles/dashboard/templates/openstack-dashboard.conf.j2
new file mode 100755 (executable)
index 0000000..403fcc2
--- /dev/null
@@ -0,0 +1,15 @@
+{% set work_threads = (ansible_processor_vcpus + 1) // 2 %}
+
+<VirtualHost {{ internal_ip }}:80>
+    WSGIScriptAlias /horizon {{ horizon_dir }}/wsgi/django.wsgi
+    WSGIDaemonProcess horizon user=horizon group=horizon processes={{ work_threads }} threads={{ work_threads }}
+    WSGIProcessGroup horizon
+    Alias /static {{ horizon_dir }}/static/
+    Alias /horizon/static {{ horizon_dir }}/static/
+    <Directory {{ horizon_dir }}/wsgi>
+        Order allow,deny
+        Allow from all
+    </Directory>
+</VirtualHost>
+
+
index 4d9023d..5c9b032 100644 (file)
@@ -7,15 +7,10 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
-http_packages:
-  - apache2
-  - libapache2-mod-wsgi
-
-http_service: apache2
-
 packages: []
 
 services:
   - memcached
 
-http_config_file: "/etc/apache2/ports.conf"
+apache_config_dir: /etc/apache2
+horizon_dir: /usr/share/openstack-dashboard/openstack_dashboard
index 790567f..d213381 100644 (file)
@@ -7,14 +7,11 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
-http_packages:
-  - httpd
-
-http_service: httpd
-
 packages:
   - mod_wsgi
+  - httpd
 
-services: []
+services:
+  - httpd
 
 http_config_file: "/etc/httpd/conf/httpd.conf"