Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-11315

Plans apply function collides with resource types that have apply attribute



    • Monolithic
    • CentOS 7
    • PE 2019.8.5
    • Skeletor
    • Needs Assessment
    • 43878
    • 1
    • Bug Fix
    • The names "apply" and "plan" can now be used as resource parameter names in all cases. Previously, using them within an apply() block in a plan would fail.
    • Needs Assessment


      When using apply function in a Bolt as well as Puppet plan, it conflicts with a resource type that is having apply as an attribute. 

      Ways to reproduce:

      Finding a module augeasproviders_sysctl who has a resource type sysctl that has apply as an attribute.

      Plans with the following content will fail:

      plan plans::test (
        TargetSpec $targets = "localhost"
      ) {
      #  out::message("Hello from plans::test")
      #  $command_result = run_command('whoami', $targets)$targets.apply_prep$apply_results = apply($targets)
      $shmmax_size = 184467440
      sysctl{ 'kernel.shmmax':
              apply => false,
              ensure => present,
              value => $shmmax_size,

      With errors:

      Syntax error at 'apply' (file: /root/boltProjects/43878/plans/plans/test.pp, line: 21, column: 8)

      If we comment out the `apply` line within the resource type, it is working without an error.

      However, directly running bolt apply doesn't trigger the issue.

      root@puppetmom manifests]# cat server.pp
      $shmmax_size = 184467440
      sysctl{ 'kernel.shmmax':
      ensure => present,
      apply => false,
      value => $shmmax_size,
      [root@puppetmom manifests]# bolt apply server.pp --targets localhost
      Starting: install puppet and gather facts on localhost
      Finished: install puppet and gather facts with 0 failures in 12.94 sec
      Starting: apply catalog on localhost
      Started on localhost...
      Finished on localhost:
        Notice: /Stage[main]/Main/Sysctl[kernel.shmmax]/value: changed configuration value from '' to '184467440'
        changed: 1, failed: 0, unchanged: 0 skipped: 0, noop: 0
      Finished: apply catalog with 0 failures in 15.31 sec
      Successful on 1 node: localhost
      Ran on 1 node in 28.41 sec
      [root@puppetmom manifests]# cat /etc/sysctl.conf
      # sysctl settings are defined through files in
      # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
      # Vendors settings live in /usr/lib/sysctl.d/.
      # To override a whole file, create a new file with the same in
      # /etc/sysctl.d/ and put new settings there. To override
      # only specific settings, add a file with a lexically later
      # name in /etc/sysctl.d/ and put new settings there.
      # For more information, see sysctl.conf(5) and sysctl.d(5).
      kernel.shmmax = 184467440 

      It looks like the inline function apply within a plan is conflicting with the keyword apply in a manifest.




            Unassigned Unassigned
            henry.wang Henry Wang
            0 Vote for this issue
            2 Start watching this issue



              Zendesk Support