Skip to content

Commit

Permalink
[SIMP-7864] Multiple fixes (#13)
Browse files Browse the repository at this point in the history
- Fixed the README
- Added REFERENCE.md
- Allow users to set custom settings via Hiera
- Fix `ensure = absent` in `dconf::settings`

SIMP-7864 #close

Co-authored-by: jeannegreulich <[email protected]>
  • Loading branch information
trevor-vaughan and jeannegreulich authored Jul 21, 2020
1 parent 4fe75c9 commit 8b6f565
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 61 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
* Wed Dec 11 2019 Trevor Vaughan <[email protected]> - 0.1.0
* Tue Jul 14 2020 Trevor Vaughan <[email protected]> - 0.1.0
- Add EL8 support
- Add REFERENCE.md
- Fixed the README
- Added REFERENCE.md
- Allow users to set custom settings via Hiera
- Fix `ensure = absent` in `dconf::settings`

* Fri Aug 02 2019 Robert Vincent <[email protected]> - 0.1.0
- Remove Puppet 4.x support
Expand Down
80 changes: 72 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
* [This is a SIMP module](#this-is-a-simp-module)
* [Setup](#setup)
* [Usage](#usage)
* [Configuring custom rules](#configuring-custom-rules)
* [> to prevent users from modifying them!](#-to-prevent-users-from-modifying-them)
* [Using `puppet`](#using-puppet)
* [Using `hiera`](#using-hiera)
* [Configuring custom profiles](#configuring-custom-profiles)
* [Using `puppet`](#using-puppet-1)
* [Globally With `hiera`](#globally-with-hiera)
* [Reference](#reference)
* [Limitations](#limitations)
* [Development](#development)
Expand Down Expand Up @@ -49,17 +56,74 @@ include 'dconf'

## Usage

All `dconf` settings are locked by default so that users can't change them.
### Configuring custom rules

This can be disabled on a per setting basis, like in this entry for wallpaper
taken from the `simp-gnome` module.
You can configure custom ``dconf`` settings using the ``dconf::settings``
defined type.

---
> Any settings that are configured using this code will automatically be locked
> to prevent users from modifying them!
---

#### Using `puppet`

```puppet
dconf::settings { 'automount_lockdowns':
settings_hash => {
'org/gnome/desktop/media-handling' => {
'automount' => { 'value' => false, 'lock' => false } # allow users to change this one
'automount-open' => { 'value' => false }
}
}
}
```

#### Using `hiera`

```yaml
---
dconf::user_settings:
settings_hash:
org/gnome/desktop/media-handling:
automount:
value: false
lock: false # allow users to change this one
automount-open:
value: false
```
### Configuring custom profiles
You can set up a custom [dconf profile](https://help.gnome.org/admin//system-admin-guide/3.8/dconf-profiles.html.en) as follows:
#### Using `puppet`

```puppet
dconf::profile { 'my_profile':
entries => {
'user' => {
'type' => 'user',
'order' => 1
},
'system' => {
'type' => 'system',
'order' => 10
}
}
```

#### Globally With `hiera`

```yaml
gnome::dconf_hash:
org/dconf/desktop/background:
picture-uri:
value: file:///usr/local/corp/puppies.jpg
lock: false
---
dconf::user_profile:
my_user:
type: user
order: 0
my_system:
type: system
order: 10
```

## Reference
Expand Down
67 changes: 52 additions & 15 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _Private Classes_
**Defined types**

* [`dconf::profile`](#dconfprofile): Updates a ``dconf`` profile entry to ``/etc/dconf/profile/$name``
* [`dconf::settings`](#dconfsettings): Add a dconf rule to the profile of your choice This adds a configuration file to the /etc/dconf/db/<profile>.d directory. The dconf datbase
* [`dconf::settings`](#dconfsettings): Add a dconf rule to the profile of your choice This adds a configuration file to the /etc/dconf/db/<profile>.d directory. The dconf database

**Data types**

Expand All @@ -37,10 +37,18 @@ The following parameters are available in the `dconf` class.

Data type: `Dconf::DBSettings`

The contents of the user profile that will be added
The contents of the default user profile that will be added

@see data/common.yaml

##### `user_settings`

Data type: `Optional[Dconf::SettingsHash]`

Custom user settings that can be provided via Hiera globally

Default value: `undef`

##### `package_ensure`

Data type: `Simplib::PackageEnsure`
Expand All @@ -59,6 +67,15 @@ Add the default `user_profile` settings to the system

Default value: `true`

##### `user_profile_defaults_name`

Data type: `String[1]`

The name that should be used for the custom `dconf::profile` in
`user_profile`

Default value: 'Defaults'

##### `user_profile_target`

Data type: `String[1]`
Expand All @@ -67,6 +84,23 @@ The name of the profile that should be targeted for the defaults

Default value: 'user'

##### `use_user_settings_defaults`

Data type: `Boolean`

Enable creation of custom `dconf::settings` based on the `user_settings` Hash

Default value: $use_user_profile_defaults

##### `user_settings_defaults_name`

Data type: `String[1]`

The name that should be used for the custom 'dconf::settings' as well as
the target profile for those settings

Default value: $user_profile_defaults_name

## Defined types

### dconf::profile
Expand Down Expand Up @@ -129,7 +163,7 @@ Default value: '/etc/dconf/profile'
Add a dconf rule to the profile of your choice

This adds a configuration file to the /etc/dconf/db/<profile>.d directory.
The dconf datbase is updated when any rule is added. You can also elect to
The dconf database is updated when any rule is added. You can also elect to
lock a value so that general users cannot change it.

#### Parameters
Expand All @@ -140,29 +174,32 @@ The following parameters are available in the `dconf::settings` defined type.

Data type: `Dconf::SettingsHash`

A hash to define the settings to be generated. You can set
whether to lock each setting like in the exmaple
An example hash would look like:
```
{
'org/gnome/desktop/media-handling' => {
'automount' => { 'value' => false, 'lock' => false },
'automount-open' => { 'value' => false }
A Hash to define the settings to be generated. You can set whether to lock
each setting like in the exmaple

@example
{
'org/gnome/desktop/media-handling' => {
'automount' => { 'value' => false, 'lock' => false },
'automount-open' => { 'value' => false }
}
}
}
```

Default value: {}

##### `profile`

Data type: `String[1]`
Data type: `Optional[String[1]]`

The dconf profile where you want to place the key/value.

Default value: `undef`

##### `ensure`

Data type: `Enum['present','absent']`

Ensure the setting is present or absent
Ensure the entire settings Hash is present or absent

Default value: 'present'

Expand Down
42 changes: 36 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Manage 'dconf' and associated entries
#
# @param user_profile
# The contents of the user profile that will be added
# The contents of the default user profile that will be added
#
# @see data/common.yaml
#
# @param user_settings
# Custom user settings that can be provided via Hiera globally
#
# @param package_ensure
# The version of `dconf` to install
#
Expand All @@ -13,23 +16,50 @@
# @param use_user_profile_defaults
# Add the default `user_profile` settings to the system
#
# @param user_profile_defaults_name
# The name that should be used for the custom `dconf::profile` in
# `user_profile`
#
# @param user_profile_target
# The name of the profile that should be targeted for the defaults
#
# @param use_user_settings_defaults
# Enable creation of custom `dconf::settings` based on the `user_settings` Hash
#
# @param user_settings_defaults_name
# The name that should be used for the custom 'dconf::settings' as well as
# the target profile for those settings
#
class dconf (
Dconf::DBSettings $user_profile,
Simplib::PackageEnsure $package_ensure = simplib::lookup('simp_options::package_ensure', { 'default_value' => 'installed' }),
Boolean $use_user_profile_defaults = true,
String[1] $user_profile_target = 'user'
Dconf::DBSettings $user_profile,
Optional[Dconf::SettingsHash] $user_settings = undef,
Simplib::PackageEnsure $package_ensure = simplib::lookup('simp_options::package_ensure', { 'default_value' => 'installed' }),
Boolean $use_user_profile_defaults = true,
String[1] $user_profile_defaults_name = 'Defaults',
String[1] $user_profile_target = 'user',
Boolean $use_user_settings_defaults = $use_user_profile_defaults,
String[1] $user_settings_defaults_name = $user_profile_defaults_name
) {
simplib::assert_metadata($module_name)

include 'dconf::install'

if $use_user_profile_defaults {
dconf::profile { 'Defaults':
dconf::profile { $user_profile_defaults_name:
target => $user_profile_target,
entries => $user_profile
}
}

if $user_settings and $use_user_settings_defaults {
dconf::settings { $user_settings_defaults_name:
settings_hash => $user_settings,
profile => $user_settings_defaults_name
}
}
else {
dconf::settings { $user_settings_defaults_name:
ensure => 'absent'
}
}
}
Loading

0 comments on commit 8b6f565

Please sign in to comment.