orchestration is failing: Error while evaluating a Resource Statement... expects a parameter

asked 2016-12-01 14:18:39 -0500

ryanrowe gravatar image

Hi, I thought I had a simple example of PE's orchestration feature, but it seems I have not :-)

It's not working. I can't see why. I have a mysql type that accepts some parameters, then it exports those parameters in an sql object, and a webapp define consumes them. Except the webapp define never seems to get them.

The error:

Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Lamp::Webapp[app2]: expects a value for parameter 'db_user' expects a value for parameter 'db_pass' expects a value for parameter 'db_host' expects a value for parameter 'db_name' at /etc/puppetlabs/code/environments/orchestration_test/modules/lamp/manifests/init.pp:16 on node n54.example.com
The code:
::::::::::::::
manifests/site.pp
::::::::::::::
node default {
  ini_setting { 'use_cached_catalog':
    ensure  => present,
    path    => $settings::config,
    section => 'agent',
    setting => 'use_cached_catalog',
    value   => 'true',
  }
}

site {

  lamp{'app2':
    db_user => '3db_user',
    db_pass => '3db_pass',
    db_name => '3db_name',
    db_host => '3db_host',
    nodes   => {
      Node['n37.example.com'] => Lamp::Mysql['app2'],
      Node['n54.example.com'] => Lamp::Webapp['app2'],
    }
  }

}

::::::::::::::
modules/lamp/lib/puppet/type/sql.rb
::::::::::::::
Puppet::Type.newtype :sql, :is_capability => true do
  newparam :name, :is_namevar => true
  newparam :user
  newparam :password
  newparam :host
  newparam :database
end

::::::::::::::
modules/lamp/manifests/init.pp
::::::::::::::
application lamp(
  $db_user,
  $db_pass,
  $db_host,
  $db_name,
) {

  lamp::mysql { $name:
    db_user => $db_user,
    db_pass => $db_pass,
    db_host => $db_host,
    db_name => $db_name,
    export  => Sql[$name],
  }

  lamp::webapp { $name:
    consume => Sql[$name],
  }
}

Lamp::Mysql produces Sql {
  user     => $db_user,
  password => $db_pass,
  host     => $db_host,
  database => $db_name,
}

Lamp::Webapp consumes Sql {
  db_user => $user,
  db_pass => $password,
  db_host => $host,
  db_name => $database,
}

define lamp::mysql (
  $db_user,
  $db_pass,
  $db_host,
  $db_name,
) {
  file { '/tmp/mysql.ini':
    content => "name ${name} db_user ${db_user} db_pass ${db_pass} db_host ${db_host} db_name ${db_name}",
  }
}

define lamp::webapp (
  $db_user,
  $db_pass,
  $db_host,
  $db_name,
) {
  file { '/tmp/webapp.ini':
    content => "name ${name} db_user ${db_user} db_pass ${db_pass} db_host ${db_host} db_name ${db_name}",
  }
}

and here is my code on github: https://github.com/roweryan/orchestra...

edit retag flag offensive close merge delete