Skip to content
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

Allow usage of array in actions configs #182

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zerrac
Copy link

@zerrac zerrac commented Aug 12, 2021

Pull Request (PR) description

According to the doc (https://www.rsyslog.com/doc/v8-stable/configuration/modules/omrelp.html) omrelp tls permitted peers can be given as an array.
example:

tls.permittedPeer=["SHA1:...1", "SHA1:....2"] 

This PR reuse the same logic present in inputs.epp for to deal with arrays.

This Pull Request (PR) fixes the following issues

Following puppet declaration :

class { 'rsyslog::config':
    modules       => {
      'omrelp' => {},

    },
    actions       => {      
      relp     => {
        type   => 'omrelp',
        config => {
          target              => 'logs.example.tld',
          port                => '2514',
          tls                 => 'on',
          'tls.mycert'        => '/etc/ssl/certs/ssl-cert-snakeoil.pem',
          'tls.myprivkey'     =>'/etc/ssl/private/ssl-cert-snakeoil.key',
          'tls.authmode'      => 'fingerprint',
          'tls.permittedpeer' =>['rsyslog_permittedpeers'],
        }
      },
}

produce the following rsyslog config :

module(load="omrelp")
# relp
action(type="omrelp"
    name="relp"
    target="logs.example.tld"
    port="2514"
    tls="on"
    tls.mycert="/etc/ssl/certs/ssl-cert-snakeoil.pem"
    tls.myprivkey="/etc/ssl/private/ssl-cert-snakeoil.key"
    tls.authmode="fingerprint"
    tls.permittedpeer="[ 'rsyslog_permittedpeers' ]"
  )

with the fix i have

...
    tls.permittedpeer=[ "rsyslog_permittedpeers" ]
...

@bastelfreak
Copy link
Member

hi @zerrac, thanks for the PR. Can you add some unit tests for it?

@zerrac
Copy link
Author

zerrac commented Aug 12, 2021

hi @zerrac, thanks for the PR. Can you add some unit tests for it?

I have no idea how to do that but i will try tomorow

@zerrac
Copy link
Author

zerrac commented Aug 13, 2021

@bastelfreak i tried something with the unit tests...

I am not familiar with ruby, rspec or unit testing in general so please check carefully what i did ;)

@bastelfreak
Copy link
Member

@zerrac can you please rebase against our latest master branch?

@bastelfreak
Copy link
Member

can you please do an actual rebase instead of a merge commit?

@zerrac
Copy link
Author

zerrac commented Aug 13, 2021

done!

@bastelfreak
Copy link
Member

thanks for rebasing. Can you take a look at the failing unit tests?

@@ -25,9 +25,13 @@ action(type="<%= $type %>"
name="<%= $action_name %>"
<%}-%>
<% if $config { -%>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you like you can also remove this if check. It doesn't make any sense anymore. We can always iterate on $config. If it's empty it won't print anything.

@zerrac
Copy link
Author

zerrac commented Aug 13, 2021

I added the if to avoid this :

 1) Rsyslog::Config cyclic dependency check is expected to compile into a catalogue without dependency cycles
     Failure/Error: it { is_expected.to compile.with_all_deps }
     
       error during compilation: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Method call, The function 'each' was called with arguments it does not accept. It expects one of:
         (Hash hash, Callable[2, 2] block)
           rejected: parameter 'hash' expects a Hash value, got Undef
         (Hash hash, Callable[1, 1] block)
           rejected: parameter 'hash' expects a Hash value, got Undef
         (Iterable enumerable, Callable[2, 2] block)
           rejected: parameter 'enumerable' expects an Iterable value, got Undef
         (Iterable enumerable, Callable[1, 1] block)
           rejected: parameter 'enumerable' expects an Iterable value, got Undef 

maybe its better to change the test in some way but its too complicated for me

@zerrac zerrac requested a review from bastelfreak September 15, 2021 15:10
@zerrac
Copy link
Author

zerrac commented Sep 15, 2021

i cant remember where the test were failling, can you relaunch them mannualy ?

@vox-pupuli-tasks
Copy link

Dear @zerrac, thanks for the PR!

This is Vox Pupuli Tasks, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants