From 259cf1e63482c11fddfd3f89bc23b04a1a03686d Mon Sep 17 00:00:00 2001 From: Marc Gariepy Date: Mon, 5 Dec 2016 11:51:38 -0500 Subject: [PATCH] Add CentOS support for os_gnocchi role Depends-on: Id31fb15b352a160c8f5139ae70966055d93f7ce6 Change-Id: I540e8f08f3a8935b6a5af5a73f0a896ec8ec7a98 --- handlers/main.yml | 2 +- ...occhi-centos-support-d86d5e8269789a77.yaml | 3 ++ tasks/gnocchi_apache.yml | 42 +++++++++++++------ tasks/gnocchi_install.yml | 5 +++ tasks/gnocchi_install_yum.yml | 24 +++++++++++ vars/redhat-7.yml | 39 +++++++++++++++++ vars/ubuntu-16.04.yml | 16 +++++++ 7 files changed, 118 insertions(+), 13 deletions(-) create mode 100644 releasenotes/notes/os_gnocchi-centos-support-d86d5e8269789a77.yaml create mode 100644 tasks/gnocchi_install_yum.yml create mode 100644 vars/redhat-7.yml diff --git a/handlers/main.yml b/handlers/main.yml index 3d40ada..92fd1b4 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -36,7 +36,7 @@ - name: Restart Apache service: - name: "apache2" + name: "{{ gnocchi_system_service_name }}" state: "restarted" pattern: "apache2" when: gnocchi_use_mod_wsgi | bool diff --git a/releasenotes/notes/os_gnocchi-centos-support-d86d5e8269789a77.yaml b/releasenotes/notes/os_gnocchi-centos-support-d86d5e8269789a77.yaml new file mode 100644 index 0000000..b992559 --- /dev/null +++ b/releasenotes/notes/os_gnocchi-centos-support-d86d5e8269789a77.yaml @@ -0,0 +1,3 @@ +--- +features: + - CentOS7/RHEL support has been added to the os_gnocchi role. diff --git a/tasks/gnocchi_apache.yml b/tasks/gnocchi_apache.yml index b74e05d..7eb7365 100644 --- a/tasks/gnocchi_apache.yml +++ b/tasks/gnocchi_apache.yml @@ -20,39 +20,39 @@ dest: "{{ item.dest }}" owner: "root" group: "root" - with_items: - - { src: "gnocchi-ports.conf.j2", dest: "/etc/apache2/ports.conf" } - - { src: "gnocchi-httpd.conf.j2", dest: "/etc/apache2/sites-available/gnocchi-httpd.conf" } + with_items: "{{ gnocchi_apache_config }}" notify: - Restart Apache - name: Disable default apache site file: - path: "/etc/apache2/sites-enabled/000-default.conf" + path: "{{ item }}" state: "absent" + with_items: "{{ gnocchi_apache_default_sites }}" notify: - Restart Apache - name: Enabled gnocchi vhost file: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - state: "{{ item.state }}" - with_items: - - { src: "/etc/apache2/sites-available/gnocchi-httpd.conf", dest: "/etc/apache2/sites-enabled/gnocchi-httpd.conf", state: "link" } + src: "{{ gnocchi_apache_site_available }}" + dest: "{{ gnocchi_apache_site_enabled }}" + state: "link" + when: + - gnocchi_apache_site_available is defined + - gnocchi_apache_site_enabled is defined notify: - Restart Apache - name: Ensure Apache ServerName lineinfile: - dest: "/etc/apache2/apache2.conf" + dest: "{{ gnocchi_apache_conf }}" line: "ServerName {{ inventory_hostname }}" notify: - Restart Apache - name: Ensure Apache ServerTokens lineinfile: - dest: "/etc/apache2/conf-available/security.conf" + dest: "{{ gnocchi_apache_security_conf }}" regexp: '^ServerTokens' line: "ServerTokens {{ gnocchi_apache_servertokens }}" notify: @@ -60,15 +60,33 @@ - name: Ensure Apache ServerSignature lineinfile: - dest: "/etc/apache2/conf-available/security.conf" + dest: "{{ gnocchi_apache_security_conf }}" regexp: '^ServerSignature' line: "ServerSignature {{ gnocchi_apache_serversignature }}" notify: - Restart Apache +- name: remove Listen from Apache config + lineinfile: + dest: "{{ gnocchi_apache_security_conf }}" + regexp: '^(Listen.*)' + backrefs: yes + line: '#\1' + notify: + - Restart Apache + - name: Enable/disable mod_ssl for apache2 apache2_module: name: ssl state: "{{ gnocchi_ssl | bool | ternary('present', 'absent') }}" + when: + - ansible_pkg_mgr == 'apt' notify: - Restart Apache + +- name: Load service + service: + name: "{{ gnocchi_system_service_name }}" + enabled: "yes" + state: "started" + diff --git a/tasks/gnocchi_install.yml b/tasks/gnocchi_install.yml index 26e8a6a..941dab8 100644 --- a/tasks/gnocchi_install.yml +++ b/tasks/gnocchi_install.yml @@ -18,6 +18,11 @@ when: - ansible_pkg_mgr == 'apt' +- include: gnocchi_install_yum.yml + static: no + when: + - ansible_pkg_mgr == 'yum' + - name: Create developer mode constraint file copy: dest: "/opt/developer-pip-constraints.txt" diff --git a/tasks/gnocchi_install_yum.yml b/tasks/gnocchi_install_yum.yml new file mode 100644 index 0000000..296e4fe --- /dev/null +++ b/tasks/gnocchi_install_yum.yml @@ -0,0 +1,24 @@ +--- +# Copyright 2015, 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. + +- name: Install yum packages + yum: + pkg: "{{ item }}" + state: "{{ gnocchi_package_state }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ gnocchi_distro_packages }}" diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml new file mode 100644 index 0000000..627753a --- /dev/null +++ b/vars/redhat-7.yml @@ -0,0 +1,39 @@ +--- +# Copyright 2016, 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. + +#: Necessary packages +gnocchi_distro_packages: + - '@Development Tools' + - httpd + - httpd-tools + - mod_wsgi + - git + - python-devel + - libpqxx-devel + +gnocchi_system_service_name: httpd + +gnocchi_apache_config: + - { src: "gnocchi-ports.conf.j2", dest: "/etc/httpd/conf.d/ports.conf" } + - { src: "gnocchi-httpd.conf.j2", dest: "/etc/httpd/conf.d/gnocchi-httpd.conf" } + +gnocchi_apache_default_sites: + - "/etc/httpd/conf.d/userdir.conf" + - "/etc/httpd/conf.d/welcome.conf" + - "/etc/httpd/conf.d/ssl.conf" + +gnocchi_apache_conf: "/etc/httpd/conf/httpd.conf" +gnocchi_apache_security_conf: "{{ gnocchi_apache_conf }}" + diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml index ca786a4..4e88031 100644 --- a/vars/ubuntu-16.04.yml +++ b/vars/ubuntu-16.04.yml @@ -22,3 +22,19 @@ gnocchi_distro_packages: - build-essential - python-dev - libpq-dev + +gnocchi_system_service_name: apache2 + +gnocchi_apache_config: + - { src: "gnocchi-ports.conf.j2", dest: "/etc/apache2/ports.conf" } + - { src: "gnocchi-httpd.conf.j2", dest: "/etc/apache2/sites-available/gnocchi-httpd.conf" } + +gnocchi_apache_default_sites: + - "/etc/apache2/sites-enabled/000-default.conf" + +gnocchi_apache_site_available: "/etc/apache2/sites-available/gnocchi-httpd.conf" +gnocchi_apache_site_enabled: "/etc/apache2/sites-enabled/gnocchi-httpd.conf" + +gnocchi_apache_conf: "/etc/apache2/apache2.conf" +gnocchi_apache_security_conf: "/etc/apache2/conf-available/security.conf" +