~juju/charms/precise/tarmac/gobotnext

« back to all changes in this revision

Viewing changes to tarmac.pp

  • Committer: Martin Packman
  • Date: 2014-03-06 17:55:43 UTC
  • Revision ID: martin.packman@canonical.com-20140306175543-vqxq88j3tos5hq0n
Use bzr-2.6.0 from tarball and allow arbitrary scripting via config

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
class tarmac {
2
2
  $home = "/home/tarmac"
 
3
  $bzrcmd = "$home/.local/bin/bzr"
 
4
  $pathwithlocal = "$home/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
3
5
 
4
6
  package {
5
 
    "bzr": ensure => present;
6
 
 
7
 
    # You can add extra packages to install here, for instance things
8
 
    #  needed to run test tests.
 
7
    "python-dev": ensure => present;
9
8
  }
10
9
 
11
10
  user { "tarmac":
19
18
    owner   => "tarmac",
20
19
  }
21
20
 
 
21
  exec { "latest-bazaar-tgz":
 
22
    command => "/usr/bin/wget https://launchpad.net/bzr/2.6/2.6.0/+download/bzr-2.6.0.tar.gz",
 
23
    user    => "tarmac",
 
24
    cwd     => $home,
 
25
    require => [File[$home]],
 
26
    creates => "$home/bzr-2.6.0.tar.gz",
 
27
  }
 
28
 
 
29
  exec { "latest-bazaar-tree":
 
30
    command => "/bin/tar -xzf $home/bzr-2.6.0.tar.gz",
 
31
    user    => "tarmac",
 
32
    cwd     => $home,
 
33
    require => [Exec["latest-bazaar-tgz"]],
 
34
    creates => "$home/bzr-2.6.0",
 
35
  }
 
36
 
 
37
  exec { "latest-bazaar-built":
 
38
    command     => "/usr/bin/python setup.py install --user",
 
39
    user        => "tarmac",
 
40
    cwd         => "$home/bzr-2.6.0",
 
41
    logoutput   => "on_failure",
 
42
    environment => ["HOME=$home"],
 
43
    require     => [Package["python-dev"], Exec["latest-bazaar-tree"]],
 
44
    creates     => "$bzrcmd",
 
45
  }
 
46
 
22
47
  exec { "tarmac-source":
23
 
    command => "/usr/bin/bzr checkout --lightweight lp:tarmac",
24
 
    user    => "tarmac",
25
 
    cwd     => $home,
26
 
    require => [File[$home], Package["bzr"]],
27
 
    creates => "$home/tarmac",
 
48
    command     => "$bzrcmd checkout --lightweight $tarmac_branch tarmac",
 
49
    user        => "tarmac",
 
50
    cwd         => $home,
 
51
    logoutput   => "on_failure",
 
52
    environment => ["HOME=$home"],
 
53
    require     => [Exec["latest-bazaar-built"]],
 
54
    creates     => "$home/tarmac",
28
55
  }
29
56
 
30
57
  file { "$home/tarmac/tarmac/plugins/commit.py":
50
77
      owner   => "tarmac",
51
78
      require => File["$home/.config/tarmac"],
52
79
      content => $launchpad_credentials;
 
80
    "$home/.profile":
 
81
      owner   => "tarmac",
 
82
      require => File["$home"],
 
83
      content => "export PATH=$pathwithlocal";
53
84
    "$home/.ssh":
54
85
      owner   => "tarmac",
55
86
      require => File["$home"],
77
108
 
78
109
  if $launchpad_username {
79
110
    exec { "launchpad-login":
80
 
      command     => "/usr/bin/bzr launchpad-login $launchpad_username 2>&1",
 
111
      command     => "$bzrcmd launchpad-login $launchpad_username 2>&1",
81
112
      user        => "tarmac",
82
113
      creates     => "$home/.bazaar/authentication.conf",
83
 
      require     => [Package["bzr"], File["$home/.ssh/id_rsa"]],
 
114
      require     => [Exec["latest-bazaar-built"], File["$home/.ssh/id_rsa"]],
 
115
      logoutput   => "on_failure",
 
116
      environment => ["HOME=$home"],
 
117
    }
 
118
 
 
119
    exec { "whoami":
 
120
      command     => "$bzrcmd whoami Tarmac",
 
121
      user        => "tarmac",
 
122
      require     => [Exec["latest-bazaar-built"], File["$home/.ssh/id_rsa"]],
84
123
      logoutput   => "on_failure",
85
124
      environment => ["HOME=$home"],
86
125
    }
89
128
      command     => "/usr/bin/flock -n $home/tarmac.lock /usr/bin/python $home/tarmac/bin/tarmac merge",
90
129
      user        => "tarmac",
91
130
      minute      => "*",
92
 
      environment => ["PYTHONPATH=$home/tarmac"],
93
 
      require     => [User["tarmac"], File["$home/tarmac.lock"]]
 
131
      environment => "PYTHONPATH=$home/tarmac\nPATH=$pathwithlocal",
 
132
      require     => [User["tarmac"], File["$home/tarmac.lock"]],
94
133
    }
95
134
  }
96
135
}