example42 / puppi

Puppet module to manage applications deployments and servers local management
http://www.example42.com
Other
142 stars 84 forks source link

netinstall postextract_command => ./tools/setup #159

Closed eric-maletras closed 2 years ago

eric-maletras commented 2 years ago

I try decompress nagios-plugins but the postextract_command don't recognize teh command "./tools/setup puppi::netinstall {'nagios-plugin': url => 'https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz', extracted_dir => '.', destination_dir => '/tmp/nagios-plugins-release-2.3.3', postextract_command => './tools/setup', }

Error: Could not find command. If I try like: postextract_command => '/tmp/nagios-plugins-release-2.3.3/tools/setup',

It's the same

alvagante commented 2 years ago

Try with:

puppi::netinstall { 'nagios-plugin':
  url => 'https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz',
  extracted_dir => '.',
  destination_dir => '/tmp',
  postextract_command => '/tmp/nagios-plugins-release-2.3.3/tools/setup',
}

With the sample code you provided the tarball is extracted under /tmp/nagios-plugins-release-2.3.3, so the setup script is found in /tmp/nagios-plugins-release-2.3.3/nagios-plugins-release-2.3.3/tools/setup

eric-maletras commented 2 years ago

I just try it, no error display but I can't find the result to continue the process !! Notice: /Stage[main]/Main/Node[puppet01.labo.lab]/Puppi::Netinstall[nagios-plugin]/Exec[Retrieve https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz in /var/tmp - nagios-plugin]/returns: executed successfully Notice: Applied catalog in 78.56 seconds root@puppet01:~# ls /var/tmp release-2.3.3.tar.gz systemd-private-d557e06b0d48451cb8a9c9f70e3e9e51-systemd-logind.service-0TnRUf systemd-private-d557e06b0d48451cb8a9c9f70e3e9e51-systemd-timesyncd.service-iX2rcj root@puppet01:~# ls /tmp systemd-private-d557e06b0d48451cb8a9c9f70e3e9e51-systemd-logind.service-klOMag
systemd-private-d557e06b0d48451cb8a9c9f70e3e9e51-systemd-timesyncd.service-HCMbGh

alvagante commented 2 years ago

Uhm , the exatrcted_dir param should contain the name of the directory extracted from the tarball.

[root@www0 ~]# ls -l /tmp/
total 0
[root@www0 ~]# ls -l /var/tmp/
total 0
[root@www0 ~]# cat puppi.pp
puppi::netinstall {'nagios-plugin':
  url => 'https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz',
  extracted_dir => 'nagios-plugins-release-2.3.3',
  destination_dir => '/tmp',
  postextract_command => '/tmp/nagios-plugins-release-2.3.3/tools/setup',
}
[root@www0 ~]# puppet apply puppi.pp
Notice: Compiled catalog for 2416nix0.classroom.puppet.com in environment production in 0.12 seconds
Notice: /Stage[main]/Main/Puppi::Netinstall[nagios-plugin]/Exec[Retrieve https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz in /var/tmp - nagios-plugin]/returns: executed successfully
Notice: /Stage[main]/Main/Puppi::Netinstall[nagios-plugin]/Exec[Extract release-2.3.3.tar.gz from /var/tmp - nagios-plugin]/returns: executed successfully
Notice: /Stage[main]/Main/Puppi::Netinstall[nagios-plugin]/Exec[Chown release-2.3.3.tar.gz in /tmp - nagios-plugin]: Triggered 'refresh' from 1 event
Notice: /Stage[main]/Main/Puppi::Netinstall[nagios-plugin]/Exec[PostExtract release-2.3.3.tar.gz in /tmp - nagios-plugin]: Triggered 'refresh' from 1 event
Notice: Applied catalog in 0.41 seconds
[root@www0 ~]# ls -l /var/tmp/
total 2068
-rw-r--r--. 1 root root 2116341 Jan 27 17:51 release-2.3.3.tar.gz
[root@www0 ~]# ls -l /tmp/
total 4
drwxrwxr-x. 17 root root 4096 Mar 11  2020 nagios-plugins-release-2.3.3
[root@www0 ~]# puppet apply puppi.pp
Notice: Compiled catalog for 2416nix0.classroom.puppet.com in environment production in 0.13 seconds
Notice: Applied catalog in 0.03 seconds
eric-maletras commented 2 years ago

SO It's OK for ./tools/setup, I have not change the folder in postextract_command, sorry Yep, I change the parameter 'extracted_dir', I find the folder in /tmp but the command tool/setup has not run. (normaly the process is ./tools/setup and after ./configure)

alvagante commented 2 years ago

Uhm, then its better to specify all the needed commands separated by ; , in the postextract_command argument, as that' executed only after the extract command:

puppi::netinstall {'nagios-plugin':
  url => 'https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz',
  extracted_dir => 'nagios-plugins-release-2.3.3',
  destination_dir => '/tmp',
  postextract_command => '/tmp/nagios-plugins-release-2.3.3/tools/setup ; /tmp/nagios-plugins-release-2.3.3/configure',
}

In the above puppet apply the post extract command is actually executed:

Notice: /Stage[main]/Main/Puppi::Netinstall[nagios-plugin]/Exec[PostExtract release-2.3.3.tar.gz in /tmp - nagios-plugin]: Triggered 'refresh' from 1 event

alvagante commented 2 years ago

you will need first to remove the extracted dir under /tmp otherwise the command is not refreshed / executed

alvagante commented 2 years ago

worst case, manage the execution of the extra commands in the class where you use puppi::netinstall

eric-maletras commented 2 years ago

sure !! I just try with all post command and it's OK, thanks a lot: $stdPackages = ['autoconf', 'gcc', 'libc6', 'libmcrypt-dev', 'make', 'libssl-dev', 'wget', 'bc', 'gawk', 'dc', 'build-essential', 'snmp', 'libnet-snmp-perl', 'gettext'] Package { $stdPackages: ensure => "installed", }

puppi::netinstall {'nagios-plugin': url => 'https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz', extracted_dir => 'nagios-plugins-release-2.3.3', destination_dir => '/tmp', postextract_command => '/tmp/nagios-plugins-release-2.3.3/tools/setup ; /tmp/nagios-plugins-release-2.3.3/configure ; make ; make install', }

(sorry to don't use code tag but i don't find how to make line break in bloc code)