Skip to content

Commit 1ae0a10

Browse files
committed
Merge pull request #388 from mhaskel/merge_4.5.x_into_master
Merge 4.5.x into master
2 parents be46f0e + 49acade commit 1ae0a10

File tree

5 files changed

+44
-33
lines changed

5 files changed

+44
-33
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
##2014-12-15 - Supported Release 4.5.0
2+
###Summary
3+
4+
This release improves functionality of the member function and adds improved future parser support.
5+
6+
####Features
7+
- MODULES-1329: Update member() to allow the variable to be an array.
8+
- Sync .travis.yml, Gemfile, Rakefile, and CONTRIBUTING.md via modulesync
9+
10+
####Bugfixes
11+
- Fix range() to work with numeric ranges with the future parser
12+
- Accurately express SLES support in metadata.json (was missing 10SP4 and 12)
13+
- Don't require `line` to match the `match` parameter
14+
115
##2014-11-10 - Supported Release 4.4.0
216
###Summary
317
This release has an overhauled readme, new private manifest function, and fixes many future parser bugs.

README.markdown

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ After you've installed stdlib, all of its functions, facts, and resources are av
4040

4141
If you want to use a standardized set of run stages for Puppet, `include stdlib` in your manifest.
4242

43-
##Reference
43+
## Reference
4444

4545
### Classes
4646

@@ -75,7 +75,30 @@ If you want to use a standardized set of run stages for Puppet, `include stdlib`
7575
class { java: stage => 'runtime' }
7676
}
7777
```
78+
79+
### Resources
7880

81+
* `file_line`: This resource ensures that a given line, including whitespace at the beginning and end, is contained within a file. If the line is not contained in the given file, Puppet will add the line. Multiple resources can be declared to manage multiple lines in the same file. You can also use match to replace existing lines.
82+
83+
```
84+
file_line { 'sudo_rule':
85+
path => '/etc/sudoers',
86+
line => '%sudo ALL=(ALL) ALL',
87+
}
88+
file_line { 'sudo_rule_nopw':
89+
path => '/etc/sudoers',
90+
line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
91+
}
92+
```
93+
94+
* `after`: Specify the line after which Puppet will add any new lines. (Existing lines are added in place.) Optional.
95+
* `ensure`: Ensures whether the resource is present. Valid values are 'present', 'absent'.
96+
* `line`: The line to be added to the file located by the `path` parameter.
97+
* `match`: A regular expression to run against existing lines in the file; if a match is found, we replace that line rather than adding a new line. Optional.
98+
* `multiple`: Determine if match can change multiple lines. Valid values are 'true', 'false'. Optional.
99+
* `name`: An arbitrary name used as the identity of the resource.
100+
* `path`: The file in which Puppet will ensure the line specified by the line parameter.
101+
79102
### Functions
80103

81104
* `abs`: Returns the absolute value of a number; for example, '-34.56' becomes '34.56'. Takes a single integer and float value as an argument. *Type*: rvalue
@@ -165,25 +188,6 @@ also appear in the second array. For example, `difference(["a","b","c"],["b","c"
165188

166189
*Type*: statement
167190

168-
* `file_line`: This resource ensures that a given line is contained within a file. You can also use match to replace existing lines.
169-
170-
*Example:*
171-
172-
```
173-
file_line { 'sudo_rule':
174-
path => '/etc/sudoers',
175-
line => '%sudo ALL=(ALL) ALL',
176-
}
177-
178-
file_line { 'change_mount':
179-
path => '/etc/fstab',
180-
line => '10.0.0.1:/vol/data /opt/data nfs defaults 0 0',
181-
match => '^172.16.17.2:/vol/old',
182-
}
183-
```
184-
185-
*Type*: resource
186-
187191
* `flatten`: This function flattens any deeply nested arrays and returns a single flat array as a result. For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c']. *Type*: rvalue
188192

189193
* `floor`: Returns the largest integer less than or equal to the argument.
@@ -321,7 +325,7 @@ returns the value of the resource's parameter. For example, the following code r
321325

322326
* `max`: Returns the highest value of all arguments. Requires at least one argument. *Type*: rvalue
323327

324-
* `member`: This function determines if a variable is a member of an array. For example, `member(['a','b'], 'b')` returns 'true', while `member(['a','b'], 'c')` returns 'false'. *Type*: rvalue
328+
* `member`: This function determines if a variable is a member of an array. The variable can be either a string, array, or fixnum. For example, `member(['a','b'], 'b')` and `member(['a','b','c'], ['b','c'])` return 'true', while `member(['a','b'], 'c')` and `member(['a','b','c'], ['c','d'])` return 'false'. *Type*: rvalue
325329

326330
* `merge`: Merges two or more hashes together and returns the resulting hash.
327331

lib/puppet/type/file_line.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,5 @@
7171
unless self[:line] and self[:path]
7272
raise(Puppet::Error, "Both line and path are required attributes")
7373
end
74-
75-
if (self[:match])
76-
unless Regexp.new(self[:match]).match(self[:line])
77-
raise(Puppet::Error, "When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter")
78-
end
79-
end
80-
8174
end
8275
end

metadata.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "puppetlabs-stdlib",
3-
"version": "4.4.0",
3+
"version": "4.5.0",
44
"author": "puppetlabs",
55
"summary": "Standard library of resources for Puppet modules.",
6-
"license": "Apache 2.0",
7-
"source": "git://github.com/puppetlabs/puppetlabs-stdlib",
6+
"license": "Apache-2.0",
7+
"source": "https://github.com/puppetlabs/puppetlabs-stdlib",
88
"project_page": "https://github.com/puppetlabs/puppetlabs-stdlib",
99
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
1010
"operatingsystem_support": [

spec/unit/puppet/type/file_line_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
file_line[:match] = '^foo.*$'
1616
expect(file_line[:match]).to eq('^foo.*$')
1717
end
18-
it 'should not accept a match regex that does not match the specified line' do
18+
it 'should accept a match regex that does not match the specified line' do
1919
expect {
2020
Puppet::Type.type(:file_line).new(
2121
:name => 'foo',
2222
:path => '/my/path',
2323
:line => 'foo=bar',
2424
:match => '^bar=blah$'
25-
)}.to raise_error(Puppet::Error, /the value must be a regex that matches/)
25+
)}.not_to raise_error
2626
end
2727
it 'should accept a match regex that does match the specified line' do
2828
expect {

0 commit comments

Comments
 (0)