Ask Your Question
0

how to create dependencies for Exec and define, and stop define from running all the time

asked 2016-10-09 15:45:39 -0500

Angry gravatar image

updated 2016-10-10 00:00:27 -0500

All I wanted to do is, creating the below flow and its dependencies

  • 1) Detect a change in file ( deploy.cfg )
  • 2) If there is a change, run Nexus::Artifact[ "nexus-artifact" ]
  • 3) After Nexus::Artifact[ "nexus-artifact" ] finishes, run Exec['unzip'].

thats it!

The problem I am facing now is, Nexus::Artifact is a definition and it runs every time, but I just don't want this behaviour. It should run only if there is a change in deploy.cfg file. How to achieve this flow ???????

class deloy(....) {

file { '/home/downloads/deploy': ensure => directory }

file { 'deploy.cfg':
    ensure  => file,
    path    => '/home/downloads/deploy/deploy.cfg',
    mode    => '0644',
    owner   => 'root',
    group   => 'root',
    content => "test",        
    require => File['/home/downloads/deploy'],
}


class { 'nexus':
    url      => $url,
    username => $user,
    password => $password,
}

nexus::artifact { "nexus-artifact":
    gav        => $gav,
    packaging  => $packaging,
    output     => $targetfilepath,
    repository => $repository,
    owner      => $owner,
    mode       => $mode,
}

exec {
    "unzip":
    command => "....",
    path    => ['/usr/bin/', '/usr/sbin/'],
    subscribe => Nexus::Artifact["nexus-artifact"],
    refreshonly => true,
}
}
edit retag flag offensive close merge delete

Comments

is this using a publicly available nexus module? Can you link to it on the forge?

DarylW gravatar imageDarylW ( 2016-10-10 08:10:40 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2016-10-10 07:27:20 -0500

You can't. nexus::artifact doesn't have a refreshonly attribute, does it?

If there are refreshable resources inside nexus::artifact's definition, you can send them the refresh event:

File['deploy.cfg'] ~> Nexus::Artifact['nexus-artifact'] -> Exec['unzip']
File['deploy.cfg'] ~> Exec['unzip']

The second line's there, bc I only see File['deploy.cfg'] as a notification emitting resource [hence subscribe => Nexus::Artifact['nexus-artifact'] in your exec resource doesn't have an effect (except for ordering it)],

more on relationships and ordering

edit flag offensive delete link more

Comments

If I put refreshonly attribute to Nexus::Artifact, its going to be custom variable right? How to make it behave like "refreshonly" attribute

Angry gravatar imageAngry ( 2016-10-10 23:34:41 -0500 )edit
1

AFAIK the puppet language (unfortunately) does not [yet] provide a way to mimic a refreshonly behavior. You've had to implement your resource type as a custom type written in Ruby https://docs.puppet.com/guides/custom_types.html in order to use the full feature set puppet offers.

Kai Burghardt gravatar imageKai Burghardt ( 2016-10-11 09:35:22 -0500 )edit
0

answered 2016-10-11 04:57:21 -0500

Thanks guys so much for this post.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-10-09 15:45:39 -0500

Seen: 97 times

Last updated: Oct 11 '16