From: Ismaƫl Bouya Date: Tue, 9 Aug 2016 19:36:00 +0000 (+0200) Subject: Add aura helper X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FPuppet.git;a=commitdiff_plain;h=919d772aaa9bb6f298b1d0a433b6b32d15c0410f Add aura helper --- diff --git a/manifests/install_ovh.pp b/manifests/install_ovh.pp index 41a9ad2..d1e109f 100644 --- a/manifests/install_ovh.pp +++ b/manifests/install_ovh.pp @@ -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 index 0000000..fff988b --- /dev/null +++ b/modules/aur/manifests/aura.pp @@ -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 index 0000000..cdf9929 --- /dev/null +++ b/modules/aur/manifests/init.pp @@ -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 index 0000000..074088e --- /dev/null +++ b/modules/aur/manifests/install.pp @@ -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'") + } + + } +}