Skip to content

Commit

Permalink
Merge pull request #747 from Icinga/enhancement/replace-newline-function
Browse files Browse the repository at this point in the history
Replace icinga2::newline function with icinga::newline
  • Loading branch information
lbetz authored Dec 22, 2023
2 parents 2127176 + 2683e2f commit de7bd64
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 65 deletions.
19 changes: 0 additions & 19 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ with or without TLS information.
* [`icinga2::icinga2_attributes`](#icinga2--icinga2_attributes): Calls the simple parser to decide what to quote.
For more information, see lib/puppet_x/icinga2/utils.rb.
* [`icinga2::icinga2_ticket_id`](#icinga2--icinga2_ticket_id): Summarise what the function does here
* [`icinga2::newline`](#icinga2--newline): Replace newlines for Windows systems.
* [`icinga2::parse`](#icinga2--parse)
* [`icinga2::unwrap`](#icinga2--unwrap): This function returns an unwrap string if necessary.

Expand Down Expand Up @@ -5699,24 +5698,6 @@ Data type: `Variant[String, Sensitive[String]]`

The ticket salt of the Icinga CA.

### <a name="icinga2--newline"></a>`icinga2::newline`

Type: Puppet Language

Replace newlines for Windows systems.

#### `icinga2::newline(Optional[String] $text)`

The icinga2::newline function.

Returns: `String` Text with correct newlines.

##### `text`

Data type: `Optional[String]`



### <a name="icinga2--parse"></a>`icinga2::parse`

Type: Puppet Language
Expand Down
25 changes: 0 additions & 25 deletions functions/newline.pp

This file was deleted.

8 changes: 2 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
)

if $facts['kernel'] != 'windows' {
$template_constants = icinga2::parse($constants)
$template_mainconfig = $_mainconfig
$file_permissions = '0640'
} else {
$template_constants = regsubst(icinga2::parse($constants), '\n', "\r\n", 'EMG')
$template_mainconfig = regsubst($_mainconfig, '\n', "\r\n", 'EMG')
$file_permissions = undef
}

Expand All @@ -35,12 +31,12 @@

file { "${conf_dir}/constants.conf":
ensure => file,
content => $template_constants,
content => icinga::newline(icinga2::parse($constants)),
}

file { "${conf_dir}/icinga2.conf":
ensure => file,
content => $template_mainconfig,
content => icinga::newline($_mainconfig),
}

file { "${conf_dir}/features-enabled":
Expand Down
2 changes: 1 addition & 1 deletion manifests/config/fragment.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
) {
case $facts['os']['family'] {
'windows': {
$_content = regsubst($content, '\n', "\r\n", 'EMG')
$_content = icinga::newline($content)
} # windows
default: {
Concat {
Expand Down
6 changes: 3 additions & 3 deletions manifests/feature/api.pp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
file { $_ssl_key_path:
ensure => file,
mode => $_ssl_key_mode,
content => icinga2::newline($ssl_key),
content => icinga::newline($ssl_key),
tag => 'icinga2::config::file',
show_diff => false,
backup => false,
Expand All @@ -262,15 +262,15 @@
if $ssl_cert {
file { $_ssl_cert_path:
ensure => file,
content => icinga2::newline($ssl_cert),
content => icinga::newline($ssl_cert),
tag => 'icinga2::config::file',
}
}

if $ssl_cacert {
file { $_ssl_cacert_path:
ensure => file,
content => icinga2::newline($ssl_cacert),
content => icinga::newline($ssl_cacert),
tag => 'icinga2::config::file',
}
}
Expand Down
7 changes: 1 addition & 6 deletions manifests/object.pp
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@
}
)

$_content = $facts['os']['family'] ? {
'windows' => regsubst($_object, '\n', "\r\n", 'EMG'),
default => $_object,
}

if !defined(Concat[$target]) {
concat { $target:
ensure => present,
Expand All @@ -114,7 +109,7 @@
if $ensure != 'absent' {
concat::fragment { $title:
target => $target,
content => $_content,
content => icinga::newline($_object),
order => $order,
}
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/pki/ca.pp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@

file { "${ca_dir}/ca.crt":
ensure => file,
content => icinga2::newline($ca_cert),
content => icinga::newline($ca_cert),
tag => 'icinga2::config::file',
before => File[$_ssl_cacert_path],
}

file { "${ca_dir}/ca.key":
ensure => file,
mode => $_ca_key_mode,
content => icinga2::newline($ca_key),
content => icinga::newline($ca_key),
tag => 'icinga2::config::file',
show_diff => false,
backup => false,
Expand Down
6 changes: 3 additions & 3 deletions manifests/tls/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if icinga2::unwrap($args[key]) {
file { $args['key_file']:
ensure => file,
content => icinga2::newline(icinga2::unwrap($args['key'])),
content => icinga::newline(icinga2::unwrap($args['key'])),
mode => $key_mode,
show_diff => false,
}
Expand All @@ -38,14 +38,14 @@
if $args['cert'] {
file { $args['cert_file']:
ensure => file,
content => icinga2::newline($args['cert']),
content => icinga::newline($args['cert']),
}
}

if $args['cacert'] {
file { $args['cacert_file']:
ensure => file,
content => icinga2::newline($args['cacert']),
content => icinga::newline($args['cacert']),
}
}
}

0 comments on commit de7bd64

Please sign in to comment.