]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Add aura helper
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 9 Aug 2016 19:36:00 +0000 (21:36 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 9 Aug 2016 20:47:39 +0000 (22:47 +0200)
manifests/install_ovh.pp
modules/aur/manifests/aura.pp [new file with mode: 0644]
modules/aur/manifests/init.pp [new file with mode: 0644]
modules/aur/manifests/install.pp [new file with mode: 0644]

index 41a9ad22023c9def3ab0da241fcad4d8f79f95bd..d1e109f4a17dd421b8de096406513f57d191fc33 100644 (file)
@@ -8,6 +8,7 @@ node default {
     class { 'base_configuration':
       hostname => 'new.immae.eu'
     }
+    class { 'aur': }
 
     reboot { 'after_run':
       apply => 'finished'
diff --git a/modules/aur/manifests/aura.pp b/modules/aur/manifests/aura.pp
new file mode 100644 (file)
index 0000000..fff988b
--- /dev/null
@@ -0,0 +1,38 @@
+class aur::aura(
+) {
+  user { "aur-builder":
+    name   => "aur-builder",
+    system => true,
+    ensure => "present"
+  }
+
+  exec { 'pacman-base-devel':
+    command   => '/usr/bin/pacman -S base-devel --needed --noconfirm',
+    unless    => '/usr/bin/pacman -Qo aura',
+    logoutput => 'on_failure',
+  }
+
+  ensure_packages(['gmp', 'pcre', 'abs'], { 'install_options' => '--asdeps' })
+
+  exec { 'aur::aura':
+    cwd       => "/tmp",
+    path      => "/usr/bin",
+    command   => 'curl -o /tmp/aur.sh aur.sh && chmod +x /tmp/aur.sh && /tmp/aur.sh aura-bin && mv /tmp/aura-bin/aura-bin-*-x86_64.pkg.tar.xz /tmp/aura-bin-x86_64.pkg.tar.xz && rm /tmp/aur.sh && rm -rf /tmp/aura-bin',
+    user      => "aur-builder",
+    unless    => '/usr/bin/pacman -Qo aura',
+    require   => Exec['pacman-base-devel'],
+    logoutput => 'on_failure',
+  }
+
+  package { 'aura-bin':
+    ensure => "present",
+    source => "/tmp/aura-bin-x86_64.pkg.tar.xz",
+    notify => Exec['aur::aura::cleanup']
+  }
+
+  exec { 'aur::aura::cleanup':
+    path        => "/usr/bin/",
+    command     => "rm -f /tmp/aura-bin-x86_64.pkg.tar.xz",
+    refreshonly => true
+  }
+}
diff --git a/modules/aur/manifests/init.pp b/modules/aur/manifests/init.pp
new file mode 100644 (file)
index 0000000..cdf9929
--- /dev/null
@@ -0,0 +1,4 @@
+class aur {
+  class { 'aur::aura': }
+}
+
diff --git a/modules/aur/manifests/install.pp b/modules/aur/manifests/install.pp
new file mode 100644 (file)
index 0000000..074088e
--- /dev/null
@@ -0,0 +1,28 @@
+define aur::install (
+  $ensure = 'present',
+) {
+
+  case $ensure {
+    'present': {
+      exec { "pacman::aur::install::${name}":
+        require   => Class[aur::aura],
+        command   => "/usr/bin/aura -A ${name}",
+        unless    => "/usr/bin/aura -Qk ${name}",
+        logoutput => 'on_failure',
+        timeout   => 1800,
+      }
+    }
+    'absent': {
+      exec { "pacman::aur::remove::${name}":
+        require   => Class[aur::aura],
+        command   => "/usr/bin/aura -Rs ${name}",
+        onlyif    => "/usr/bin/aura -Qi ${name}",
+        logoutput => 'on_failure',
+      }
+    }
+    default: {
+      fail("Pacman::Aur[${name}] ensure parameter must be either 'present' or 'absent'")
+    }
+
+  }
+}