Issue #6017 has been updated by Clay Caviness.

I haven't tested, just glanced at the code, but I wonder if doing a `dscl 
'localhost', '-mcxdelete', ds_path` just before [line 118 in 
mcxcontent.rb](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/mcx/mcxcontent.rb#L118)
 would solve this.
----------------------------------------
Bug #6017: MCX provider doesn't overwrite existing MCX data
https://projects.puppetlabs.com/issues/6017#change-60098

Author: Clay Caviness
Status: Accepted
Priority: Normal
Assignee: 
Category: OSX
Target version: Telly
Affected Puppet version: 
Keywords: 
Branch: 


If a directory service resource has pre-existing MCX data, the mcx provider 
will not remove it - it will only append.

This means that all subsequent puppet runs will see the existing MCX data and 
re-apply the mcx resource ... which of course won't overwrite the existing MCX 
data, etc.

In this case, I think an "mcxdelete"  on the existing directory service 
resource will remove *all* mcx, at which point the "mcximport" will work and 
the resource will have only the correct MCX.

Example:
Assume an existing group, testgroup. Add some MCX data to it:

<pre># dscl . -mcxset /Groups/testgroup existing_domain existing_key always 1
Password: 
$ dscl . -mcxread /Groups/testgroup
App domain: existing_domain
Key: existing_key
State: always
Value: 1
</pre>

Apply puppet manifest with different MCX data:

<pre>mcx_group.pp:
mcx { &quot;/Groups/testgroup&quot;:
  ensure =&gt; present,
  content =&gt; &#x27;&lt;?xml version=&quot;1.0&quot; 
encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; 
&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
        &lt;key&gt;some.domain&lt;/key&gt;
        &lt;dict&gt;
                &lt;key&gt;some.key&lt;/key&gt;
                &lt;dict&gt;
                        &lt;key&gt;state&lt;/key&gt;
                        &lt;string&gt;always&lt;/string&gt;
                        &lt;key&gt;value&lt;/key&gt;
                        &lt;string&gt;1&lt;/string&gt;
                &lt;/dict&gt;
        &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;
&#x27;,
}</pre>

<pre>[...]
notice: /Stage[main]//Mcx[/Groups/testgroup]/content: content changed 
&#x27;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; 
&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
        &lt;key&gt;existing_domain&lt;/key&gt;
        &lt;dict&gt;
                &lt;key&gt;existing_key&lt;/key&gt;
                &lt;dict&gt;
                        &lt;key&gt;state&lt;/key&gt;
                        &lt;string&gt;always&lt;/string&gt;
                        &lt;key&gt;value&lt;/key&gt;
                        &lt;string&gt;1&lt;/string&gt;
                &lt;/dict&gt;
        &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;
&#x27; to &#x27;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; 
&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
        &lt;key&gt;some.domain&lt;/key&gt;
        &lt;dict&gt;
                &lt;key&gt;some.key&lt;/key&gt;
                &lt;dict&gt;
                        &lt;key&gt;state&lt;/key&gt;
                        &lt;string&gt;always&lt;/string&gt;
                        &lt;key&gt;value&lt;/key&gt;
                        &lt;string&gt;1&lt;/string&gt;
                &lt;/dict&gt;
        &lt;/dict&gt;
&lt;/dict&gt;
&lt;/plist&gt;
&#x27;
[...]</pre>

Note that the pre-existing MCX data is still in the record:

<pre>$ dscl . -mcxread /Groups/testgroup
App domain: existing_domain
Key: existing_key
State: always
Value: 1

App domain: some.domain
Key: some.key
State: always
Value: 1
</pre>


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to