Arpit
Arpit

Reputation: 6260

Puppet running exec before other commands

I am creating a group named jboss in puppet and then using exec to run a sed command to make some changes in /etc/group file afterwards.
The problem is that the exec command is running before the group command.

My Yaml file

    group { 'jboss':
        ensure => 'present',
        gid    => "501",
    }
    exec { "modify etc_group":
        command => "/bin/sed -i -e '<regex>' /etc/group",
        path    => "/bin:/usr/bin",
        unless  => "<condition>",
    }

Puppet run output

notice: /Stage[main]/App::Misc/Exec[modify etc_group]/returns: current_value notrun, should be 0 (noop)
notice: /Stage[main]/App::Misc/Group[jboss]/ensure: current_value absent, should be present (noop)

How to make sure that the exec runs after the group command?

Upvotes: 2

Views: 1900

Answers (1)

kkamil
kkamil

Reputation: 2595

Simply just define relationship between group and exec.

E.g:

exec { "modify etc_group":
    command => "/bin/sed -i -e '<regex>' /etc/group",
    path    => "/bin:/usr/bin",
    unless  => "<condition>",
    require => Group['jboss'],
}

More about relationships in puppet here.

Upvotes: 4

Related Questions