Add CentOS support for os_horizon role

Change-Id: I1cd6d4b8f4626331a47575be330f4a4fc4ba593f
This commit is contained in:
Marc Gariepy 2016-11-24 09:36:24 -05:00 committed by Marc Gariépy
parent 6b29de939c
commit 21499f4366
7 changed files with 123 additions and 14 deletions

View File

@ -15,5 +15,5 @@
- name: Restart apache2 - name: Restart apache2
service: service:
name: "apache2" name: "{{ horizon_system_service_name }}"
state: "restarted" state: "restarted"

View File

@ -0,0 +1,3 @@
---
features:
- CentOS7/RHEL support has been added to the os_horizon role.

View File

@ -26,6 +26,8 @@
- { state: present, name: mpm_worker } - { state: present, name: mpm_worker }
- { state: present, name: rewrite } - { state: present, name: rewrite }
- { state: present, name: headers } - { state: present, name: headers }
when:
- ansible_pkg_mgr == 'apt'
notify: Restart apache2 notify: Restart apache2
- name: Drop apache2 configs - name: Drop apache2 configs
@ -34,37 +36,57 @@
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
owner: "{{ item.owner|default(horizon_system_user_name) }}" owner: "{{ item.owner|default(horizon_system_user_name) }}"
group: "{{ item.group|default(horizon_system_group_name) }}" group: "{{ item.group|default(horizon_system_group_name) }}"
with_items: with_items: "{{ horizon_apache_configs }}"
- { src: "horizon_apache_ports.conf.j2", dest: "/etc/apache2/ports.conf", owner: "root", group: "root" } notify: Restart apache2
- { src: "openstack_dashboard.conf.j2", dest: "/etc/apache2/sites-available/openstack-dashboard.conf" }
- name: Disable default apache site
file:
path: "{{ item }}"
state: "absent"
with_items: "{{ horizon_apache_default_sites }}"
notify: Restart apache2 notify: Restart apache2
- name: Enable Horizon Site - name: Enable Horizon Site
file: file:
src: "/etc/apache2/sites-available/{{ item.name }}" src: "{{ horizon_apache_site_available }}"
dest: "/etc/apache2/sites-enabled/{{ item.name }}" dest: "{{ horizon_apache_site_enabled }}"
state: "{{ item.state }}" state: "link"
with_items: when:
- { state: link, name: openstack-dashboard.conf } - horizon_apache_site_available is defined
- { state: absent, name: 000-default.conf } - horizon_apache_site_enabled is defined
notify: Restart apache2 notify: Restart apache2
- name: Ensure Apache ServerName - name: Ensure Apache ServerName
lineinfile: lineinfile:
dest: "/etc/apache2/apache2.conf" dest: "{{ horizon_apache_conf }}"
line: "ServerName {{ horizon_server_name }}" line: "ServerName {{ horizon_server_name }}"
notify: Restart apache2 notify: Restart apache2
- name: Ensure Apache ServerTokens - name: Ensure Apache ServerTokens
lineinfile: lineinfile:
dest: "/etc/apache2/conf-available/security.conf" dest: "{{ horizon_apache_security_conf }}"
regexp: '^ServerTokens' regexp: '^ServerTokens'
line: "ServerTokens {{ horizon_apache_servertokens }}" line: "ServerTokens {{ horizon_apache_servertokens }}"
notify: Restart apache2 notify: Restart apache2
- name: Ensure Apache ServerSignature - name: Ensure Apache ServerSignature
lineinfile: lineinfile:
dest: "/etc/apache2/conf-available/security.conf" dest: "{{ horizon_apache_security_conf }}"
regexp: '^ServerSignature' regexp: '^ServerSignature'
line: "ServerSignature {{ horizon_apache_serversignature }}" line: "ServerSignature {{ horizon_apache_serversignature }}"
notify: Restart apache2 notify: Restart apache2
# Removing the Listen from apache config to prevent conflick with ports.conf on CentOS
- name: remove Listen from Apache config
lineinfile:
dest: "{{ horizon_apache_security_conf }}"
regexp: '^(Listen.*)'
backrefs: yes
line: '#\1'
notify: Restart apache2
- name: Load service
service:
name: "{{ horizon_system_service_name }}"
enabled: "yes"
state: "started"

