You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.[Module Description - What the module does and why it is useful](#module-description)
11
9
3.[Setup - The basics of getting started with inifile module](#setup)
12
-
*[Setup requirements](#setup-requirements)
13
10
*[Beginning with inifile](#beginning-with-inifile)
14
11
4.[Usage - Configuration options and additional functionality](#usage)
15
12
5.[Reference - An under-the-hood peek at what the module is doing and how](#reference)
16
13
5.[Limitations - OS compatibility, etc.](#limitations)
17
14
6.[Development - Guide for contributing to the module](#development)
18
15
19
-
##Overview
16
+
##Overview
20
17
21
-
This module adds resource types to manage settings in INI-style configuration files.
18
+
The inifile module lets Puppet manage settings stored in INI-style configuration files.
22
19
23
20
##Module Description
24
21
25
-
The inifile module adds two resource types so that you can use Puppet to manage settings and subsettings in INI-style configuration files.
26
-
27
-
This module tries hard not to manipulate your file any more than it needs to. In most cases, it should leave the original whitespace, comments, ordering, etc. intact.
28
-
29
-
###Noteworthy module features include:
30
-
31
-
* Supports comments starting with either '#' or ';'.
32
-
* Supports either whitespace or no whitespace around '='.
33
-
* Adds any missing sections to the INI file.
22
+
Many applications use INI-style configuration files to store their settings. This module supplies two custom resource types to let you manage those settings through Puppet.
34
23
35
24
##Setup
36
25
37
-
##Beginning with inifile
26
+
###Beginning with inifile
38
27
39
-
To manage an INI file, add the resource type `ini_setting` or `ini_subsetting` to a class.
40
28
41
-
##Usage
29
+
To manage a single setting in an INI file, add the `ini_setting` type to a class:
42
30
43
-
Manage individual settings in INI files by adding the `ini_setting` resource type to a class. For example:
44
-
45
-
```
31
+
~~~
46
32
ini_setting { "sample setting":
47
33
ensure => present,
48
34
path => '/tmp/foo.ini',
49
-
section => 'foo',
50
-
setting => 'foosetting',
51
-
value => 'FOO!',
35
+
section => 'bar',
36
+
setting => 'baz',
37
+
value => 'quux',
52
38
}
53
-
```
39
+
~~~
40
+
41
+
##Usage
42
+
43
+
44
+
The inifile module tries hard not to manipulate your file any more than it needs to. In most cases, it doesn't affect the original whitespace, comments, ordering, etc.
54
45
55
-
To control multiple values in a setting, use `ini_subsetting`. For example:
56
46
57
-
```
47
+
* Supports comments starting with either '#' or ';'.
48
+
* Supports either whitespace or no whitespace around '='.
You can set up custom child providers that inherit the `ini_setting` provider. This allows you to implement custom resources to manage INI settings for specific configuration files without copying all the code or writing your own code from scratch. This also allows resource purging to be used.
72
+
You might want to create child providers that inherit the `ini_setting` provider, for one or both of these purposes:
74
73
75
-
To implement child providers, you'll need to specify your own type. This type needs to implement a namevar (name) and a property called value:
74
+
* Make a custom resource to manage an application that stores its settings in INI files, without recreating the code to manage the files themselves.
76
75
77
-
For example:
76
+
*[Purge all unmanaged settings](https://docs.puppetlabs.com/references/latest/type.html#resources-attribute-purge) from a managed INI file.
78
77
79
-
```
78
+
To implement child providers, first specify a custom type. Have it implement a namevar called `name` and a property called `value`:
79
+
80
+
~~~
80
81
#my_module/lib/puppet/type/glance_api_config.rb
81
82
Puppet::Type.newtype(:glance_api_config) do
82
83
ensurable
@@ -86,17 +87,17 @@ Puppet::Type.newtype(:glance_api_config) do
86
87
newvalues(/\S+\/\S+/)
87
88
end
88
89
newproperty(:value) do
89
-
desc 'The value of the setting to be defined.'
90
+
desc 'The value of the setting to define'
90
91
munge do |v|
91
92
v.to_s.strip
92
93
end
93
94
end
94
95
end
95
-
```
96
+
~~~
96
97
97
-
This type must also have a provider that uses the `ini_setting` provider as its parent. For example:
98
+
Your type also needs a provider that uses the `ini_setting` provider as its parent:
Now the individual settings of the /etc/glance/glance-api.conf file can be managed as individual resources:
122
+
Now the settings in /etc/glance/glance-api.conf file can be managed as individual resources:
122
123
123
-
```
124
+
~~~
124
125
glance_api_config { 'HEADER/important_config':
125
126
value => 'secret_value',
126
127
}
127
-
```
128
+
~~~
128
129
129
-
If the self.file_path has been implemented, you can purge with the following Puppet syntax:
130
+
If you've implemented self.file_path, you can have Puppet purge the file of all lines that aren't implemented as Puppet resources:
130
131
131
-
```
132
+
~~~
132
133
resources { 'glance_api_config'
133
134
purge => true,
134
135
}
135
-
```
136
-
137
-
If the above code is added, the resulting configured file will contain only lines implemented as Puppet resources.
136
+
~~~
138
137
139
138
##Reference
140
139
141
-
###Type: ini_setting
140
+
###Public Types
141
+
142
+
*[`ini_setting`](#type-ini_setting)
143
+
144
+
*[`ini_subsetting`](#type-ini_subsetting)
145
+
146
+
### Type: ini_setting
147
+
148
+
Manages a setting within an INI file.
142
149
143
150
#### Parameters
144
151
145
-
*`ensure`: Ensures that the resource is present. Valid values are 'present', 'absent'.
152
+
##### `ensure`
153
+
154
+
Determines whether the specified setting should exist. Valid options: 'present' and 'absent'. Default value: 'present'.
155
+
156
+
##### `key_val_separator`
157
+
158
+
*Optional.* Specifies a string to use between each setting name and value (e.g., to determine whether the separator includes whitespace). Valid options: a string. Default value: ' = '.
159
+
160
+
##### `name`
161
+
162
+
*Optional.* Specifies an arbitrary name to identify the resource. Valid options: a string. Default value: the title of your declared resource.
146
163
147
-
*`key_val_separator`: The separator string to use between each setting name and value. Defaults to ' = ', but you could use this to override the default (e.g., whether or not the separator should include whitespace).
164
+
##### `path`
148
165
149
-
*`name`: An arbitrary name used as the identity of the resource.
166
+
*Required.* Specifies an INI file containing the setting to manage. Valid options: a string containing an absolute path.
150
167
151
-
*`path`: The INI file in which Puppet ensures the specified setting.
168
+
##### `section`
152
169
153
-
*`provider`: The specific backend to use for this `ini_setting` resource. You will seldom need to specify this --- Puppet usually discovers the appropriate provider for your platform. The only available provider for `ini_setting` is ruby.
170
+
*Required.* Designates a section of the specified INI file containing the setting to manage. To manage a global setting (at the beginning of the file, before any named sections) enter "". Valid options: a string.
154
171
155
-
*`section`: The name of the INI file section in which the setting should be defined. Add a global section --- settings that appear at the beginning of the file, before any named sections --- by specifying a section name of "".
172
+
##### `setting`
156
173
157
-
*`setting`: The name of the INI file setting to be defined.
174
+
*Required.* Designates a setting to manage within the specified INI file and section. Valid options: a string.
158
175
159
-
*`value`: The value of the INI file setting to be defined.
176
+
#####`value`
160
177
161
-
###Type: ini_subsetting
178
+
*Optional.* Supplies a value for the specified setting. Valid options: a string. Default value: undefined.
179
+
180
+
### Type: ini_subsetting
181
+
182
+
183
+
Manages multiple values within the same INI setting.
162
184
163
185
#### Parameters
164
186
165
-
*`ensure`: Ensures that the resource is present. Valid values are 'present', 'absent'.
187
+
#####`ensure`
166
188
167
-
*`key_val_separator`: The separator string to use between each setting name and value. Defaults to ' = ', but you could use this to override the default (e.g., whether or not the separator should include whitespace).
189
+
Specifies whether the subsetting should be present. Valid options: 'present' and 'absent'. Default value: 'present'.
168
190
169
-
*`name`: An arbitrary name used as the identity of the resource.
191
+
##### `key_val_separator`
170
192
171
-
*`path`: The INI file in which Puppet ensures the specified setting.
193
+
*Optional.* Specifies a string to use between subsetting name and value (e.g., to determine whether the separator includes whitespace). Valid options: a string. Default value: ' = '.
172
194
173
-
*`provider`: The specific backend to use for this `ini_subsetting` resource. You will seldom need to specify this --- Puppet usually discovers the appropriate provider for your platform. The only available provider for `ini_subsetting` is ruby.
195
+
##### `path`
174
196
175
-
*`quote_char`: The character used to quote the entire value of the setting. Valid values are '', '"', and "'". Defaults to ''.
197
+
*Required.* Specifies an INI file containing the subsetting to manage. Valid options: a string containing an absolute path.
176
198
177
-
*`section`: The name of the INI file section in which the setting should be defined. Add a global section --- settings that appear at the beginning of the file, before any named sections --- by specifying a section name of "".
199
+
##### `quote_char`
178
200
179
-
*`setting`: The name of the INI file settingto be defined.
201
+
*Optional.*The character used to quote the entire value of the setting. Valid values are '', '"', and "'". Defaults to ''. Valid options: '', '"' and "'". Default value: ''.
180
202
181
-
*`subsetting`: The name of the INI file subsetting to be defined.
203
+
##### `section`
182
204
183
-
*`subsetting_separator`: The separator string used between subsettings. Defaults to " ".
205
+
*Required.* Designates a section of the specified INI file containing the subsetting to manage. To manage a global setting (at the beginning of the file, before any named sections) enter "". Valid options: a string, or "".
184
206
185
-
*`value`: The value of the INI file subsetting to be defined.
207
+
##### `setting`
186
208
187
-
##Limitations
209
+
*Required.* Designates a setting within the specified section containing the subsetting to manage. Valid options: a string.
188
210
189
-
This module is officially [supported](https://forge.puppetlabs.com/supported) on :
211
+
##### `subsetting`
190
212
191
-
* Red Hat Enterprise Linux (RHEL) 5, 6, 7
192
-
* CentOS 5, 6, 7
193
-
* Oracle Linux 5, 6, 7
194
-
* Scientific Linux 5, 6, 7
195
-
* SLES 11 SP1 or greater
196
-
* Debian 6, 7
197
-
* Ubuntu 10.04 LTS, 12.04 LTS, 14.04 LTS
198
-
* Solaris 10, 11
199
-
* Windows Server 2003/2008 R2, 2012/2012 R2
200
-
* AIX 5.3, 6.1, 7.1
213
+
*Required.* Designates a subsetting to manage within the specified setting. Valid options: a string.
201
214
202
-
This module has also been tested, but is not officially supported, on:
203
215
204
-
* Red Hat Enterprise Linux (RHEL) 4
205
-
* Windows 7
206
-
* Mac OSX 10.9 (Mavericks)
216
+
##### `subsetting_separator`
207
217
208
-
### Agent run failure with Puppet Enterprise
218
+
*Optional.* Specifies a string to use between subsettings. Valid options: a string. Default value: " ".
209
219
210
-
As of Puppet Enterprise 3.3, agent runs on master fail if you are using an older, manually installed version of inifile. To solve this problem, upgrade your inifile module to version 1.1.0 or later.
220
+
##### `value`
211
221
212
-
##Development
213
-
214
-
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
222
+
*Optional.* Supplies a value for the specified subsetting. Valid options: a string. Default value: undefined.
215
223
216
-
We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
224
+
##Limitations
217
225
218
-
You can read the complete module contribution guide in [CONTRIBUTING.md](./CONTRIBUTING.md)
226
+
This module has been tested on [all PE-supported platforms](https://forge.puppetlabs.com/supported#compat-matrix), and no issues have been identified. Additionally, it is tested (but not supported) on Windows 7 and Mac OS X 10.9.
219
227
220
-
##Contributors
228
+
##Development
221
229
222
-
The list of contributors can be found at: [https://github.com/puppetlabs/puppetlabs-inifile/graphs/contributors](https://github.com/puppetlabs/puppetlabs-inifile/graphs/contributors).
230
+
#Development
223
231
232
+
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
233
+
234
+
We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
224
235
236
+
For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html)
225
237
238
+
###Contributors
226
239
240
+
To see who's already involved, see the [list of contributors.](https://github.com/puppetlabs/puppetlabs-inifile/graphs/contributors)
0 commit comments