Ask Your Question
0

is there any better way to write etc_services manifests to avoid time consume

asked 2016-07-13 03:51:32 -0600

Chutki gravatar image

Hi,

Here you can find manifests for etc_services,

class module_name {

  $val = 600

  $val.each |Integer $index, $srvs| {
    etc_services { "my_srv$index/tcp" :
      port    => "25$srvs",
    }
  }

The manifests is working but the entry to the /etc/services takes more time, It tool 5 mins 45 secs to append 600 entry in /etc/sevices.

So , do we have any other iteration in a better way to consume less time.

edit retag flag offensive close merge delete

Comments

What is 'etc_services'. Something from the Forge or something you wrote internally?

Alex Harvey gravatar imageAlex Harvey ( 2016-07-13 04:11:33 -0600 )edit
Chutki gravatar imageChutki ( 2016-07-13 04:15:35 -0600 )edit

Is that really your code or have you pasted it in here incorrectly? That code doesn't make sense.

Alex Harvey gravatar imageAlex Harvey ( 2016-07-13 05:33:26 -0600 )edit

It worked without any error. When I run the manifests it will append the data in /etc/services

Chutki gravatar imageChutki ( 2016-07-13 06:18:38 -0600 )edit

Anybody got clue?

Chutki gravatar imageChutki ( 2016-07-14 01:02:33 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-07-14 23:22:16 -0600

Chutki gravatar image

updated 2016-07-15 05:21:51 -0600

I have changed resource file_line rather than etc_services and it worked. It took just 3 secs to append all the 600 entries.

edit flag offensive delete link more
0

answered 2016-07-15 05:21:58 -0600

updated 2016-07-18 09:14:06 -0600

Ok, this code is not doing what you think it's doing although I must admit I'm surprised that it compiles.

I changed it to this:

  $val = 600
  $val.each |Integer $index, $srvs| {
    notify { "index is $index" : message => "srvs is $srvs", }
  }

And I inspect the catalog:

{
  "type": "Notify",
  "title": "index is 1",
  "tags": ["notify","class","test"],
  "file": "/Users/alexharvey/git/foo/spec/fixtures/modules/test/manifests/init.pp",
  "line": 5,
  "exported": false,
  "parameters": {
    "message": "srvs is 1"
  }
},
{
  "type": "Notify",
  "title": "index is 2",
  "tags": ["notify","class","test"],
  "file": "/Users/alexharvey/git/foo/spec/fixtures/modules/test/manifests/init.pp",
  "line": 5,
  "exported": false,
  "parameters": {
    "message": "srvs is 2"
  }
},

The code is equivalent to this:

  $val = 600
  $val.each |Integer $index| {
    etc_services { "my_srv$index/tcp" :
      port    => "25$index",
    }
  }

Meanwhile, it only takes 4.9 seconds to run this code on my laptop:

$ bundle exec rake spec_standalone
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -I/Users/alexharvey/git/foo/.gems/ruby/2.0.0/gems/rspec-core-3.5.1/lib:/Users/alexharvey/git/foo/.gems/ruby/2.0.0/gems/rspec-support-3.5.0/lib /Users/alexharvey/git/foo/.gems/ruby/2.0.0/gems/rspec-core-3.5.1/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration,types\}/\*\*/\*_spec.rb --color
..

Finished in 4.9 seconds (files took 0.91279 seconds to load)
2 examples, 0 failures
edit flag offensive delete link more

Comments

what is the path that you referred for catalog value.

Chutki gravatar imageChutki ( 2016-07-18 01:36:12 -0600 )edit

That's the catalog created by Puppet. I showed you on a previous occasion how to generate that.

Alex Harvey gravatar imageAlex Harvey ( 2016-07-18 04:12:06 -0600 )edit

Yes, I do remember. Thanks :)

Chutki gravatar imageChutki ( 2016-07-18 04:26:35 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-07-13 03:51:32 -0600

Seen: 85 times

Last updated: Jul 18 '16