Puppet: System Administration Automated

Support

Ticket #1157 (closed defect: wontfix)

Opened 8 months ago

Last modified 8 months ago

0.24.4rc3: resources inside of @@defines are not being created nor exported

Reported by: Fujin Assigned to: Luke
Priority: high Milestone: 0.24.4
Component: library Version: 0.24.3
Severity: normal Keywords: resources virtual defines export
Cc: Triage Stage: Needs design decision
Attached Patches: None Complexity: Trivial

Description

# ntp module
class blah {
@@concatenatedfilepart {
            # export this server for our own clients
            "server_${fqdn}":
               dir => "/var/lib/puppet/modules/ntp/ntp.client.d",
               content => "server ${fqdn} iburst\n",
               tag => 'ntp';
            # export this server for our other servers
            "peer_${fqdn}":
               dir => "/var/lib/puppet/modules/ntp/ntp.server.d",
               content => "peer ${fqdn} iburst\nrestrict ${fqdn} nomodify notrap\n",
               tag => 'ntp';
         }
}
define concatenatedfilepart (
   $dir, $content = '', $ensure = present,
   $mode = 0644, $owner = root, $group = root
   )
   {
      file { "${dir}/${name}":
         ensure => $ensure, content => $content,
         mode => $mode, owner => $owner, group => $group,
         alias => "cf_part_${name}",
         notify => Exec["concat_${dir}"],
         require => File["${dir}"];
      }
   }
}

MySQL DB looks like this. Note that the define is actually being exported, not the file resources as expected:

mysql> select * from resources where title not like '%munin%' and exported is not null\G
*************************** 1. row ***************************
            id: 14773
         title: peer_smtp02.maxnet.net.nz
       restype: Ntp::Concatenatedfilepart
       host_id: 29
source_file_id: 10
      exported: 1
          line: 85
    updated_at: 2008-03-26 01:06:36
*************************** 2. row ***************************
            id: 14800
         title: server_smtp02.maxnet.net.nz
       restype: Ntp::Concatenatedfilepart
       host_id: 29
source_file_id: 10
      exported: 1
          line: 85
    updated_at: 2008-03-26 01:06:46
*************************** 3. row ***************************
            id: 14813
         title: server_smtp01.maxnet.net.nz
       restype: Ntp::Concatenatedfilepart
       host_id: 28
source_file_id: 10
      exported: 1
          line: 85
    updated_at: 2008-03-26 01:06:50
*************************** 4. row ***************************
            id: 14895
         title: peer_smtp01.maxnet.net.nz
       restype: Ntp::Concatenatedfilepart
       host_id: 28
source_file_id: 10
      exported: 1
          line: 85
    updated_at: 2008-03-26 01:07:04
4 rows in set (0.00 sec)

Change History

03/25/08 02:07:04 changed by Fujin

Ok so that wasn't the exact manifest - going to try and do a very very simply manifest and test it out.

03/25/08 02:52:22 changed by Fujin

Right, let's try that again. A simplified manifest, which, by my reckonings, should export some files for collection to the database, and also suck them into /tmp/{testa,testb}:

class testing {
   File <<| tag == 'testing' |>>

   define testvirtual($dir, $content = '', $ensure = present) {
      file { "${dir}/${name}":
         ensure => $ensure, content => $content, alias => "cf_part_${name}";
      }
   }

   @@testvirtual {
      "testa":
         dir => "/tmp", content => "testa\n", tag => "testing";
      "testb":
         dir => "/tmp", content => "testb\n", tag => "testing";
   }
}

Puppetmaster:

info: Caching node puppettest.maxnet.net.nz
info: Stored catalog for puppettest.maxnet.net.nz in 0.29 seconds
notice: Compiled configuration for puppettest.maxnet.net.nz in 0.33 seconds

Node:

root@puppettest:/tmp# runpuppet
running puppet on puppettest, standby.
info: Loading fact configured_ntp_servers
info: Loading fact netmask
info: Loading fact interfaces
info: Loading fact acpi_available
info: Retrieving plugins
notice: Ignoring cache
info: Caching catalog at /var/lib/puppet/state/localconfig.yaml
notice: Starting catalog run
notice: Finished catalog run in 0.82 seconds

Storeconfigs MySQL output (the interesting bit!)

mysql> select * from resources where exported is not null\G
*************************** 1. row ***************************
            id: 17
         title: testb
       restype: Testing::Testvirtual
       host_id: 1
source_file_id: 3
      exported: 1
          line: 15
    updated_at: 2008-03-26 02:56:34
*************************** 2. row ***************************
            id: 18
         title: testa
       restype: Testing::Testvirtual
       host_id: 1
source_file_id: 3
      exported: 1
          line: 15
    updated_at: 2008-03-26 02:56:34
2 rows in set (0.00 sec)

03/25/08 02:55:55 changed by Fujin

  • owner changed from community to Luke.
  • priority changed from normal to high.
  • stage changed from Unreviewed to Needs design decision.
  • milestone set to 0.24.4.

Obviously this is requring a design decision:

a) should define{} blocks that are virtualised (@@define) imply that all resources inside the define are virtualiased OR b) maintain the current (broken for some manifests) behaviour

An obvious workaround is to modify the define so that the file{} inside the define is in fact virtual (@@file).

Regardless I feel this may have been worth mentioning in the changes, unless it was broken inadvertently.

03/25/08 03:12:31 changed by Fujin

  • summary changed from 0.24.4rc1: resources inside of @@defines are not being created nor exported to 0.24.4rc3: resources inside of @@defines are not being created nor exported.

03/25/08 03:38:18 changed by luke

Note that this change in behaviour as introduced by the fix to #997.

It's basically a design decision at this point, I think: Should defined but virtual (or exported) resources get evaluated and thus expanded into their component resources, or should they only get expanded if they get collected/realized?

03/25/08 21:07:36 changed by Fujin

  • status changed from new to closed.
  • complexity changed from Unknown to Trivial.
  • resolution set to wontfix.

The obvious fix here is to redocument what we currently have to explain this scenario correctly, which I'll get right onto after my caffiene levels have stabilised.