From ca503c37e64c1a8f826a6a6aa0dbcd767fb2e2da Mon Sep 17 00:00:00 2001 From: Cocker Koch Date: Thu, 24 Jun 2021 14:55:20 +0200 Subject: [PATCH] Use EPP instead of ERB - As a Preparation for making this Module "Sensitive"-aware, we prefer to use EPP instead of ERB in such Situations, where "Sensitive" could come into Play, as EPP is able to handle Data of Type Sensitive natively. --- manifests/cli.pp | 19 +++++++++++++++++-- templates/hammer_etc.yml.epp | 30 ++++++++++++++++++++++++++++++ templates/hammer_etc.yml.erb | 23 ----------------------- templates/hammer_root.yml.epp | 8 ++++++++ templates/hammer_root.yml.erb | 4 ---- 5 files changed, 55 insertions(+), 29 deletions(-) create mode 100644 templates/hammer_etc.yml.epp delete mode 100644 templates/hammer_etc.yml.erb create mode 100644 templates/hammer_root.yml.epp delete mode 100644 templates/hammer_root.yml.erb diff --git a/manifests/cli.pp b/manifests/cli.pp index 78914e849..c6ff9d8e2 100644 --- a/manifests/cli.pp +++ b/manifests/cli.pp @@ -60,7 +60,16 @@ owner => 'root', group => 'root', mode => '0644', - content => template('foreman/hammer_etc.yml.erb'), + content => epp( + 'foreman/hammer_etc.yml.epp', + { + host => $foreman_url_real, + use_sessions => $use_sessions, + refresh_cache => $refresh_cache, + request_timeout => $request_timeout, + ssl_ca_file => $ssl_ca_file_real, + } + ), } # Separate configuration for admin username/password @@ -83,7 +92,13 @@ group => 'root', mode => '0600', replace => false, - content => template('foreman/hammer_root.yml.erb'), + content => epp( + 'foreman/hammer_root.yml.epp', + { + username => $username_real, + password => $password_real, + } + ), } } diff --git a/templates/hammer_etc.yml.epp b/templates/hammer_etc.yml.epp new file mode 100644 index 000000000..7f01561de --- /dev/null +++ b/templates/hammer_etc.yml.epp @@ -0,0 +1,30 @@ +<%- | + Optional[Stdlib::HTTPUrl] $host, + Boolean $use_sessions, + Boolean $refresh_cache, + Integer[-1] $request_timeout, + Optional[Stdlib::Absolutepath] $ssl_ca_file, +| -%> +:foreman: + # Enable/disable foreman commands + :enable_module: true + + # Your foreman server address + :host: '<%= $host %>' + + # Enable using sessions + # When sessions are enabled, hammer ignores credentials stored in the config file + # and asks for them interactively at the begining of each session. + :use_sessions: <%= $use_sessions %> + + # Check API documentation cache status on each request + :refresh_cache: <%= $refresh_cache %> + + # API request timeout in seconds, set -1 for infinity + :request_timeout: <%= $request_timeout %> + +<% if $ssl_ca_file { -%> + +:ssl: + :ssl_ca_file: '<%= $ssl_ca_file %>' +<% } -%> diff --git a/templates/hammer_etc.yml.erb b/templates/hammer_etc.yml.erb deleted file mode 100644 index a2542e1cf..000000000 --- a/templates/hammer_etc.yml.erb +++ /dev/null @@ -1,23 +0,0 @@ -:foreman: - # Enable/disable foreman commands - :enable_module: true - - # Your foreman server address - :host: '<%= @foreman_url_real %>' - - # Enable using sessions - # When sessions are enabled, hammer ignores credentials stored in the config file - # and asks for them interactively at the begining of each session. - :use_sessions: <%= @use_sessions %> - - # Check API documentation cache status on each request - :refresh_cache: <%= @refresh_cache %> - - # API request timeout in seconds, set -1 for infinity - :request_timeout: <%= @request_timeout %> - -<% if @ssl_ca_file_real -%> - -:ssl: - :ssl_ca_file: '<%= @ssl_ca_file_real %>' -<% end -%> diff --git a/templates/hammer_root.yml.epp b/templates/hammer_root.yml.epp new file mode 100644 index 000000000..2962a3a4d --- /dev/null +++ b/templates/hammer_root.yml.epp @@ -0,0 +1,8 @@ +<%- | + Optional[String] $username, + Optional[String] $password, +| -%> +:foreman: + # Credentials. You'll be asked for the interactively if you leave them blank here + :username: '<%= $username %>' + :password: '<%= $password %>' diff --git a/templates/hammer_root.yml.erb b/templates/hammer_root.yml.erb deleted file mode 100644 index c669b5560..000000000 --- a/templates/hammer_root.yml.erb +++ /dev/null @@ -1,4 +0,0 @@ -:foreman: - # Credentials. You'll be asked for the interactively if you leave them blank here - :username: '<%= @username_real %>' - :password: '<%= @password_real %>'