View File

@ -20,6 +20,30 @@
when: when:
- ansible_pkg_mgr == 'apt' - ansible_pkg_mgr == 'apt'
- name: Create horizon dir
file:
path: "{{ item.path }}"
state: directory
owner: "{{ item.owner|default(horizon_system_user_name) }}"
group: "{{ item.group|default(horizon_system_group_name) }}"
mode: "{{ item.mode|default('0755') }}"
with_items:
- { path: "/etc/pki/tls/certs", owner: "root", group: "root" }
- { path: "/etc/pki/tls/private", owner: "root", group: "root" }
- { path: "/var/log/httpd", mode: "2755" }
when: ansible_pkg_mgr == 'yum'
- name: Create system links
file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
state: "link"
with_items:
- { src: "/etc/pki/tls/certs", dest: "/etc/ssl/certs" }
- { src: "/etc/pki/tls/private", dest: "/etc/ssl/private" }
- { src: "/var/log/httpd", dest: "/var/log/apache2" }
when: ansible_pkg_mgr == 'yum'
- name: Install distro packages - name: Install distro packages
package: package:
name: "{{ item }}" name: "{{ item }}"

View File

@ -59,7 +59,9 @@
- name: Update the ca certificates - name: Update the ca certificates
command: "update-ca-certificates -f" command: "update-ca-certificates -f"
when: not horizon_external_ssl|bool when:
- not horizon_external_ssl|bool
- ansible_pkg_mgr == 'apt'
tags: tags:
- horizon-ssl - horizon-ssl

View File

@ -16,6 +16,8 @@
## APT Cache options ## APT Cache options
cache_timeout: 600 cache_timeout: 600
horizon_system_service_name: apache2
horizon_distro_packages: horizon_distro_packages:
- apache2 - apache2
- apache2-utils - apache2-utils
@ -27,3 +29,17 @@ horizon_distro_packages:
- openssl - openssl
- python-mysqldb # required by the Ansible mysql_db module - python-mysqldb # required by the Ansible mysql_db module
- gettext - gettext
horizon_apache_conf: "/etc/apache2/apache2.conf"
horizon_apache_security_conf: "/etc/apache2/conf-available/security.conf"
horizon_apache_site_available: "/etc/apache2/sites-available/openstack-dashboard.conf"
horizon_apache_site_enabled: "/etc/apache2/sites-enabled/openstack-dashboard.conf"
horizon_apache_configs:
- { src: "horizon_apache_ports.conf.j2", dest: "/etc/apache2/ports.conf", owner: "root", group: "root" }
- { src: "openstack_dashboard.conf.j2", dest: "{{ horizon_apache_site_available }}" }
horizon_apache_default_sites:
- "/etc/apache2/sites-enabled/000-default.conf"

42
vars/redhat-7.yml Normal file
View File

@ -0,0 +1,42 @@
---
# Copyright 2014, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
horizon_system_service_name: httpd
horizon_distro_packages:
- cronie
- cronie-anacron
- gettext
- git
- httpd
- httpd-tools
- libxslt-devel
- mod_ssl
- mod_wsgi
- MySQL-python
- openssl
- openssl-libs
horizon_apache_conf: "/etc/httpd/conf/httpd.conf"
horizon_apache_security_conf: "{{ horizon_apache_conf }}"
horizon_apache_configs:
- { src: "horizon_apache_ports.conf.j2", dest: "/etc/httpd/conf.d/ports.conf", owner: "root", group: "root" }
- { src: "openstack_dashboard.conf.j2", dest: "/etc/httpd/conf.d/openstack-dashboard.conf" }
horizon_apache_default_sites:
- "/etc/httpd/conf.d/userdir.conf"
- "/etc/httpd/conf.d/welcome.conf"
- "/etc/httpd/conf.d/ssl.conf"