Skip to content

Instantly share code, notes, and snippets.

@omarkj
Last active December 17, 2015 19:58
Show Gist options
  • Save omarkj/5663862 to your computer and use it in GitHub Desktop.
Save omarkj/5663862 to your computer and use it in GitHub Desktop.
Exported Resources

Puppet Remote Resources

First I create a define that can, say, create an nginx config file

define nginx::config ($var1, var2) {
  file {
    "/etc/nginx/conf.d/${var1}.conf":
      ensure => present,
      content => template('nginx/template.erb'),
      notify => Service['nginx'];
  }
}

Next I define node_a which will "export" one nginx::config

node 'node_a' {
  @@nginx:config {
    'config_for_something':
      tag => 'a_tag',
      var1 => 'foo',
      var2 => 'bar'
  }
}

Then I gather these defines on node_b

node 'node_b' {
  Nginx::Config <<| tag == 'a_tag' |>>
}

This will create the file on node_b but in the scope of node_b (so all other variables need to be sent from node_a)

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