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

Cron resource generates duplicate entry when specifying only target attribute

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Duplicate
    • Affects Version/s: PUP 3.3.2, PUP 3.4.3
    • Fix Version/s: None
    • Component/s: Types and Providers
    • Labels:
      None
    • Environment:

      oraclelinux-release-6Server-3.0.2.x86_64

    • Template:

      Description

      Using this sample manifest to create cron job for another user

      cron { logrotate:
        ensure => present,
        command => "ls",
        target    => 'cloud',
        hour    => 2,
        minute  => 0
      }
      

      Result in both Puppet 3.4.3 and 3.3.2 is

      rubyTestBox:/tmp # puppet apply testDup.pp
      Notice: Compiled catalog for rubytestbox.amers1b.ciscloud in environment production in 0.14 seconds
      Notice: /Stage[main]/Main/Cron[logrotate]/ensure: created
      Notice: Finished catalog run in 0.06 seconds
      rubyTestBox:/tmp #
      rubyTestBox:/tmp # puppet apply testDup.pp
      Notice: Compiled catalog for rubytestbox.amers1b.ciscloud in environment production in 0.07 seconds
      Notice: /Stage[main]/Main/Cron[logrotate]/ensure: created
      Notice: Finished catalog run in 0.06 seconds
      rubyTestBox:/tmp #
      rubyTestBox:/tmp # crontab -l -u cloud
      # HEADER: This file was autogenerated at Thu Mar 13 04:20:12 +0000 2014 by puppet.
      # HEADER: While it can still be managed manually, it is definitely not recommended.
      # HEADER: Note particularly that the comments starting with 'Puppet Name' should
      # HEADER: not be deleted, as doing so could cause duplicate cron jobs.
      # Puppet Name: logrotate
      0 2 * * * ls
      # Puppet Name: logrotate
      0 2 * * * ls
      rubyTestBox:/tmp #
      

      It breaks differently in 3.1.0 by flipping between create and remove after each apply

      PVC3-CPMDVWN01:/tmp # puppet --version
      3.1.0
      PVC3-CPMDVWN01:/tmp # puppet apply sampleDuplicate2.pp
      Notice: /Stage[main]//Cron[logrotate]/ensure: created
      Notice: Finished catalog run in 0.10 seconds
      PVC3-CPMDVWN01:/tmp # crontab -l -u cloud
      # HEADER: This file was autogenerated at Thu Mar 13 04:31:25 +0000 2014 by puppet.
      # HEADER: While it can still be managed manually, it is definitely not recommended.
      # HEADER: Note particularly that the comments starting with 'Puppet Name' should
      # HEADER: not be deleted, as doing so could cause duplicate cron jobs.
      # Puppet Name: logrotate
      0 2 * * * ls
      PVC3-CPMDVWN01:/tmp # puppet apply sampleDuplicate2.pp
      Notice: /Stage[main]//Cron[logrotate]/user: user changed 'cloud' to 'root'
      Notice: Finished catalog run in 0.11 seconds
      PVC3-CPMDVWN01:/tmp # crontab -l -u cloud
      # HEADER: This file was autogenerated at Thu Mar 13 04:31:41 +0000 2014 by puppet.
      # HEADER: While it can still be managed manually, it is definitely not recommended.
      # HEADER: Note particularly that the comments starting with 'Puppet Name' should
      # HEADER: not be deleted, as doing so could cause duplicate cron jobs.
       
      PVC3-CPMDVWN01:/tmp # crontab -l
      PVC3-CPMDVWN01:/tmp # puppet apply sampleDuplicate2.pp
      Notice: /Stage[main]//Cron[logrotate]/ensure: created
      Notice: Finished catalog run in 0.17 seconds
      PVC3-CPMDVWN01:/tmp #
      

      I've managed to workaround this in 3.3.2 by specifying user attribute along with target.
      It is only reproducible when creating cron job for another user.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                chuck Charlie Sharpsteen
                Reporter:
                poomz Poomrat Boonyawong
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support