Search code examples
puppetmcollective

mcollective agent parameter definition


The following ddl

action 'ant', :description => "Runs ant in the application directory" do
  input :application,
      :prompt      => "Application(s)",
      :description => "Application's instance name(s)",
      :type        => :string,
      :validation  => '^[a-z0-9_,\-]+$',
      :maxlength   => 500,
      :optional    => false

can be used inside an agent to get the command line parameter application

  # entry point for the ant target
  action 'ant' do
    # find eligible applications
    applications = request[:application].split(',').select{|a| valid_application?(a) }

The command command can be started with mco <agentname> -a applicationname1,applicationname2and so on. Issuing mco <agentname> --help gives me :

$ mco ehyp --help
Manage an <internal> application
Application Options
    -a, --application APPLICATION    Application to manage

I do not find the "link" between -a or --application and request[:application]. Where is it defined how to inteprete these command line switches ?


Solution

  • It is defined in MCollective::Application there you define :

    option :application,
         :description => 'Application to manage',
         :arguments   => ['-a', '--application APPLICATION'],
         :required    => true
    
    option :destination,
         :description => 'Ant target ("destination") to call',
         :arguments   => ['-d', '--destination TARGET'],
         :required    => true