Execute a class if a file is not present.

43 views
Skip to first unread message

Seby

unread,
Jun 27, 2014, 12:13:31 AM6/27/14
to puppet...@googlegroups.com
Hi Puppet experts,

I'm trying to install tomcat7*tar.gz on few puppet-agent machines. I've defined a class that will create a user/group and copy the source file from puppet-master then extracts the tomcat*.tar.gz file to its home directory and deletes the source file. This seems to be working. But each time when the agent runs(on all agents), it will copy the source file from the master and then deletes it wasting the bandwidth. 

Is there a way to call the tomcat7 class only if the tomcat directory is not present?

Regards,
SFK.

Rich Burroughs

unread,
Jun 27, 2014, 1:38:25 AM6/27/14
to puppet...@googlegroups.com
How are you doing the installation? With an exec? If so there are some notes about making those idempotent on the type reference page:


Have a look at the creates attribute.

If it's not an exec, maybe provide some code so people have an idea what you're doing.


Rich
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/fc0ef54b-5cdf-4e29-aa3c-8532948fcb49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

José Luis Ledesma

unread,
Jun 27, 2014, 2:34:56 AM6/27/14
to puppet...@googlegroups.com

You can create a custom fact that reports if the tomcat is installed or not, and do the installation process in this case.

Moreover you could add the tomcat version to this custom fact too. This way you will have an inventory, can decide when apply a patch and when not ...

Regards,

--

Juan Sierra Pons

unread,
Jun 27, 2014, 2:40:46 AM6/27/14
to puppet...@googlegroups.com
Hi

Another options is to modify another module that acomplishes your
final goal. For example this one:
https://github.com/7terminals/puppet-java

This one copy the java source code to the agent, then extract it. It
is already idempotent so new puppet run will not do anything.

With a few modifications it should fit your expectations

Best regards

--------------------------------------------------------------------------------------
Juan Sierra Pons ju...@elsotanillo.net
Linux User Registered: #257202
Web: http://www.elsotanillo.net Git: http://www.github.com/juasiepo
GPG key = 0xA110F4FE
Key Fingerprint = DF53 7415 0936 244E 9B00 6E66 E934 3406 A110 F4FE
--------------------------------------------------------------------------------------

Seby

unread,
Jun 27, 2014, 2:48:29 AM6/27/14
to puppet...@googlegroups.com
Yea, I'm using the exec to do all custom things. I see the create attribute and will try it out and let you know.


On Friday, June 27, 2014 11:08:25 AM UTC+5:30, Rich Burroughs wrote:
How are you doing the installation? With an exec? If so there are some notes about making those idempotent on the type reference page:


Have a look at the creates attribute.

If it's not an exec, maybe provide some code so people have an idea what you're doing.


Rich


On Thursday, June 26, 2014, Seby <seby.f...@gmail.com> wrote:
Hi Puppet experts,

I'm trying to install tomcat7*tar.gz on few puppet-agent machines. I've defined a class that will create a user/group and copy the source file from puppet-master then extracts the tomcat*.tar.gz file to its home directory and deletes the source file. This seems to be working. But each time when the agent runs(on all agents), it will copy the source file from the master and then deletes it wasting the bandwidth. 

Is there a way to call the tomcat7 class only if the tomcat directory is not present?

Regards,
SFK.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.

Seby

unread,
Jun 27, 2014, 2:50:00 AM6/27/14
to puppet...@googlegroups.com
Hi Jose,

I tried to add a custom fact on master to check a file which is not working when I run from agent. 

Regards,
Seby.

Seby

unread,
Jun 27, 2014, 2:50:52 AM6/27/14
to puppet...@googlegroups.com
Juan,

Let me see if I can adapt it to my need. I'll let you know the result.

Thanks,
SFK.

Seby

unread,
Jun 27, 2014, 8:35:57 AM6/27/14
to puppet...@googlegroups.com
Juan,

I don't see the puppet-java removing the installation file after the deployment. 

Regards,
Seby.

Juan Sierra Pons

unread,
Jun 27, 2014, 8:47:42 AM6/27/14
to puppet...@googlegroups.com
Hi,

It keeps the installation source just in case, so if you delete the
installation directory next time puppet agent runs it is not necessary
to download it again as the already download source is used.

I think is a clever idea if you don't have disk space constraints.
Anyway it shouldn't be difficult to change its behavior.

Best regards

--------------------------------------------------------------------------------------
Juan Sierra Pons ju...@elsotanillo.net
Linux User Registered: #257202
Web: http://www.elsotanillo.net Git: http://www.github.com/juasiepo
GPG key = 0xA110F4FE
Key Fingerprint = DF53 7415 0936 244E 9B00 6E66 E934 3406 A110 F4FE
--------------------------------------------------------------------------------------


> https://groups.google.com/d/msgid/puppet-users/ca6022c6-ace0-4563-a0f9-1933a552b5b5%40googlegroups.com.

Rich Burroughs

unread,
Jun 27, 2014, 3:07:12 PM6/27/14
to puppet...@googlegroups.com
That should work if you have it look for the install directory. If it exists the exec won't be executed.

Rich 

On Thursday, June 26, 2014, Seby <seby.f...@gmail.com> wrote:
Yea, I'm using the exec to do all custom things. I see the create attribute and will try it out and let you know.

On Friday, June 27, 2014 11:08:25 AM UTC+5:30, Rich Burroughs wrote:
How are you doing the installation? With an exec? If so there are some notes about making those idempotent on the type reference page:


Have a look at the creates attribute.

If it's not an exec, maybe provide some code so people have an idea what you're doing.


Rich


On Thursday, June 26, 2014, Seby <seby.f...@gmail.com> wrote:
Hi Puppet experts,

I'm trying to install tomcat7*tar.gz on few puppet-agent machines. I've defined a class that will create a user/group and copy the source file from puppet-master then extracts the tomcat*.tar.gz file to its home directory and deletes the source file. This seems to be working. But each time when the agent runs(on all agents), it will copy the source file from the master and then deletes it wasting the bandwidth. 

Is there a way to call the tomcat7 class only if the tomcat directory is not present?

Regards,
SFK.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/fc0ef54b-5cdf-4e29-aa3c-8532948fcb49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/adce7fa9-841f-4b71-8023-c78f7bfe806c%40googlegroups.com.

Seby

unread,
Jul 1, 2014, 10:36:22 AM7/1/14
to puppet...@googlegroups.com
Hi All,

Using custom fact, I solved my problem.. Thank you all for the guidance provided.

:)

Best,
Seby. 
Reply all
Reply to author
Forward
0 new messages