Skip to content

4.21.0 release merge back #835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org).

## Supported Release 4.21.0
### Summary

This is a small feature release that includes a revamped, albeit backwards-compatible file_line type.

#### Added
- `replace_all_matches_not_matching_line` parameter in file_line
- additional tests and documentation for file_line

#### Removed
- duplicate spec test for absolute_path

#### Fixed
- Unixpath type to allow "/" as valid path
- file_line behavior that caused infinite appending of `line` to a file ([MODULES-5651](https://tickets.puppet.com/browse/MODULES-5651))

## Supported Release 4.20.0
### Summary

Expand Down
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,17 @@ file_line { 'bashrc_proxy':
}
```

In this code example, `match` looks for a line beginning with export followed by HTTP_PROXY and replaces it with the value in line. If a match is not found, then no changes are made to the file.
In this code example, `match` looks for a line beginning with export followed by 'HTTP_PROXY' and replaces it with the value in line. If a match is not found, then no changes are made to the file.

Examples With `ensure => absent`:
Examples of `ensure => absent`:

This type has two behaviors when `ensure => absent` is set.

One possibility is to set `match => ...` and `match_for_absence => true`,
as in the following example:
The first is to set `match => ...` and `match_for_absence => true`. Match looks for a line beginning with 'export', followed by 'HTTP_PROXY', and then deletes it. If multiple lines match, an error is raised unless the `multiple => true` parameter is set.

The `line => ...` parameter in this example would be accepted but ignored.

For example:

```puppet
file_line { 'bashrc_proxy':
Expand All @@ -145,15 +148,9 @@ file_line { 'bashrc_proxy':
}
```

In this code example match will look for a line beginning with export
followed by HTTP_PROXY and delete it. If multiple lines match, an
error will be raised unless the `multiple => true` parameter is set.
The second way of using `ensure => absent` is to specify a `line => ...` and no match. When ensuring lines are absent, the default behavior is to remove all lines matching. This behavior can't be disabled.

Note that the `line => ...` parameter would be accepted *but ignored* in
the above example.

The second way of using `ensure => absent` is to specify a `line => ...`,
and no match:
For example:

```puppet
file_line { 'bashrc_proxy':
Expand All @@ -163,9 +160,6 @@ file_line { 'bashrc_proxy':
}
```

Note that when ensuring lines are absent this way, the default behavior
this time is to always remove all lines matching, and this behavior
can't be disabled.

Encoding example:

Expand Down Expand Up @@ -236,7 +230,7 @@ Default value: `false`.

##### `multiple`

Specifies whether `match` and `after` can change multiple lines. If set to `false`, allows file\_line to replace only one line and raises an error if more than one will be replaced. If set to `true`, allows file\_line to replace one or more lines.
Specifies whether `match` and `after` can change multiple lines. If set to `false`, allows file_line to replace only one line and raises an error if more than one will be replaced. If set to `true`, allows file_line to replace one or more lines.

Values: `true`, `false`.

Expand Down Expand Up @@ -271,7 +265,7 @@ Default value: `true`.

##### `replace_all_matches_not_matching_line`

Replace all lines matched by `match` parameter, even if `line` already exists in the file.
Replaces all lines matched by `match` parameter, even if `line` already exists in the file.

Default value: `false`.

Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-stdlib",
"version": "4.20.0",
"version": "4.21.0",
"author": "puppetlabs",
"summary": "Standard library of resources for Puppet modules.",
"license": "Apache-2.0",
Expand Down
58 changes: 43 additions & 15 deletions readmes/README_ja_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,49 @@ file_line { 'bashrc_proxy':

マッチ例:

file_line { 'bashrc_proxy':
ensure => present,
path => '/etc/bashrc',
line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
match => '^export\ HTTP_PROXY\=',
append_on_no_match => false,
}
```puppet
file_line { 'bashrc_proxy':
ensure => present,
path => '/etc/bashrc',
line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
match => '^export\ HTTP_PROXY\=',
append_on_no_match => false,
}
```

このコードの例では、`match`によってexportで始まり'HTTP_PROXY'が続く行が検索され、その行が行内の値に置き換えられます。マッチするものが見つからない場合、ファイルは変更されません。

`ensure => absent`の例:

このコードの例では、`match`によってexportで始まりHTTP_PROXYが続く行が検索され、その行が行内の値に置き換えられます。マッチするものが見つからない場合、ファイルは変更されません
`ensure => absent`を設定する場合に、このタイプの動作には2通りがあります

`ensure => absent`を用いたマッチ例:
1つは`match => ...`と`match_for_absence => true`の設定です。`match`により、'export'で始まり'HTTP_PROXY'と続く行が探され、その行が削除されます。複数の行がマッチし、`multiple => true`パラメータが設定されていない場合は、エラーが生じます。

この例で`line => ...`パラメータは承認されますが無視されます。

例:

```puppet
file_line { 'bashrc_proxy':
ensure => absent,
path => '/etc/bashrc',
line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
match => '^export\ HTTP_PROXY\=',
match_for_absence => true,
}
```

上の例では、`match`により、'export'で始まり'HTTP_PROXY'と続く行が探され、その行が削除されます。複数の行がマッチし、`multiple => true`パラメータが設定されていない場合は、エラーが生じます。
`ensure => absent`を設定する場合のもう1つの動作は、`line => ...`の指定と一致なしです。行が存在しないことを確認した場合のデフォルトの動作では、マッチするすべての行を削除します。この動作を無効にすることはできません。

例:

```puppet
file_line { 'bashrc_proxy':
ensure => absent,
path => '/etc/bashrc',
line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
}
```


エンコード例:

Expand Down Expand Up @@ -193,7 +213,7 @@ file_line { "XScreenSaver":

##### `match`

ファイル内の既存の行と比較する正規表現を指定します。マッチが見つかった場合、新規の行を追加するかわりに、置き換えられます。正規表現の比較は行の値に照らして行われ、マッチしない場合は、例外が発生します
ファイル内の既存の行と比較する正規表現を指定します。マッチが見つかった場合、新規の行を追加する代わりに、置き換えられます。

値: 正規表現を含む文字列

Expand All @@ -210,7 +230,7 @@ file_line { "XScreenSaver":

##### `multiple`

`match`および`after`により複数の行を変更できるかどうかを指定します。`false`に設定すると、複数の行がマッチする場合に例外が発生します
`match`および`after`により複数の行を変更できるかどうかを指定します。`false`に設定すると、file_lineは1つの行のみ置き換えることができますが、複数の行を置き換えようとするとエラーが発生します。`true`に設定すると、file_lineは1つまたは複数の行を置き換えることができます

値: `true`、`false`

Expand All @@ -235,12 +255,20 @@ file_line { "XScreenSaver":

##### `replace`

`match`パラメータとマッチする既存の行を上書きするかどうかを指定します。`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。
`match`パラメータとマッチする既存の行をリソースで上書きするかどうかを指定します。`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。

`false`に設定すると、`match`パラメータにマッチする行が見つかった場合、その行はファイルに配置されません。

ブーリアン

デフォルト値: `true`

##### `replace_all_matches_not_matching_line`

`line`がファイルにすでに存在する場合でも、`match`パラメータに一致するすべての行が置き換えられます。

デフォルト値: `false`

### データタイプ

#### `Stdlib::Absolutepath`
Expand Down Expand Up @@ -2214,7 +2242,7 @@ validate_ip_address('260.2.32.43')
例:

```puppet
validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."])
validate_legacy('Optional[String]', 'validate_re', 'Value to be validated', ["."])
```

この関数は、Puppet 3形式の引数確認(stdlibの`validate_*`関数を使用)からPuppet 4データタイプへのモジュールのアップデートに対応しており、Puppet 3形式の確認に頼っている場合も機能性が中断することはありません。
Expand Down