feat: add owner and group params for clouds.yaml
* Add file_user and file_group parameters for clouds.yaml, to allow CLI usage for non root/sudoers users * Lint clouds.pp with Puppet VSCode Change-Id: I5cf20e496d36d702f9726b1694a09362fad50bbe
This commit is contained in:

committed by
Takashi Kajinami

parent
ee48d7a366
commit
2ca50984b1
@@ -47,7 +47,15 @@
|
||||
# Example: { 'identity' => '3', 'compute' => '2.latest' }
|
||||
# Defaults to {}
|
||||
#
|
||||
define openstacklib::clouds(
|
||||
# [*file_user*]
|
||||
# (Optional) User that owns the clouds.yaml file.
|
||||
# Defaults to 'root'.
|
||||
#
|
||||
# [*file_group*]
|
||||
# (Optional) Group that owns the clouds.yaml file.
|
||||
# Defaults to 'root'.
|
||||
#
|
||||
define openstacklib::clouds (
|
||||
String[1] $username,
|
||||
String[1] $password,
|
||||
Stdlib::HTTPUrl $auth_url,
|
||||
@@ -59,17 +67,17 @@ define openstacklib::clouds(
|
||||
Optional[Enum['public', 'internal', 'admin']] $interface = undef,
|
||||
Optional[String[1]] $region_name = undef,
|
||||
Hash $api_versions = {},
|
||||
String $file_user = 'root',
|
||||
String $file_group = 'root',
|
||||
) {
|
||||
|
||||
if !$project_name and !$system_scope {
|
||||
fail('One of project_name and system_scope should be set')
|
||||
}
|
||||
|
||||
file { $path:
|
||||
ensure => 'present',
|
||||
mode => '0600',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
owner => $file_user,
|
||||
group => $file_group,
|
||||
content => template('openstacklib/clouds.yaml.erb'),
|
||||
show_diff => false,
|
||||
}
|
||||
|
@@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``file_user`` and ``file_group`` parameters to ``openstacklib::clouds``
|
||||
resource to manage ``clouds.yaml`` file owner and group.
|
@@ -24,6 +24,27 @@ describe 'openstacklib::clouds' do
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with file owner/group' do
|
||||
let :params do
|
||||
{
|
||||
:username => 'admin',
|
||||
:password => 'secrete',
|
||||
:auth_url => 'http://127.0.0.1:5000/',
|
||||
:project_name => 'demo',
|
||||
:file_user => 'foo',
|
||||
:file_group => 'bar',
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates a clouds.yaml file with correct ownership' do
|
||||
should contain_file('/etc/openstack/clouds.yaml').with(
|
||||
:mode => '0600',
|
||||
:owner => 'foo',
|
||||
:group => 'bar',
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
|
Reference in New Issue
Block a user