Ask Your Question
1

Require multiple resources listed in array

asked 2013-08-28 11:02:16 -0500

Tomasz Olszewski gravatar image

updated 2013-08-28 13:46:00 -0500

Hi!

I wrote simple nginx module that creates virtual host definition using template, and multiple includes.

Example invocation:

nginx::vhost { "my_first_vhost":
    server_name => [ 's1', 's2' ],
    parts       => [ 'proxy_definitions', 'error_pages' ],
    root        => '/var/www', 
}

This will create 1 virtual host which include /etc/nginx/parts.d/proxy_definitions.conf and error_pages.conf. To upload those 2 files I need to create 2:

nginx::parts { .. }

Questions:

1) Is possible to require those definitions INSIDE of nginx::vhost? I would like to reload nginx AFTER Nginx::Part is executed. With one Nginx::Part - it's easy, but when its an array, I have no idea how to ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-09-10 15:31:16 -0500

Tomasz Olszewski gravatar image

updated 2013-09-11 00:28:04 -0500

Well, It looks like it is possible to specify array in require for this context

  file { $file_src:
    ensure  => file,
    mode    => '0644',
    owner   => 'root',
    group   => 'root',
    content => template('nginx/vhost.conf.erb'),
    require => Nginx::Part[$parts],   }

Where $parts is array of strings..

So simple :-) I have no idea why it didn't work before.

edit flag offensive delete link more
0

answered 2013-08-28 16:59:04 -0500

ramindk gravatar image

You might try something like this.

define nginx::vhost () {

  blah blah code {
  }

  # Either of these should work.
  Nginx::Part<||> -> Nginx::Vhost<||> ~> Service['nginx']
  # Nginx::Part<||> -> Nginx::Vhost[$name] ~> Service['nginx']
}
edit flag offensive delete link more

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: 2013-08-28 11:02:16 -0500

Seen: 416 times

Last updated: Sep 11 '13