Skip to content

Commit

Permalink
do not use file resource, when concat is in use for ftpasswd file
Browse files Browse the repository at this point in the history
  • Loading branch information
saz committed Jun 12, 2024
1 parent 1b67b41 commit e7d24fa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 27 deletions.
40 changes: 19 additions & 21 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@
# get the first argument and only use that for creating the file (don't use spaces in filename)
$authuserfile = split($real_options['Global']['AuthUserFile'], ' ')[0]

$authuser_require = File[$authuserfile]
if !defined(File[$authuserfile]) {
file { $authuserfile:
source => $proftpd::authuserfile_source,
owner => $proftpd::user,
group => $proftpd::group,
mode => '0600',
before => File[$proftpd::config],
if !$proftpd::manage_ftpasswd_file {
$authuser_require = File[$authuserfile]
if !defined(File[$authuserfile]) {
file { $authuserfile:
source => $proftpd::authuserfile_source,
owner => $proftpd::user,
group => $proftpd::group,
mode => '0600',
before => File[$proftpd::config],
}
}
} else {
$authuser_require = false
}
} else {
$authuser_require = false
Expand Down Expand Up @@ -127,28 +131,22 @@
}

concat { $modules_config:
warn => true,
owner => $proftpd::config_user,
group => $proftpd::config_group,
# modules may be required for validate_cmd to succeed
before => File[$proftpd::config],
notify => Class[proftpd::service],
}

concat::fragment { 'proftp_modules_header':
target => "${proftpd::base_dir}/modules.conf",
content => "# File is managed by Puppet\n",
order => '01',
}
}
if $proftpd::manage_ftpasswd_file {
concat { $proftpd::ftpasswd_file:
mode => $proftpd::config_mode,
owner => $proftpd::user,
group => $proftpd::group,
}
concat::fragment { '01-ftpasswd_file-header':
target => $proftpd::ftpasswd_file,
content => "### Managed by Puppet - Changes will be lost\n",
warn => true,
mode => '0600',
owner => $proftpd::user,
group => $proftpd::group,
before => File[$proftpd::config],
notify => Class[proftpd::service],
}
}
}
4 changes: 0 additions & 4 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@
it { is_expected.to contain_package(expected_packages.first) }
it { is_expected.to contain_service(expected_service_name) }
it { is_expected.to contain_concat("#{expected_base_dir}/modules.conf") }
it do
is_expected.to contain_concat__fragment('proftp_modules_header')
.with_target("#{expected_base_dir}/modules.conf")
end
end
context 'with manage_ftpasswd_file set to true' do
let(:params) do
Expand Down
2 changes: 0 additions & 2 deletions spec/defines/ftpasswd_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_concat(expected_ftpasswd_file) }
it { is_expected.to contain_concat__fragment('01-ftpasswd_file-header') }
it do
is_expected.to contain_concat__fragment('10-entry-foobar')
.with_content(%r{foobar:123456:1001:1001:foobar:/home/foobar:/bin/false})
Expand All @@ -57,7 +56,6 @@

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_concat(expected_ftpasswd_file) }
it { is_expected.to contain_concat__fragment('01-ftpasswd_file-header') }
it do
is_expected.to contain_concat__fragment('10-entry-foobar')
.with_content(%r{foobar:123456:1001:1001:Foobar user:/var/www/html:/bin/ksh})
Expand Down

0 comments on commit e7d24fa

Please sign in to comment.