Problem with deploying Hiera hashes in order

35 views
Skip to first unread message

Marcin

unread,
May 6, 2014, 12:04:21 PM5/6/14
to puppet...@googlegroups.com

I got the following lines in Hiera:

 

  # My hash array

  somehash::somevalues:

  # NODE1 - ukdc1-c1-pscn01 -- 172.19.128.2 - below

    FIRSTARTEFACT1:

      artefact: FIRSTARTEFACT

      order: ??????

    SECONDARTEFACT:

      artefact: SECONDARTEFACT

      order: FIRSTARTEFACT1

    THIRDARTEFACT:

      artefact: THIRDARTEFACT

      order: SECONDARTEFACT

 

and from those I have created  resources:

create_resources(something, $ransomething)

 

When I try to deploy this in order (from top to bottom – although this may not be clear from the listing here), I use something like:

 

I use exec of course – sample of this is below:

    exec { " something _${name}":

      command => $some_command_here,

      require => something [$order],

      creates => some entry here

    }

 

but what do I need to put in Hiera file, on the FIRST hash – where the question marks are in my example?


If I put the name of the first component - in this case: FIRSTARTEFACT1 - I got an error message like this:

Error: Could not apply complete catalog: Found 1 dependency cycle:


If I leave this field empty, it also causes an error....

 

Hope I have presented the problem clearly….


Can you help me out with this issue?


Felix Frank

unread,
May 14, 2014, 5:20:08 AM5/14/14
to puppet...@googlegroups.com
On 05/06/2014 06:04 PM, Marcin wrote:
> I use exec of course – sample of this is below:
>
> exec { " something _${name}":
>
> command => $some_command_here,
>
> require => something [$order],
>
> creates => some entry here
>
> }
>
>
>
> but what do I need to put in Hiera file, on the FIRST hash – where the
> question marks are in my example?
>

Hi,

use an empty string and build this slightly differently:

exec { " something _${name}":
command => $some_command_here,
creates => some entry here
}
if something[$order] {
Exec["something_${name}"] { require => something [$order] }
}

But I've got to add - this design feels very hacky. Are you sure you
want to do things this way? It will be horrible to maintain.

If you can explain the whole problem you are solving, someone may have a
suggestion on how to design the solution in a more straight-forward fashion.

Regards,
Felix

jcbollinger

unread,
May 14, 2014, 9:15:08 AM5/14/14
to puppet...@googlegroups.com


On Wednesday, May 14, 2014 4:20:08 AM UTC-5, Felix.Frank wrote:
On 05/06/2014 06:04 PM, Marcin wrote:
> I use exec of course – sample of this is below:
>
>     exec { " something _${name}":
>
>       command => $some_command_here,
>
>       require => something [$order],
>
>       creates => some entry here
>
>     }
>
>  
>
> but what do I need to put in Hiera file, on the FIRST hash – where the
> question marks are in my example?
>

Hi,

use an empty string and build this slightly differently:

exec { " something _${name}":
      command => $some_command_here,
      creates => some entry here
}
if something[$order] {
  Exec["something_${name}"] { require => something [$order] }
}



Or if you want to put it all in one resource block,


exec { " something _${name}":
      command => $some_command_here,
      creates => some entry here,
      require => $something[$order] ? {
          '' => undef,
          default => Exec["something_${something[$order]}"]
      }
}

That better satisfies my distaste for overrides.  In fact, if I didn't want to use a selector as above then I would use a chain expression instead of a resource override:

(alternative:)
if something[$order] {
  Exec["something_${something[$order]}"] -> Exec["something_${name}"]
}

 
But I've got to add - this design feels very hacky. Are you sure you
want to do things this way? It will be horrible to maintain.



+1
 

If you can explain the whole problem you are solving, someone may have a
suggestion on how to design the solution in a more straight-forward fashion.



We're all ears.


John
 
Reply all
Reply to author
Forward
0 new messages