From e9f75bf8609714a70f65ad65bc6d5c0c05c6897a Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Thu, 14 Sep 2017 15:21:33 -0600 Subject: [PATCH] Ensure sysstat is running on CentOS This patch fixes sysstat on CentOS so that it runs properly. Closes-Bug: 1717361 Change-Id: If95b0e02d7863291f88b67909128439599660ad0 --- defaults/main.yml | 3 +++ ...tos-opensuse-running-0be396c60a513562.yaml | 8 ++++++++ tasks/openstack_sysstat.yml | 19 +++++++++++++++++-- vars/redhat-7.yml | 2 ++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/sysstat-centos-opensuse-running-0be396c60a513562.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 8e2448fd..86e2adc6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -104,6 +104,9 @@ openstack_domain: openstack.local # Global environment variables should be empty by default global_environment_variables: {} +# Set the default mode for the /etc/cron.d/sysstat file +openstack_host_sysstat_cron_mode: '0755' + # Set default mirror for CentOS repositories # NOTE(mhayden): Ensure that the full path to the 'centos' directory is used. #openstack_hosts_centos_mirror_url: 'http://mirror.centos.org/centos' diff --git a/releasenotes/notes/sysstat-centos-opensuse-running-0be396c60a513562.yaml b/releasenotes/notes/sysstat-centos-opensuse-running-0be396c60a513562.yaml new file mode 100644 index 00000000..732a58f2 --- /dev/null +++ b/releasenotes/notes/sysstat-centos-opensuse-running-0be396c60a513562.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + The ``sysstat`` package was installed on all distributions, but it was + only configured to run on Ubuntu and OpenSUSE. It would not run on CentOS + due to bad SELinux contexts and file permissions on + ``/etc/cron.d/sysstat``. This has been fixed and ``sysstat`` now runs + properly on CentOS. diff --git a/tasks/openstack_sysstat.yml b/tasks/openstack_sysstat.yml index 063f1f95..f22407a4 100644 --- a/tasks/openstack_sysstat.yml +++ b/tasks/openstack_sysstat.yml @@ -20,13 +20,28 @@ mode: "0644" when: - openstack_host_sysstat_enabled | bool - - ansible_os_family == "Debian" + - ansible_pkg_mgr == 'apt' notify: Restart sysstat - name: Enable sysstat cron template: src: "{{ openstack_host_cron_template }}" dest: "/etc/cron.d/sysstat" - mode: "0755" + mode: "{{ openstack_host_sysstat_cron_mode }}" when: - openstack_host_sysstat_enabled | bool + +- name: Restore SELinux contexts on sysstat cron file + command: restorecon -v /etc/cron.d/sysstat + when: + - openstack_host_sysstat_enabled | bool + - ansible_pkg_mgr in ['yum', 'dnf'] + +- name: Start and enable the sysstat service + service: + name: sysstat + state: started + enabled: yes + when: + - openstack_host_sysstat_enabled | bool + - ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 52c9a240..c3c3e860 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -19,6 +19,8 @@ openstack_host_sysstat_file: /etc/sysconfig/sysstat openstack_host_cron_template: sysstat.cron.redhat.j2 openstask_host_module_file: /etc/modules-load.d/openstack-ansible.conf +openstack_host_sysstat_cron_mode: '0600' + ## Kernel modules loaded on hosts openstack_host_kernel_modules: - 8021q