Ask Your Question
0

Ordering maifest behaviour to ensure keys are copied then vcsrepos then vhosts

asked 2013-12-29 13:58:41 -0500

dwdwdwdwdw gravatar image

I am trying to build a vagrant lamp development box and have run into an issue with the order my manifest steps are running. I have a central default.pp manifest which copies my deployment key and imports deploy.pp and vhosts.pp.

default.pp copies key and imports files

file { "/home/vagrant/.ssh/deploykey":
     owner => vagrant,
     group => root,
     mode => 0600,
     purge => true,
     ensure  => present,
     content => template("/vagrant/files/.ssh/deploykey"),
}

import 'deploy.pp'
import 'vhosts.pp'

deploy.pp contains lots of vcsrepos

#### Site1 ####
vcsrepo { "/var/www/site1.dev":
    ensure   => latest,
    owner    => vagrant,
    provider => git,
    source   => "ssh://git@bitbucket.org ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-12-30 03:09:55 -0500

updated 2013-12-30 03:14:30 -0500

One elegant way to do this is using Tags, collectors and ordering :

file { "/home/vagrant/.ssh/deploykey":
 owner => vagrant,
 group => root,
 mode => 0600,
 purge => true,
 tag    => 'myappDeploymentKey',
 ensure  => present,
 content => template("/vagrant/files/.ssh/deploykey"),}

VCS repo :

vcsrepo { "/var/www/site1.dev":
ensure   => latest,
owner    => vagrant,
provider => git,
tag    => 'myappSiteBitbucket',
source   => "ssh://git@bitbucket.org/account/site1.git",
revision => 'master',
identity => '/home/vagrant/.ssh/deploykey',}

Apache vhost :

apache::vhost { 'site1.dev':
docroot       => '/var/www/site1.dev/public/',
tag             => 'myappVhost',
port            => '80',}

Then use ordering

File<| tag == 'myappDeploymentKey' |> -> Vcsrepo<| tag == 'myappSiteBitbucket' |> -> Apache::Vhost<| tag == 'myappVhost' |>

cf : http://docs.puppetlabs.com/puppet/3/reference/lang_collectors.html

edit flag offensive delete link more

Comments

2

And you should avoid using import as explained here : http://docs.puppetlabs.com/puppet/3/reference/lang_import.html Except if vagrant requires a single manifest ?

ThinkBriK gravatar imageThinkBriK ( 2013-12-30 03:13:19 -0500 )edit

Thanks for your help. I actually managed to do this using require => and requiring that the other classes/functions had been run, more than one way to skin a cat ...(more)

dwdwdwdwdw gravatar imagedwdwdwdwdw ( 2013-12-30 06:33:45 -0500 )edit

@ThnikBriK Using the tags method would I be able to ensure multiple items with the same tag had run? So for example could I give all vhosts a tag of ...(more)

dwdwdwdwdw gravatar imagedwdwdwdwdw ( 2013-12-30 06:38:09 -0500 )edit

It's the point of resource collectors and you can use it with the require/before pattern too (but I find it less manageable) : If you use Vcsrepo<||> -> Apache::Vhost ...(more)

ThinkBriK gravatar imageThinkBriK ( 2013-12-31 03:11:06 -0500 )edit

In this case, Tags are used to limit the resources affected.

ThinkBriK gravatar imageThinkBriK ( 2013-12-31 03:12:02 -0500 )edit

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: 2013-12-29 13:58:41 -0500

Seen: 702 times

Last updated: Dec 30 '13