From 09dcc00481da401979851dc8d2c767f68ca8c376 Mon Sep 17 00:00:00 2001 From: Himani Deshpande Date: Thu, 25 Apr 2024 20:37:58 -0400 Subject: [PATCH] [AL2023] Adding installation of rsyslog and enabling the service --- .../kitchen.platform-install.yml | 10 +++++++ .../recipes/install/enable_services.rb | 27 +++++++++++++++++++ .../install_packages_alinux2023.rb | 2 +- .../spec/unit/recipes/enable_services_spec.rb | 16 +++++++++++ .../test/controls/enable_services_spec.rb | 9 +++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 cookbooks/aws-parallelcluster-platform/recipes/install/enable_services.rb create mode 100644 cookbooks/aws-parallelcluster-platform/spec/unit/recipes/enable_services_spec.rb create mode 100644 cookbooks/aws-parallelcluster-platform/test/controls/enable_services_spec.rb diff --git a/cookbooks/aws-parallelcluster-platform/kitchen.platform-install.yml b/cookbooks/aws-parallelcluster-platform/kitchen.platform-install.yml index 8bc608fc58..eeca5d793b 100644 --- a/cookbooks/aws-parallelcluster-platform/kitchen.platform-install.yml +++ b/cookbooks/aws-parallelcluster-platform/kitchen.platform-install.yml @@ -309,3 +309,13 @@ suites: verifier: controls: - /tag:install_users/ + - name: enable_services + run_list: + - recipe[aws-parallelcluster-tests::setup] + - recipe[aws-parallelcluster-platform::enable_services] + verifier: + controls: + - /install_service_is_enabled/ + attributes: + dependencies: + - resource:install_packages:install_base_packages diff --git a/cookbooks/aws-parallelcluster-platform/recipes/install/enable_services.rb b/cookbooks/aws-parallelcluster-platform/recipes/install/enable_services.rb new file mode 100644 index 0000000000..5be4012515 --- /dev/null +++ b/cookbooks/aws-parallelcluster-platform/recipes/install/enable_services.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# +# Cookbook:: aws-parallelcluster-platform +# Recipe:: disable_services +# +# Copyright:: 2013-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the +# License. A copy of the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES +# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and +# limitations under the License. + +# If the service does not exist the action disable does not return error. +# Masking the service in order to prevent it from being automatically enabled if not installed yet. + +# on alinux2023, enable ryslog +service 'rsyslog' do + supports restart: true + action %i(enable start) + retries 5 + retry_delay 10 +end unless on_docker? diff --git a/cookbooks/aws-parallelcluster-platform/resources/install_packages/install_packages_alinux2023.rb b/cookbooks/aws-parallelcluster-platform/resources/install_packages/install_packages_alinux2023.rb index de983bded0..c9bef1f32e 100644 --- a/cookbooks/aws-parallelcluster-platform/resources/install_packages/install_packages_alinux2023.rb +++ b/cookbooks/aws-parallelcluster-platform/resources/install_packages/install_packages_alinux2023.rb @@ -43,7 +43,7 @@ def default_packages libical-devel sendmail libxml2-devel libglvnd-devel libgcrypt-devel libevent-devel glibc-static bind-utils iproute python3 python3-pip libcurl-devel - coreutils environment-modules gcc gcc-c++ bzip2 iptables vim yum-plugin-versionlock) + coreutils environment-modules gcc gcc-c++ bzip2 iptables vim yum-plugin-versionlock rsyslog) end def unsupported_packages diff --git a/cookbooks/aws-parallelcluster-platform/spec/unit/recipes/enable_services_spec.rb b/cookbooks/aws-parallelcluster-platform/spec/unit/recipes/enable_services_spec.rb new file mode 100644 index 0000000000..48454fe408 --- /dev/null +++ b/cookbooks/aws-parallelcluster-platform/spec/unit/recipes/enable_services_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'aws-parallelcluster-platform::enable_services' do + for_all_oses do |platform, version| + context "on #{platform}#{version}" do + cached(:chef_run) do + runner(platform: platform, version: version).converge(described_recipe) + end + + it 'enables ryslog' do + is_expected.to enable_service('rsyslog') + is_expected.to start_service('rsyslog') + end + end + end +end diff --git a/cookbooks/aws-parallelcluster-platform/test/controls/enable_services_spec.rb b/cookbooks/aws-parallelcluster-platform/test/controls/enable_services_spec.rb new file mode 100644 index 0000000000..341549bdce --- /dev/null +++ b/cookbooks/aws-parallelcluster-platform/test/controls/enable_services_spec.rb @@ -0,0 +1,9 @@ +control 'tag:install_service_is_enabled' do + only_if { !os_properties.on_docker? } + + describe service('rsyslog') do + it { should be_installed } + it { should be_enabled } + it { should be_running } + end +end