diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0dba11b..2b73acc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,6 @@ jobs: "amazonlinux-2023", "centos-stream-9", "centos-stream-10", - "debian-11", "debian-12", "rockylinux-8", "rockylinux-9", diff --git a/documentation/nginx_config.md b/documentation/nginx_config.md index df42f61b..8978a290 100644 --- a/documentation/nginx_config.md +++ b/documentation/nginx_config.md @@ -21,6 +21,9 @@ | `group` | String | `root` | Nginx run-as/file/folder group. | | `mode` | String | `0640` | Nginx configuration file mode. | | `folder_mode` | String | `0750` | Nginx configuration folder mode. | +| `log_dir_mode` | String | `0755` | Nginx log directory mode. | +| `log_dir_owner` | String | `root` | Nginx log directory owner. | +| `log_dir_group` | String | `root` | Nginx log directory group. | | `process_user` | String | `www-data` (Debian) or `nginx` | Nginx run-as user. | | `process_group` | String | `www-data` (Debian) or `nginx` | Nginx run-as group. | | `worker_processes` | Integer, String | `auto` | The number of worker processes. | @@ -43,3 +46,15 @@ nginx_config 'nginx' do notifies :reload, 'nginx_service[nginx]', :delayed end ``` + +### Using custom log directory permissions + +```ruby +nginx_config 'nginx' do + log_dir_mode '0750' + log_dir_owner 'nginx' + log_dir_group 'nginx' + action :create + notifies :reload, 'nginx_service[nginx]', :delayed +end +``` diff --git a/resources/config.rb b/resources/config.rb index 90a0bdb2..3fe73ea7 100644 --- a/resources/config.rb +++ b/resources/config.rb @@ -64,6 +64,18 @@ description: 'Folder mode', default: '0750' +property :log_dir_mode, String, + description: 'Log directory mode', + default: lazy { platform_family?('debian') ? '0755' : '0750' } + +property :log_dir_owner, String, + description: 'Log directory owner', + default: lazy { owner } + +property :log_dir_group, String, + description: 'Log directory group', + default: lazy { group } + property :process_user, String, description: 'Nginx process user', default: lazy { nginx_user } @@ -146,9 +158,9 @@ def default_site_enabled? end directory nginx_log_dir do - owner new_resource.owner - group new_resource.group - mode new_resource.folder_mode + owner new_resource.log_dir_owner + group new_resource.log_dir_group + mode new_resource.log_dir_mode end %w(default.conf example_ssl.conf).each do |config| diff --git a/spec/unit/resources/config_spec.rb b/spec/unit/resources/config_spec.rb index d210ce76..cab5af76 100644 --- a/spec/unit/resources/config_spec.rb +++ b/spec/unit/resources/config_spec.rb @@ -51,4 +51,32 @@ it { is_expected.to create_directory('/etc/nginx/conf.d').with_mode('0750') } it { is_expected.to create_directory('/etc/nginx/conf.http.d').with_mode('0750') } end + + context 'with custom log directory properties' do + recipe do + nginx_install 'distro' + nginx_config 'default' do + log_dir_mode '0750' + log_dir_owner 'nginx' + log_dir_group 'nginx' + end + end + + it { is_expected.to create_directory('/var/log/nginx').with_mode('0750').with_owner('nginx').with_group('nginx') } + it { is_expected.to create_directory('/etc/nginx/conf.d').with_mode('0750') } + it { is_expected.to create_directory('/etc/nginx/conf.http.d').with_mode('0750') } + end + + context 'on debian platform' do + platform 'ubuntu' + + recipe do + nginx_install 'distro' + nginx_config 'default' + end + + it { is_expected.to create_directory('/var/log/nginx').with_mode('0755').with_owner('root') } + it { is_expected.to create_directory('/etc/nginx/conf.d').with_mode('0750') } + it { is_expected.to create_directory('/etc/nginx/conf.http.d').with_mode('0750') } + end end