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

@property_hash not updated in OSX user directoryservice provider


    • Type: Bug
    • Status: Accepted
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: PUP 4.6.1
    • Fix Version/s: None
    • Component/s: None
    • Template:
    • Team:
      Platform OS


      It would be desirable to refacter the logic in the OSX user directoryservice provider to check the @property_hash value for the existence of the desired user as shown in this PR. However, after a call to the `create` method, @property_hash is empty. Thus if this refactoring was implemented, a call to puppet to ensue a new user would return an indicator of ensure => absent even though the user was successfully created.

      Steps to create on OSX

      Install Puppet Agent

      curl -O http://downloads.puppetlabs.com/mac/10.11/PC1/x86_64/puppet-agent-1.6.1-1.osx10.11.dmg
      sudo hdiutil mount puppet-agent-1.6.1-1.osx10.11.dmg
      sudo installer -pkg  /Volumes/puppet-agent-1.6.1-1.osx10.11/puppet-agent-1.6.1-1-installer.pkg -target /
      sudo umount /Volumes/puppet-agent-1.6.1-1.osx10.11

      Patch user/directoryservice provider

      Change to provider/user directory

      cd /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/user/

      Create patch file

      cat <<\EOF > patch
      --- directoryservice.rb
      +++ directoryservice.rb
      @@ -237,13 +237,7 @@
       ##                   ##
         def exists?
      -    begin
      -      dscl '.', 'read', "/Users/#{@resource.name}"
      -    rescue Puppet::ExecutionFailure => e
      -      Puppet.debug("User was not found, dscl returned: #{e.inspect}")
      -      return false
      -    end
      -    true
      +    return @property_hash.any?
         # This method is called if ensure => present is passed and the exists?

      Apply the patch

      patch directoryservice.rb patch

      Create new user with provider and notice failure

      Notice in the user creation output below that puppet returns an erroneous absent result. When we query puppet a second time, we can see that the user was successfully created.

      e:user root# /opt/puppetlabs/bin/puppet resource user bar ensure=present
      Notice: /User[bar]/ensure: created
      user { 'bar':
        ensure => 'absent',
      e:user root# /opt/puppetlabs/bin/puppet resource user bar
      user { 'bar':
        ensure     => 'present',
        uid        => '29',


          Issue Links



              • Assignee:
                john.duarte John Duarte
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created:

                  Zendesk Support