Puppet is not executing scripts in order.

51 views
Skip to first unread message

Ayyanar

unread,
Jun 24, 2015, 9:56:55 AM6/24/15
to puppet...@googlegroups.com

== My site.pp contains shell script executing. I need to run this file according to this order.

class hadinstall {

    file { "/home/haas/a1.sh":
        mode => "0755",
        owner => 'haas',
        group => 'haas',
        source => 'puppet:///modules/scripts/01-hadoop-install.sh',
    }

    exec { "/home/haas/a1.sh":
    }

}

class haddir {
    file { "/home/haas/b1.sh":
        mode => "0755",
        owner => 'haas',
        group => 'haas',
        source => 'puppet:///modules/scripts/02-hadoop-directories.sh',
    }

    exec { "/home/haas/b1.sh":
    }

}

class hadconf {
    file { "/home/haas/hadoop-config.jar":
        mode => "0755",
        owner => 'haas',
        group => 'haas',
        source => 'puppet:///modules/scripts/hadoop-config.jar',
    }

    file { "/home/haas/c1-.sh":
        mode => "0755",
        owner => 'haas',
        group => 'haas',
        source => 'puppet:///modules/scripts/03-hadoop-config-jar-extract.sh',
    }

    exec { "/home/haas/c1.sh":
    }
}


class hadconfextract {
    file { "/home/haas/d1.sh":
        mode => "0755",
        owner => 'haas',
        group => 'haas',
        source => 'puppet:///modules/scripts/04-hadoop-config.sh',

    exec { "/home/haas/d1.sh":
    }

}



But in agent executes file in different order. How to solve this.


[root@h1 manifests]# puppet apply site.pp
Notice: Compiled catalog for h1.lab.orzota.com in environment production in 0.13 seconds
Notice: /Stage[main]/D/Exec[/root/d1.sh]/returns: executed successfully
Notice: /Stage[main]/C/Exec[/root/a1.sh]/returns: executed successfully
Notice: /Stage[main]/A/Exec[/root/b1.sh]/returns: executed successfully
Notice: /Stage[main]/B/Exec[/root/c1.sh]/returns: executed successfully
Notice: Finished catalog run in 0.40 seconds
[root@h1 manifests]#

Vlado Peshov

unread,
Jun 24, 2015, 10:07:00 AM6/24/15
to puppet...@googlegroups.com
Regards,
--
Vlado Peshov

John Zimmerman

unread,
Jun 24, 2015, 3:19:54 PM6/24/15
to puppet...@googlegroups.com
In general puppet is a poor script executor as it wasn't designed to do that.

You'll can use explicit ordering and chaining as described in the link given or you can look at what you are doing in your shell scripts and refactor into puppet code.  In the long run you will be a lot better off refactoring your shell scripts as you'll be able to take advantage of things Puppet was designed to do.

Exec should be used as a last resort to accomplish something Puppet does not support.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/5e4e08db-6306-4f44-903d-10f18d19b471%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ayy...@orzota.com

unread,
Jun 25, 2015, 8:47:17 AM6/25/15
to puppet...@googlegroups.com
Thanks,
i wll look to it.
Reply all
Reply to author
Forward
0 new messages