<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 09/16/2015 02:58 PM, Cody Herriges
      wrote:<br>
    </div>
    <blockquote cite="mid:55F9D7F6.2000604@puppetlabs.com" type="cite">
      <pre wrap="">I wrote my first composite namevar type a few years and ago and all the
magic is basically a single block of code inside the type...

<a class="moz-txt-link-freetext" href="https://github.com/puppetlabs/puppetlabs-java_ks/blob/master/lib/puppet/type/java_ks.rb#L145-L169">https://github.com/puppetlabs/puppetlabs-java_ks/blob/master/lib/puppet/type/java_ks.rb#L145-L169</a>

It basically boils down to these three things:

* Pick your namevars
(<a class="moz-txt-link-freetext" href="https://github.com/puppetlabs/puppetlabs-java_ks/blob/master/lib/puppet/type/java_ks.rb#L49-L64">https://github.com/puppetlabs/puppetlabs-java_ks/blob/master/lib/puppet/type/java_ks.rb#L49-L64</a>)
* Pick a delimiter
  - Personally I'd use @ here since we are talking about domains</pre>
    </blockquote>
    <br>
    Unfortunately, not only is "domains" an overloaded term, but "@" is
    already in use as a delimiter for keystone_user_role, and "@" is a
    legal character in usernames.<br>
    <br>
    <blockquote cite="mid:55F9D7F6.2000604@puppetlabs.com" type="cite">
      <pre wrap="">
* Build your self.title_patterns method, accounting for delimited names
and arbitrary names.

While it looks like the README never got updated, the java_ks example
supports both meaningful titles and arbitrary ones.

java_ks { 'activemq_puppetca_keystore':
  ensure       => latest,
  name         => 'puppetca',
  certificate  => '/etc/puppet/ssl/certs/ca.pem',
  target       => '/etc/activemq/broker.ks',
  password     => 'puppet',
  trustcacerts => true,
}

java_ks { 'broker.example.com:/etc/activemq/broker.ks':
  ensure      => latest,
  certificate =>
'/etc/puppet/ssl/certs/broker.example.com.pe-internal-broker.pem',
  private_key =>
'/etc/puppet/ssl/private_keys/broker.example.com.pe-internal-broker.pem',
  password    => 'puppet',
}

You'll notice the first being an arbitrary title and the second
utilizing a ":" as a delimiter and omitting the name and target parameters.

Another code example can be found in the package type.

<a class="moz-txt-link-freetext" href="https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type/package.rb#L268-L291">https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type/package.rb#L268-L291</a>.</pre>
    </blockquote>
    <br>
    Ok.  I've hacked a lib/puppet/type/keystone_tenant.rb to use name
    and domain with "isnamevar" and added a title_patterns like this:<br>
    <br>
      def self.title_patterns<br>
        identity = lambda {|x| x}<br>
        [<br>
          [<br>
            /^(.+)::(.+)$/,<br>
            [<br>
              [ :name, identity ],<br>
              [ :domain, identity ]<br>
            ]<br>
          ],<br>
          [<br>
            /^(.+)$/,<br>
            [<br>
              [ :name, identity ]<br>
            ]<br>
          ]<br>
        ]<br>
      end<br>
    <br>
    Then I hacked one of the simple rspec-puppet files to do this:<br>
    <br>
      let :pre_condition do<br>
        [<br>
         'keystone_tenant { "tenant1": name => "tenant", domain =>
    "domain1" }',<br>
         'keystone_tenant { "tenant2": name => "tenant", domain =>
    "domain2" }'<br>
        ]<br>
      end<br>
    <br>
    because what I'm trying to do is not rely on the title of the
    resource, but to make the combination of 'name' + 'domain' the
    actual "name" of the resource.  This doesn't work.  This is the
    error I get running spec:<br>
    <br>
         Failure/Error: it { is_expected.to
    contain_package('python-keystone').with_ensure("present") }<br>
         Puppet::Error:<br>
           Puppet::Parser::AST::Resource failed with error
    ArgumentError: Cannot alias Keystone_tenant[tenant2] to ["tenant"];
    resource ["Keystone_tenant", "tenant"] already declared at line 3 on
    node unused.redhat.com<br>
         #
    ./vendor/gems/puppet-3.8.2/lib/puppet/resource/catalog.rb:137:in
    `alias'<br>
         #
    ./vendor/gems/puppet-3.8.2/lib/puppet/resource/catalog.rb:111:in
    `create_resource_aliases'<br>
         #
    ./vendor/gems/puppet-3.8.2/lib/puppet/resource/catalog.rb:90:in
    `add_one_resource'<br>
    <br>
    Is there any way to accomplish the above?  If not, please tell me
    now and put me out of my misery, and we can go back to the original
    plan of forcing everyone to use "::" in the resource titles and
    names.<br>
    <br>
    <blockquote cite="mid:55F9D7F6.2000604@puppetlabs.com" type="cite">
      <pre wrap="">

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: <a class="moz-txt-link-abbreviated" href="mailto:OpenStack-dev-request@lists.openstack.org?subject:unsubscribe">OpenStack-dev-request@lists.openstack.org?subject:unsubscribe</a>
<a class="moz-txt-link-freetext" href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>