annierana
2011-Jun-16 19:17 UTC
[Puppet Users] Puppet recipe to copy and execute a shell file
Hi all, I am new to puppet. I need a sample recipe to write/copy a shell file on puppet client. The shell file exists on puppet server. Once the file is written, I also want to execute it. I have tried using file resource with ensure command to copy at /etc but permission was denied and moreover with a different directory path (\tmp) it just created an empty file. Can anyone please help? Regards, A. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Peter Bukowinski
2011-Jun-16 19:42 UTC
Re: [Puppet Users] Puppet recipe to copy and execute a shell file
It sounds like you haven''t set up the puppet fileserver yet. Choose a directory that will hold files you want to copy to clients. I use /opt/files, so that''s what is in my example. Create fileserver.conf in the same directory as puppet.conf and add these lines: [files] path /opt/files allow *.client.domain Put your shell file in the path you specified. Now you just need to set up a file and exec resource. Note the source item in the file resource and the require item in exec. file { ''/etc/shell_file'': ensure => present, owner => ''root'', group => ''root'', mode => ''0755'', source => ''puppet://puppet/files/shell_file'', } exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } -- Peter M. Bukowinski Systems Engineer Janelia Farm Research Campus, HHMI On Thursday, June 16, 2011 at 3:17 PM, annierana wrote:> Hi all, I am new to puppet. I need a sample recipe to write/copy a > shell file on puppet client. The shell file exists on puppet server. > Once the file is written, I also want to execute it. I have tried > using file resource with ensure command to copy at /etc but permission > was denied and moreover with a different directory path (\tmp) it just > created an empty file. Can anyone please help? > > Regards, > > A. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users+unsubscribe@googlegroups.com). > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 13:09 UTC
Re: [Puppet Users] Puppet recipe to copy and execute a shell file
Hi Peter, thanks for your reply. I managed to copy the shell file puppet client using the file resource recipe you specified but exec is throwing an error, which is as follows: info: No classes to store info: Caching catalog at /var/lib/puppet/state/localconfig.yaml notice: Starting catalog run err: //File[/tmp/QoS/QoS.sh]/ensure: change from absent to file failed: Could not set file on ensure: No such file or directory - /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 notice: //Exec[/tmp/QoS/QoS.sh]: Dependency file[/tmp/QoS/QoS.sh] has 1 failures warning: //Exec[/tmp/QoS/QoS.sh]: Skipping because of failed dependencies notice: Finished catalog run in 0.38 seconds When I tried running the shell script manually using the following command ''/tmp/QoS/QoS.sh; echo $?'' , it worked fine printing 0 at the end. Any help what is wrong with exec resource recipe? Thanks in advance for your time. Regards, A. On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski <pmbuko@gmail.com> wrote:> It sounds like you haven''t set up the puppet fileserver yet. Choose a > directory that will hold files you want to copy to clients. I use > /opt/files, so that''s what is in my example. Create fileserver.conf in the > same directory as puppet.conf and add these lines: > > [files] > path /opt/files > allow *.client.domain > > Put your shell file in the path you specified. Now you just need to set up > a file and exec resource. Note the source item in the file resource and the > require item in exec. > > file { ''/etc/shell_file'': > ensure => present, > owner => ''root'', > group => ''root'', > mode => ''0755'', > source => ''puppet://puppet/files/shell_file'', > } > > exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } > > -- > Peter M. Bukowinski > Systems Engineer > Janelia Farm Research Campus, HHMI > > On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > > Hi all, I am new to puppet. I need a sample recipe to write/copy a > > shell file on puppet client. The shell file exists on puppet server. > > Once the file is written, I also want to execute it. I have tried > > using file resource with ensure command to copy at /etc but permission > > was denied and moreover with a different directory path (\tmp) it just > > created an empty file. Can anyone please help? > > > > Regards, > > > > A. > > > > -- > > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > > To post to this group, send email to puppet-users@googlegroups.com(mailto: > puppet-users@googlegroups.com). > > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com (mailto: > puppet-users+unsubscribe@googlegroups.com). > > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 13:36 UTC
Re: [Puppet Users] Puppet recipe to copy and execute a shell file
I apologize for posting wrong log messages, here is the correct log: notice: Starting catalog run notice: //File[/tmp/QoS/QoS.sh]/ensure: created err: //Exec[/tmp/QoS/QoS.sh]/returns: change from notrun to 0 failed: /tmp/QoS/QoS.sh returned 1 instead of 0 at /etc/puppet/manifests/site.pp:10 notice: Finished catalog run in 0.46 seconds Any help please? On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annierana@gmail.com> wrote:> Hi Peter, thanks for your reply. I managed to copy the shell file puppet > client using the file resource recipe you specified but exec is throwing an > error, which is as follows: > > info: No classes to store > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml > notice: Starting catalog run > err: //File[/tmp/QoS/QoS.sh]/ensure: change from absent to file failed: > Could not set file on ensure: No such file or directory - > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 > notice: //Exec[/tmp/QoS/QoS.sh]: Dependency file[/tmp/QoS/QoS.sh] has 1 > failures > warning: //Exec[/tmp/QoS/QoS.sh]: Skipping because of failed dependencies > notice: Finished catalog run in 0.38 seconds > > > When I tried running the shell script manually using the following command > > ''/tmp/QoS/QoS.sh; echo $?'' > > , it worked fine printing 0 at the end. Any help what is wrong with exec > resource recipe? > > Thanks in advance for your time. > > Regards, > > A. > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski <pmbuko@gmail.com>wrote: > >> It sounds like you haven''t set up the puppet fileserver yet. Choose a >> directory that will hold files you want to copy to clients. I use >> /opt/files, so that''s what is in my example. Create fileserver.conf in the >> same directory as puppet.conf and add these lines: >> >> [files] >> path /opt/files >> allow *.client.domain >> >> Put your shell file in the path you specified. Now you just need to set up >> a file and exec resource. Note the source item in the file resource and the >> require item in exec. >> >> file { ''/etc/shell_file'': >> ensure => present, >> owner => ''root'', >> group => ''root'', >> mode => ''0755'', >> source => ''puppet://puppet/files/shell_file'', >> } >> >> exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } >> >> -- >> Peter M. Bukowinski >> Systems Engineer >> Janelia Farm Research Campus, HHMI >> >> On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: >> >> > Hi all, I am new to puppet. I need a sample recipe to write/copy a >> > shell file on puppet client. The shell file exists on puppet server. >> > Once the file is written, I also want to execute it. I have tried >> > using file resource with ensure command to copy at /etc but permission >> > was denied and moreover with a different directory path (\tmp) it just >> > created an empty file. Can anyone please help? >> > >> > Regards, >> > >> > A. >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "Puppet Users" group. >> > To post to this group, send email to puppet-users@googlegroups.com(mailto: >> puppet-users@googlegroups.com). >> > To unsubscribe from this group, send email to >> puppet-users+unsubscribe@googlegroups.com (mailto: >> puppet-users+unsubscribe@googlegroups.com). >> > For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To post to this group, send email to puppet-users@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-users+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> >> >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Luke Bigum
2011-Jun-17 13:44 UTC
[Puppet Users] Re: Puppet recipe to copy and execute a shell file
Annie, http://docs.puppetlabs.com/references/stable/type.html#exec By default the expected return code is probably zero, your script is returning 1. Whether this is correct or not I don''t know, but you can tell puppet to expect a different return code: exec { ''/etc/shell_file'': require => File[''/etc/shell_file''], returns => 1, } On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com> wrote:> I apologize for posting wrong log messages, here is the correct log: > > notice: Starting catalog run > notice: //File[/tmp/QoS/QoS.sh]/ensure: created > err: //Exec[/tmp/QoS/QoS.sh]/returns: change from notrun to 0 failed: > /tmp/QoS/QoS.sh returned 1 instead of 0 at /etc/puppet/manifests/site.pp:10 > notice: Finished catalog run in 0.46 seconds > > Any help please? > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annier...@gmail.com> wrote: > > Hi Peter, thanks for your reply. I managed to copy the shell file puppet > > client using the file resource recipe you specified but exec is throwing an > > error, which is as follows: > > > info: No classes to store > > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml > > notice: Starting catalog run > > err: //File[/tmp/QoS/QoS.sh]/ensure: change from absent to file failed: > > Could not set file on ensure: No such file or directory - > > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 > > notice: //Exec[/tmp/QoS/QoS.sh]: Dependency file[/tmp/QoS/QoS.sh] has 1 > > failures > > warning: //Exec[/tmp/QoS/QoS.sh]: Skipping because of failed dependencies > > notice: Finished catalog run in 0.38 seconds > > > When I tried running the shell script manually using the following command > > > ''/tmp/QoS/QoS.sh; echo $?'' > > > , it worked fine printing 0 at the end. Any help what is wrong with exec > > resource recipe? > > > Thanks in advance for your time. > > > Regards, > > > A. > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski <pmb...@gmail.com>wrote: > > >> It sounds like you haven''t set up the puppet fileserver yet. Choose a > >> directory that will hold files you want to copy to clients. I use > >> /opt/files, so that''s what is in my example. Create fileserver.conf in the > >> same directory as puppet.conf and add these lines: > > >> [files] > >> path /opt/files > >> allow *.client.domain > > >> Put your shell file in the path you specified. Now you just need to set up > >> a file and exec resource. Note the source item in the file resource and the > >> require item in exec. > > >> file { ''/etc/shell_file'': > >> ensure => present, > >> owner => ''root'', > >> group => ''root'', > >> mode => ''0755'', > >> source => ''puppet://puppet/files/shell_file'', > >> } > > >> exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } > > >> -- > >> Peter M. Bukowinski > >> Systems Engineer > >> Janelia Farm Research Campus, HHMI > > >> On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > >> > Hi all, I am new to puppet. I need a sample recipe to write/copy a > >> > shell file on puppet client. The shell file exists on puppet server. > >> > Once the file is written, I also want to execute it. I have tried > >> > using file resource with ensure command to copy at /etc but permission > >> > was denied and moreover with a different directory path (\tmp) it just > >> > created an empty file. Can anyone please help? > > >> > Regards, > > >> > A. > > >> > -- > >> > You received this message because you are subscribed to the Google > >> Groups "Puppet Users" group. > >> > To post to this group, send email to puppet-users@googlegroups.com(mailto: > >> puppet-users@googlegroups.com). > >> > To unsubscribe from this group, send email to > >> puppet-users+unsubscribe@googlegroups.com (mailto: > >> puppet-users+unsubscribe@googlegroups.com). > >> > For more options, visit this group at > >>http://groups.google.com/group/puppet-users?hl=en. > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Puppet Users" group. > >> To post to this group, send email to puppet-users@googlegroups.com. > >> To unsubscribe from this group, send email to > >> puppet-users+unsubscribe@googlegroups.com. > >> For more options, visit this group at > >>http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 14:18 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
Thanks but it couldn''t work though i got the message that shell script is successfully executed. On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum <Luke.Bigum@lmax.com> wrote:> Annie, > > http://docs.puppetlabs.com/references/stable/type.html#exec > > By default the expected return code is probably zero, your script is > returning 1. Whether this is correct or not I don''t know, but you can > tell puppet to expect a different return code: > > exec { ''/etc/shell_file'': > require => File[''/etc/shell_file''], > returns => 1, > } > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com> wrote: > > I apologize for posting wrong log messages, here is the correct log: > > > > notice: Starting catalog run > > notice: //File[/tmp/QoS/QoS.sh]/ensure: created > > err: //Exec[/tmp/QoS/QoS.sh]/returns: change from notrun to 0 failed: > > /tmp/QoS/QoS.sh returned 1 instead of 0 at > /etc/puppet/manifests/site.pp:10 > > notice: Finished catalog run in 0.46 seconds > > > > Any help please? > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annier...@gmail.com> wrote: > > > Hi Peter, thanks for your reply. I managed to copy the shell file > puppet > > > client using the file resource recipe you specified but exec is > throwing an > > > error, which is as follows: > > > > > info: No classes to store > > > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml > > > notice: Starting catalog run > > > err: //File[/tmp/QoS/QoS.sh]/ensure: change from absent to file failed: > > > Could not set file on ensure: No such file or directory - > > > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 > > > notice: //Exec[/tmp/QoS/QoS.sh]: Dependency file[/tmp/QoS/QoS.sh] has 1 > > > failures > > > warning: //Exec[/tmp/QoS/QoS.sh]: Skipping because of failed > dependencies > > > notice: Finished catalog run in 0.38 seconds > > > > > When I tried running the shell script manually using the following > command > > > > > ''/tmp/QoS/QoS.sh; echo $?'' > > > > > , it worked fine printing 0 at the end. Any help what is wrong with > exec > > > resource recipe? > > > > > Thanks in advance for your time. > > > > > Regards, > > > > > A. > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski <pmb...@gmail.com > >wrote: > > > > >> It sounds like you haven''t set up the puppet fileserver yet. Choose a > > >> directory that will hold files you want to copy to clients. I use > > >> /opt/files, so that''s what is in my example. Create fileserver.conf in > the > > >> same directory as puppet.conf and add these lines: > > > > >> [files] > > >> path /opt/files > > >> allow *.client.domain > > > > >> Put your shell file in the path you specified. Now you just need to > set up > > >> a file and exec resource. Note the source item in the file resource > and the > > >> require item in exec. > > > > >> file { ''/etc/shell_file'': > > >> ensure => present, > > >> owner => ''root'', > > >> group => ''root'', > > >> mode => ''0755'', > > >> source => ''puppet://puppet/files/shell_file'', > > >> } > > > > >> exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } > > > > >> -- > > >> Peter M. Bukowinski > > >> Systems Engineer > > >> Janelia Farm Research Campus, HHMI > > > > >> On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > > > >> > Hi all, I am new to puppet. I need a sample recipe to write/copy a > > >> > shell file on puppet client. The shell file exists on puppet server. > > >> > Once the file is written, I also want to execute it. I have tried > > >> > using file resource with ensure command to copy at /etc but > permission > > >> > was denied and moreover with a different directory path (\tmp) it > just > > >> > created an empty file. Can anyone please help? > > > > >> > Regards, > > > > >> > A. > > > > >> > -- > > >> > You received this message because you are subscribed to the Google > > >> Groups "Puppet Users" group. > > >> > To post to this group, send email to puppet-users@googlegroups.com > (mailto: > > >> puppet-users@googlegroups.com). > > >> > To unsubscribe from this group, send email to > > >> puppet-users+unsubscribe@googlegroups.com (mailto: > > >> puppet-users+unsubscribe@googlegroups.com). > > >> > For more options, visit this group at > > >>http://groups.google.com/group/puppet-users?hl=en. > > > > >> -- > > >> You received this message because you are subscribed to the Google > Groups > > >> "Puppet Users" group. > > >> To post to this group, send email to puppet-users@googlegroups.com. > > >> To unsubscribe from this group, send email to > > >> puppet-users+unsubscribe@googlegroups.com. > > >> For more options, visit this group at > > >>http://groups.google.com/group/puppet-users?hl=en. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Luke Bigum
2011-Jun-17 14:26 UTC
[Puppet Users] Re: Puppet recipe to copy and execute a shell file
How do you know it didn''t work? What''s your shell script expected to do? If you run it by hand in a root shell, does it work then? If so, there might be an environment problem when running from Puppet, like $PATH or something. Try set the parameter "logoutput => true" in the exec resource. On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com> wrote:> Thanks but it couldn''t work though i got the message that shell script is > successfully executed. > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum <Luke.Bi...@lmax.com> wrote: > > Annie, > > >http://docs.puppetlabs.com/references/stable/type.html#exec > > > By default the expected return code is probably zero, your script is > > returning 1. Whether this is correct or not I don''t know, but you can > > tell puppet to expect a different return code: > > > exec { ''/etc/shell_file'': > > require => File[''/etc/shell_file''], > > returns => 1, > > } > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com> wrote: > > > I apologize for posting wrong log messages, here is the correct log: > > > > notice: Starting catalog run > > > notice: //File[/tmp/QoS/QoS.sh]/ensure: created > > > err: //Exec[/tmp/QoS/QoS.sh]/returns: change from notrun to 0 failed: > > > /tmp/QoS/QoS.sh returned 1 instead of 0 at > > /etc/puppet/manifests/site.pp:10 > > > notice: Finished catalog run in 0.46 seconds > > > > Any help please? > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annier...@gmail.com> wrote: > > > > Hi Peter, thanks for your reply. I managed to copy the shell file > > puppet > > > > client using the file resource recipe you specified but exec is > > throwing an > > > > error, which is as follows: > > > > > info: No classes to store > > > > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml > > > > notice: Starting catalog run > > > > err: //File[/tmp/QoS/QoS.sh]/ensure: change from absent to file failed: > > > > Could not set file on ensure: No such file or directory - > > > > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 > > > > notice: //Exec[/tmp/QoS/QoS.sh]: Dependency file[/tmp/QoS/QoS.sh] has 1 > > > > failures > > > > warning: //Exec[/tmp/QoS/QoS.sh]: Skipping because of failed > > dependencies > > > > notice: Finished catalog run in 0.38 seconds > > > > > When I tried running the shell script manually using the following > > command > > > > > ''/tmp/QoS/QoS.sh; echo $?'' > > > > > , it worked fine printing 0 at the end. Any help what is wrong with > > exec > > > > resource recipe? > > > > > Thanks in advance for your time. > > > > > Regards, > > > > > A. > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski <pmb...@gmail.com > > >wrote: > > > > >> It sounds like you haven''t set up the puppet fileserver yet. Choose a > > > >> directory that will hold files you want to copy to clients. I use > > > >> /opt/files, so that''s what is in my example. Create fileserver.conf in > > the > > > >> same directory as puppet.conf and add these lines: > > > > >> [files] > > > >> path /opt/files > > > >> allow *.client.domain > > > > >> Put your shell file in the path you specified. Now you just need to > > set up > > > >> a file and exec resource. Note the source item in the file resource > > and the > > > >> require item in exec. > > > > >> file { ''/etc/shell_file'': > > > >> ensure => present, > > > >> owner => ''root'', > > > >> group => ''root'', > > > >> mode => ''0755'', > > > >> source => ''puppet://puppet/files/shell_file'', > > > >> } > > > > >> exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } > > > > >> -- > > > >> Peter M. Bukowinski > > > >> Systems Engineer > > > >> Janelia Farm Research Campus, HHMI > > > > >> On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > > > >> > Hi all, I am new to puppet. I need a sample recipe to write/copy a > > > >> > shell file on puppet client. The shell file exists on puppet server. > > > >> > Once the file is written, I also want to execute it. I have tried > > > >> > using file resource with ensure command to copy at /etc but > > permission > > > >> > was denied and moreover with a different directory path (\tmp) it > > just > > > >> > created an empty file. Can anyone please help? > > > > >> > Regards, > > > > >> > A. > > > > >> > -- > > > >> > You received this message because you are subscribed to the Google > > > >> Groups "Puppet Users" group. > > > >> > To post to this group, send email to puppet-users@googlegroups.com > > (mailto: > > > >> puppet-users@googlegroups.com). > > > >> > To unsubscribe from this group, send email to > > > >> puppet-users+unsubscribe@googlegroups.com (mailto: > > > >> puppet-users+unsubscribe@googlegroups.com). > > > >> > For more options, visit this group at > > > >>http://groups.google.com/group/puppet-users?hl=en. > > > > >> -- > > > >> You received this message because you are subscribed to the Google > > Groups > > > >> "Puppet Users" group. > > > >> To post to this group, send email to puppet-users@googlegroups.com. > > > >> To unsubscribe from this group, send email to > > > >> puppet-users+unsubscribe@googlegroups.com. > > > >> For more options, visit this group at > > > >>http://groups.google.com/group/puppet-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Puppet Users" group. > > To post to this group, send email to puppet-users@googlegroups.com. > > To unsubscribe from this group, send email to > > puppet-users+unsubscribe@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 14:44 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
Hi Luke, What''s your shell script expected to do? The shell script would generate Iptables rules How do you know it didn''t work? I can check using ipatbles -L or iptables -t mangle -L commands If you run it by hand in a root shell, does it work then? Yes If so, there might be an environment problem when running from Puppet, like $PATH or something. Try set the parameter "logoutput => true" in the exec resource. I did but no affect. Thanks again, much appreciated your help and time. On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum <Luke.Bigum@lmax.com> wrote:> How do you know it didn''t work? What''s your shell script expected to > do? If you run it by hand in a root shell, does it work then? If so, > there might be an environment problem when running from Puppet, like > $PATH or something. Try set the parameter "logoutput => true" in the > exec resource. > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com> wrote: > > Thanks but it couldn''t work though i got the message that shell script is > > successfully executed. > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum <Luke.Bi...@lmax.com> wrote: > > > Annie, > > > > >http://docs.puppetlabs.com/references/stable/type.html#exec > > > > > By default the expected return code is probably zero, your script is > > > returning 1. Whether this is correct or not I don''t know, but you can > > > tell puppet to expect a different return code: > > > > > exec { ''/etc/shell_file'': > > > require => File[''/etc/shell_file''], > > > returns => 1, > > > } > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com> wrote: > > > > I apologize for posting wrong log messages, here is the correct log: > > > > > > notice: Starting catalog run > > > > notice: //File[/tmp/QoS/QoS.sh]/ensure: created > > > > err: //Exec[/tmp/QoS/QoS.sh]/returns: change from notrun to 0 failed: > > > > /tmp/QoS/QoS.sh returned 1 instead of 0 at > > > /etc/puppet/manifests/site.pp:10 > > > > notice: Finished catalog run in 0.46 seconds > > > > > > Any help please? > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annier...@gmail.com> > wrote: > > > > > Hi Peter, thanks for your reply. I managed to copy the shell file > > > puppet > > > > > client using the file resource recipe you specified but exec is > > > throwing an > > > > > error, which is as follows: > > > > > > > info: No classes to store > > > > > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml > > > > > notice: Starting catalog run > > > > > err: //File[/tmp/QoS/QoS.sh]/ensure: change from absent to file > failed: > > > > > Could not set file on ensure: No such file or directory - > > > > > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 > > > > > notice: //Exec[/tmp/QoS/QoS.sh]: Dependency file[/tmp/QoS/QoS.sh] > has 1 > > > > > failures > > > > > warning: //Exec[/tmp/QoS/QoS.sh]: Skipping because of failed > > > dependencies > > > > > notice: Finished catalog run in 0.38 seconds > > > > > > > When I tried running the shell script manually using the following > > > command > > > > > > > ''/tmp/QoS/QoS.sh; echo $?'' > > > > > > > , it worked fine printing 0 at the end. Any help what is wrong with > > > exec > > > > > resource recipe? > > > > > > > Thanks in advance for your time. > > > > > > > Regards, > > > > > > > A. > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < > pmb...@gmail.com > > > >wrote: > > > > > > >> It sounds like you haven''t set up the puppet fileserver yet. > Choose a > > > > >> directory that will hold files you want to copy to clients. I use > > > > >> /opt/files, so that''s what is in my example. Create > fileserver.conf in > > > the > > > > >> same directory as puppet.conf and add these lines: > > > > > > >> [files] > > > > >> path /opt/files > > > > >> allow *.client.domain > > > > > > >> Put your shell file in the path you specified. Now you just need > to > > > set up > > > > >> a file and exec resource. Note the source item in the file > resource > > > and the > > > > >> require item in exec. > > > > > > >> file { ''/etc/shell_file'': > > > > >> ensure => present, > > > > >> owner => ''root'', > > > > >> group => ''root'', > > > > >> mode => ''0755'', > > > > >> source => ''puppet://puppet/files/shell_file'', > > > > >> } > > > > > > >> exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } > > > > > > >> -- > > > > >> Peter M. Bukowinski > > > > >> Systems Engineer > > > > >> Janelia Farm Research Campus, HHMI > > > > > > >> On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > > > > > >> > Hi all, I am new to puppet. I need a sample recipe to write/copy > a > > > > >> > shell file on puppet client. The shell file exists on puppet > server. > > > > >> > Once the file is written, I also want to execute it. I have > tried > > > > >> > using file resource with ensure command to copy at /etc but > > > permission > > > > >> > was denied and moreover with a different directory path (\tmp) > it > > > just > > > > >> > created an empty file. Can anyone please help? > > > > > > >> > Regards, > > > > > > >> > A. > > > > > > >> > -- > > > > >> > You received this message because you are subscribed to the > Google > > > > >> Groups "Puppet Users" group. > > > > >> > To post to this group, send email to > puppet-users@googlegroups.com > > > (mailto: > > > > >> puppet-users@googlegroups.com). > > > > >> > To unsubscribe from this group, send email to > > > > >> puppet-users+unsubscribe@googlegroups.com (mailto: > > > > >> puppet-users+unsubscribe@googlegroups.com). > > > > >> > For more options, visit this group at > > > > >>http://groups.google.com/group/puppet-users?hl=en. > > > > > > >> -- > > > > >> You received this message because you are subscribed to the Google > > > Groups > > > > >> "Puppet Users" group. > > > > >> To post to this group, send email to > puppet-users@googlegroups.com. > > > > >> To unsubscribe from this group, send email to > > > > >> puppet-users+unsubscribe@googlegroups.com. > > > > >> For more options, visit this group at > > > > >>http://groups.google.com/group/puppet-users?hl=en. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Puppet Users" group. > > > To post to this group, send email to puppet-users@googlegroups.com. > > > To unsubscribe from this group, send email to > > > puppet-users+unsubscribe@googlegroups.com. > > > For more options, visit this group at > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 14:49 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
Here is site.pp ============================= file {"/tmp/QoS/QoS.sh": ensure =>present, owner=>''root'', group=>''root'', mode=>''777'', source=>''puppet://puppet/files/QoS.sh'', } exec {"/tmp/QoS/QoS.sh": require=>File[''/tmp/QoS/QoS.sh''], } =============================== Here is the QoS.sh Script: =============================== #!/bin/bash #create alias for interfaces to avoid confusion export LAN=eth1 export WAN=eth0 #----------------------------------------------------------------------QoS Settings----------------------------------------------------------# #Rules for engress queue #----------------------------------start-------------------------- #create priority queue tc qdisc add dev ${WAN} root handle 1: htb default 13 tc class add dev ${WAN} parent 1: classid 1:1 htb rate 50kbps ceil 50kbps # voip class tc class add dev ${WAN} parent 1:1 classid 1:10 htb rate 30kbps ceil 50kbps prio 1 #stream class tc class add dev ${WAN} parent 1:1 classid 1:11 htb rate 30kbps ceil 30kbps prio 2 #http, https, ssh, telnet class tc class add dev ${WAN} parent 1:1 classid 1:12 htb rate 20kbps ceil 30kbps prio 3 #ftp class tc class add dev ${WAN} parent 1:1 classid 1:13 htb rate 20kbps ceil 20kbps prio 4 #attach sfq on every class tc qdisc add dev ${WAN} parent 1:10 handle 20: sfq perturb 10 tc qdisc add dev ${WAN} parent 1:11 handle 30: sfq perturb 10 tc qdisc add dev ${WAN} parent 1:12 handle 40: sfq perturb 10 tc qdisc add dev ${WAN} parent 1:13 handle 60: sfq perturb 10 #define class filters tc filter add dev ${WAN} parent 1:0 prio 1 protocol ip u32 match ip tos 0x28 0xff classid 1:10 tc filter add dev ${WAN} parent 1:0 prio 2 protocol ip u32 match ip tos 0x48 0xff classid 1:11 tc filter add dev ${WAN} parent 1:0 prio 3 protocol ip u32 match ip tos 0x68 0xff classid 1:12 tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match ip tos 0x88 0xff classid 1:12 #-------------------------------------end---------------------------------------- iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 2345 -j TOS --set-tos 0x28 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 2345 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 2345 -j TOS --set-tos 0x28 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 2345 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport telnet -j TOS --set-tos 0x28 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport telnet -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport telnet -j TOS --set-tos 0x28 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport telnet -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport ssh -j TOS --set-tos 0x28 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport ssh -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport ssh -j TOS --set-tos 0x28 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport ssh -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j TOS --set-tos 0x28 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -j RETURN iptables -t mangle -I FORWARD -i ${LAN} -o ${WAN} -p udp --sport sip -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport sip -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport sip -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport sip -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 5060 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 5060 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 5060 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 5060 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 4569 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 4569 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 4569 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 4569 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 5036 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 5036 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 5036 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 5036 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 10000:20000 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 10000:20000 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 10000:20000 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 10000:20000 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 2727 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 2727 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 2727 -j TOS --set-tos 0x48 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --dport 2727 -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport http -j TOS --set-tos 0x68 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport http -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport http -j TOS --set-tos 0x68 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport http -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport https -j TOS --set-tos 0x68 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport https -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport https -j TOS --set-tos 0x68 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport https -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport ftp -j TOS --set-tos 0x88 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport ftp -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport ftp -j TOS --set-tos 0x88 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport ftp -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport ftp-data -j TOS --set-tos 0x88 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --dport ftp-data -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport ftp-data -j TOS --set-tos 0x88 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p tcp --sport ftp-data -j RETURN iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -j TOS --set-tos 0x88 iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -j RETURN #save iptables rules iptables-save =============================================================== On Fri, Jun 17, 2011 at 3:44 PM, Annie Rana <annierana@gmail.com> wrote:> Hi Luke, > What''s your shell script expected to > do? > The shell script would generate Iptables rules > > How do you know it didn''t work? > I can check using ipatbles -L or iptables -t mangle -L commands > > > If you run it by hand in a root shell, does it work then? > Yes > > If so, > there might be an environment problem when running from Puppet, like > $PATH or something. Try set the parameter "logoutput => true" in the > exec resource. > I did but no affect. > > Thanks again, much appreciated your help and time. > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum <Luke.Bigum@lmax.com> wrote: > >> How do you know it didn''t work? What''s your shell script expected to >> do? If you run it by hand in a root shell, does it work then? If so, >> there might be an environment problem when running from Puppet, like >> $PATH or something. Try set the parameter "logoutput => true" in the >> exec resource. >> >> On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com> wrote: >> > Thanks but it couldn''t work though i got the message that shell script >> is >> > successfully executed. >> > >> > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum <Luke.Bi...@lmax.com> >> wrote: >> > > Annie, >> > >> > >http://docs.puppetlabs.com/references/stable/type.html#exec >> > >> > > By default the expected return code is probably zero, your script is >> > > returning 1. Whether this is correct or not I don''t know, but you can >> > > tell puppet to expect a different return code: >> > >> > > exec { ''/etc/shell_file'': >> > > require => File[''/etc/shell_file''], >> > > returns => 1, >> > > } >> > >> > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com> wrote: >> > > > I apologize for posting wrong log messages, here is the correct log: >> > >> > > > notice: Starting catalog run >> > > > notice: //File[/tmp/QoS/QoS.sh]/ensure: created >> > > > err: //Exec[/tmp/QoS/QoS.sh]/returns: change from notrun to 0 >> failed: >> > > > /tmp/QoS/QoS.sh returned 1 instead of 0 at >> > > /etc/puppet/manifests/site.pp:10 >> > > > notice: Finished catalog run in 0.46 seconds >> > >> > > > Any help please? >> > >> > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annier...@gmail.com> >> wrote: >> > > > > Hi Peter, thanks for your reply. I managed to copy the shell file >> > > puppet >> > > > > client using the file resource recipe you specified but exec is >> > > throwing an >> > > > > error, which is as follows: >> > >> > > > > info: No classes to store >> > > > > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml >> > > > > notice: Starting catalog run >> > > > > err: //File[/tmp/QoS/QoS.sh]/ensure: change from absent to file >> failed: >> > > > > Could not set file on ensure: No such file or directory - >> > > > > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 >> > > > > notice: //Exec[/tmp/QoS/QoS.sh]: Dependency file[/tmp/QoS/QoS.sh] >> has 1 >> > > > > failures >> > > > > warning: //Exec[/tmp/QoS/QoS.sh]: Skipping because of failed >> > > dependencies >> > > > > notice: Finished catalog run in 0.38 seconds >> > >> > > > > When I tried running the shell script manually using the following >> > > command >> > >> > > > > ''/tmp/QoS/QoS.sh; echo $?'' >> > >> > > > > , it worked fine printing 0 at the end. Any help what is wrong >> with >> > > exec >> > > > > resource recipe? >> > >> > > > > Thanks in advance for your time. >> > >> > > > > Regards, >> > >> > > > > A. >> > >> > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < >> pmb...@gmail.com >> > > >wrote: >> > >> > > > >> It sounds like you haven''t set up the puppet fileserver yet. >> Choose a >> > > > >> directory that will hold files you want to copy to clients. I use >> > > > >> /opt/files, so that''s what is in my example. Create >> fileserver.conf in >> > > the >> > > > >> same directory as puppet.conf and add these lines: >> > >> > > > >> [files] >> > > > >> path /opt/files >> > > > >> allow *.client.domain >> > >> > > > >> Put your shell file in the path you specified. Now you just need >> to >> > > set up >> > > > >> a file and exec resource. Note the source item in the file >> resource >> > > and the >> > > > >> require item in exec. >> > >> > > > >> file { ''/etc/shell_file'': >> > > > >> ensure => present, >> > > > >> owner => ''root'', >> > > > >> group => ''root'', >> > > > >> mode => ''0755'', >> > > > >> source => ''puppet://puppet/files/shell_file'', >> > > > >> } >> > >> > > > >> exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } >> > >> > > > >> -- >> > > > >> Peter M. Bukowinski >> > > > >> Systems Engineer >> > > > >> Janelia Farm Research Campus, HHMI >> > >> > > > >> On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: >> > >> > > > >> > Hi all, I am new to puppet. I need a sample recipe to >> write/copy a >> > > > >> > shell file on puppet client. The shell file exists on puppet >> server. >> > > > >> > Once the file is written, I also want to execute it. I have >> tried >> > > > >> > using file resource with ensure command to copy at /etc but >> > > permission >> > > > >> > was denied and moreover with a different directory path (\tmp) >> it >> > > just >> > > > >> > created an empty file. Can anyone please help? >> > >> > > > >> > Regards, >> > >> > > > >> > A. >> > >> > > > >> > -- >> > > > >> > You received this message because you are subscribed to the >> Google >> > > > >> Groups "Puppet Users" group. >> > > > >> > To post to this group, send email to >> puppet-users@googlegroups.com >> > > (mailto: >> > > > >> puppet-users@googlegroups.com). >> > > > >> > To unsubscribe from this group, send email to >> > > > >> puppet-users+unsubscribe@googlegroups.com (mailto: >> > > > >> puppet-users+unsubscribe@googlegroups.com). >> > > > >> > For more options, visit this group at >> > > > >>http://groups.google.com/group/puppet-users?hl=en. >> > >> > > > >> -- >> > > > >> You received this message because you are subscribed to the >> Google >> > > Groups >> > > > >> "Puppet Users" group. >> > > > >> To post to this group, send email to >> puppet-users@googlegroups.com. >> > > > >> To unsubscribe from this group, send email to >> > > > >> puppet-users+unsubscribe@googlegroups.com. >> > > > >> For more options, visit this group at >> > > > >>http://groups.google.com/group/puppet-users?hl=en. >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> Groups >> > > "Puppet Users" group. >> > > To post to this group, send email to puppet-users@googlegroups.com. >> > > To unsubscribe from this group, send email to >> > > puppet-users+unsubscribe@googlegroups.com. >> > > For more options, visit this group at >> > >http://groups.google.com/group/puppet-users?hl=en. >> > >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To post to this group, send email to puppet-users@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-users+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> >> >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Peter Bukowinski
2011-Jun-17 14:52 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
In your QoS.sh file, make sure to use explicit paths to executables, e.g: use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' -- Peter M. Bukowinski Systems Engineer Janelia Farm Research Campus, HHMI On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote:> Hi Luke, > What''s your shell script expected to > do? > The shell script would generate Iptables rules > > How do you know it didn''t work? > I can check using ipatbles -L or iptables -t mangle -L commands > > > If you run it by hand in a root shell, does it work then? > Yes > > If so, > there might be an environment problem when running from Puppet, like > $PATH or something. Try set the parameter "logoutput => true" in the > exec resource. > I did but no affect. > > Thanks again, much appreciated your help and time. > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum <Luke.Bigum@lmax.com (mailto:Luke.Bigum@lmax.com)> wrote: > > How do you know it didn''t work? What''s your shell script expected to > > do? If you run it by hand in a root shell, does it work then? If so, > > there might be an environment problem when running from Puppet, like > > $PATH or something. Try set the parameter "logoutput => true" in the > > exec resource. > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com (mailto:annier...@gmail.com)> wrote: > > > Thanks but it couldn''t work though i got the message that shell script is > > > successfully executed. > > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum <Luke.Bi...@lmax.com (mailto:Luke.Bi...@lmax.com)> wrote: > > > > Annie, > > > > > > > http://docs.puppetlabs.com/references/stable/type.html#exec > > > > > > > By default the expected return code is probably zero, your script is > > > > returning 1. Whether this is correct or not I don''t know, but you can > > > > tell puppet to expect a different return code: > > > > > > > exec { ''/etc/shell_file'': > > > > require => File[''/etc/shell_file''], > > > > returns => 1, > > > > } > > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com (mailto:annier...@gmail.com)> wrote: > > > > > I apologize for posting wrong log messages, here is the correct log: > > > > > > > > notice: Starting catalog run > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: created > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: change from notrun to 0 failed: > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of 0 at > > > > /etc/puppet/manifests/site.pp:10 > > > > > notice: Finished catalog run in 0.46 seconds > > > > > > > > Any help please? > > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annier...@gmail.com (mailto:annier...@gmail.com)> wrote: > > > > > > Hi Peter, thanks for your reply. I managed to copy the shell file > > > > puppet > > > > > > client using the file resource recipe you specified but exec is > > > > throwing an > > > > > > error, which is as follows: > > > > > > > > > info: No classes to store > > > > > > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml > > > > > > notice: Starting catalog run > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: change from absent to file failed: > > > > > > Could not set file on ensure: No such file or directory - > > > > > > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: Dependency file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 > > > > > > failures > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: Skipping because of failed > > > > dependencies > > > > > > notice: Finished catalog run in 0.38 seconds > > > > > > > > > When I tried running the shell script manually using the following > > > > command > > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh); echo $?'' > > > > > > > > > , it worked fine printing 0 at the end. Any help what is wrong with > > > > exec > > > > > > resource recipe? > > > > > > > > > Thanks in advance for your time. > > > > > > > > > Regards, > > > > > > > > > A. > > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski <pmb...@gmail.com (mailto:pmb...@gmail.com) > > > > > wrote: > > > > > > > > > > It sounds like you haven''t set up the puppet fileserver yet. Choose a > > > > > > > directory that will hold files you want to copy to clients. I use > > > > > > > /opt/files, so that''s what is in my example. Create fileserver.conf in > > > > the > > > > > > > same directory as puppet.conf and add these lines: > > > > > > > > > > [files] > > > > > > > path /opt/files > > > > > > > allow *.client.domain > > > > > > > > > > Put your shell file in the path you specified. Now you just need to > > > > set up > > > > > > > a file and exec resource. Note the source item in the file resource > > > > and the > > > > > > > require item in exec. > > > > > > > > > > file { ''/etc/shell_file'': > > > > > > > ensure => present, > > > > > > > owner => ''root'', > > > > > > > group => ''root'', > > > > > > > mode => ''0755'', > > > > > > > source => ''puppet://puppet/files/shell_file'', > > > > > > > } > > > > > > > > > > exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } > > > > > > > > > > -- > > > > > > > Peter M. Bukowinski > > > > > > > Systems Engineer > > > > > > > Janelia Farm Research Campus, HHMI > > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > > > > > > > > > > Hi all, I am new to puppet. I need a sample recipe to write/copy a > > > > > > > > shell file on puppet client. The shell file exists on puppet server. > > > > > > > > Once the file is written, I also want to execute it. I have tried > > > > > > > > using file resource with ensure command to copy at /etc but > > > > permission > > > > > > > > was denied and moreover with a different directory path (\tmp) it > > > > just > > > > > > > > created an empty file. Can anyone please help? > > > > > > > > > > > Regards, > > > > > > > > > > > A. > > > > > > > > > > > -- > > > > > > > > You received this message because you are subscribed to the Google > > > > > > > Groups "Puppet Users" group. > > > > > > > > To post to this group, send email to puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com) > > > > (mailto: > > > > > > > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com)). > > > > > > > > To unsubscribe from this group, send email to > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users%2Bunsubscribe@googlegroups.com) (mailto: > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users%2Bunsubscribe@googlegroups.com)). > > > > > > > > For more options, visit this group at > > > > > > > http://groups.google.com/group/puppet-users?hl=en. > > > > > > > > > > -- > > > > > > > You received this message because you are subscribed to the Google > > > > Groups > > > > > > > "Puppet Users" group. > > > > > > > To post to this group, send email to puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). > > > > > > > To unsubscribe from this group, send email to > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users%2Bunsubscribe@googlegroups.com). > > > > > > > For more options, visit this group at > > > > > > > http://groups.google.com/group/puppet-users?hl=en. > > > > > > > -- > > > > You received this message because you are subscribed to the Google Groups > > > > "Puppet Users" group. > > > > To post to this group, send email to puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). > > > > To unsubscribe from this group, send email to > > > > puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users%2Bunsubscribe@googlegroups.com). > > > > For more options, visit this group at > > > > http://groups.google.com/group/puppet-users?hl=en. > > > > -- > > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > > To post to this group, send email to puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). > > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users%2Bunsubscribe@googlegroups.com). > > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users+unsubscribe@googlegroups.com). > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 15:01 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
Thanks again Peter but sorry it didn''t work out either. On Fri, Jun 17, 2011 at 3:52 PM, Peter Bukowinski <pmbuko@gmail.com> wrote:> In your QoS.sh file, make sure to use explicit paths to executables, e.g: > > use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' > > > -- > Peter M. Bukowinski > Systems Engineer > Janelia Farm Research Campus, HHMI > > On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote: > > > Hi Luke, > > What''s your shell script expected to > > do? > > The shell script would generate Iptables rules > > > > How do you know it didn''t work? > > I can check using ipatbles -L or iptables -t mangle -L commands > > > > > > If you run it by hand in a root shell, does it work then? > > Yes > > > > If so, > > there might be an environment problem when running from Puppet, like > > $PATH or something. Try set the parameter "logoutput => true" in the > > exec resource. > > I did but no affect. > > > > Thanks again, much appreciated your help and time. > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum <Luke.Bigum@lmax.com(mailto: > Luke.Bigum@lmax.com)> wrote: > > > How do you know it didn''t work? What''s your shell script expected to > > > do? If you run it by hand in a root shell, does it work then? If so, > > > there might be an environment problem when running from Puppet, like > > > $PATH or something. Try set the parameter "logoutput => true" in the > > > exec resource. > > > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com (mailto: > annier...@gmail.com)> wrote: > > > > Thanks but it couldn''t work though i got the message that shell > script is > > > > successfully executed. > > > > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum <Luke.Bi...@lmax.com(mailto: > Luke.Bi...@lmax.com)> wrote: > > > > > Annie, > > > > > > > > > http://docs.puppetlabs.com/references/stable/type.html#exec > > > > > > > > > By default the expected return code is probably zero, your script > is > > > > > returning 1. Whether this is correct or not I don''t know, but you > can > > > > > tell puppet to expect a different return code: > > > > > > > > > exec { ''/etc/shell_file'': > > > > > require => File[''/etc/shell_file''], > > > > > returns => 1, > > > > > } > > > > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com (mailto: > annier...@gmail.com)> wrote: > > > > > > I apologize for posting wrong log messages, here is the correct > log: > > > > > > > > > > notice: Starting catalog run > > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: created > > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: change > from notrun to 0 failed: > > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of 0 at > > > > > /etc/puppet/manifests/site.pp:10 > > > > > > notice: Finished catalog run in 0.46 seconds > > > > > > > > > > Any help please? > > > > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annier...@gmail.com(mailto: > annier...@gmail.com)> wrote: > > > > > > > Hi Peter, thanks for your reply. I managed to copy the shell > file > > > > > puppet > > > > > > > client using the file resource recipe you specified but exec is > > > > > throwing an > > > > > > > error, which is as follows: > > > > > > > > > > > info: No classes to store > > > > > > > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml > > > > > > > notice: Starting catalog run > > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: change > from absent to file failed: > > > > > > > Could not set file on ensure: No such file or directory - > > > > > > > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 > > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: Dependency > file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 > > > > > > > failures > > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: Skipping > because of failed > > > > > dependencies > > > > > > > notice: Finished catalog run in 0.38 seconds > > > > > > > > > > > When I tried running the shell script manually using the > following > > > > > command > > > > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh); echo $?'' > > > > > > > > > > > , it worked fine printing 0 at the end. Any help what is wrong > with > > > > > exec > > > > > > > resource recipe? > > > > > > > > > > > Thanks in advance for your time. > > > > > > > > > > > Regards, > > > > > > > > > > > A. > > > > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < > pmb...@gmail.com (mailto:pmb...@gmail.com) > > > > > > wrote: > > > > > > > > > > > > It sounds like you haven''t set up the puppet fileserver yet. > Choose a > > > > > > > > directory that will hold files you want to copy to clients. I > use > > > > > > > > /opt/files, so that''s what is in my example. Create > fileserver.conf in > > > > > the > > > > > > > > same directory as puppet.conf and add these lines: > > > > > > > > > > > > [files] > > > > > > > > path /opt/files > > > > > > > > allow *.client.domain > > > > > > > > > > > > Put your shell file in the path you specified. Now you just > need to > > > > > set up > > > > > > > > a file and exec resource. Note the source item in the file > resource > > > > > and the > > > > > > > > require item in exec. > > > > > > > > > > > > file { ''/etc/shell_file'': > > > > > > > > ensure => present, > > > > > > > > owner => ''root'', > > > > > > > > group => ''root'', > > > > > > > > mode => ''0755'', > > > > > > > > source => ''puppet://puppet/files/shell_file'', > > > > > > > > } > > > > > > > > > > > > exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] > } > > > > > > > > > > > > -- > > > > > > > > Peter M. Bukowinski > > > > > > > > Systems Engineer > > > > > > > > Janelia Farm Research Campus, HHMI > > > > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > > > > > > > > > > > > Hi all, I am new to puppet. I need a sample recipe to > write/copy a > > > > > > > > > shell file on puppet client. The shell file exists on > puppet server. > > > > > > > > > Once the file is written, I also want to execute it. I have > tried > > > > > > > > > using file resource with ensure command to copy at /etc but > > > > > permission > > > > > > > > > was denied and moreover with a different directory path > (\tmp) it > > > > > just > > > > > > > > > created an empty file. Can anyone please help? > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > A. > > > > > > > > > > > > > -- > > > > > > > > > You received this message because you are subscribed to the > Google > > > > > > > > Groups "Puppet Users" group. > > > > > > > > > To post to this group, send email to > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com) > > > > > (mailto: > > > > > > > > puppet-users@googlegroups.com (mailto: > puppet-users@googlegroups.com)). > > > > > > > > > To unsubscribe from this group, send email to > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > puppet-users%2Bunsubscribe@googlegroups.com) (mailto: > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > puppet-users%2Bunsubscribe@googlegroups.com)). > > > > > > > > > For more options, visit this group at > > > > > > > > http://groups.google.com/group/puppet-users?hl=en. > > > > > > > > > > > > -- > > > > > > > > You received this message because you are subscribed to the > Google > > > > > Groups > > > > > > > > "Puppet Users" group. > > > > > > > > To post to this group, send email to > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). > > > > > > > > To unsubscribe from this group, send email to > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > puppet-users%2Bunsubscribe@googlegroups.com). > > > > > > > > For more options, visit this group at > > > > > > > > http://groups.google.com/group/puppet-users?hl=en. > > > > > > > > > -- > > > > > You received this message because you are subscribed to the Google > Groups > > > > > "Puppet Users" group. > > > > > To post to this group, send email to puppet-users@googlegroups.com(mailto: > puppet-users@googlegroups.com). > > > > > To unsubscribe from this group, send email to > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > puppet-users%2Bunsubscribe@googlegroups.com). > > > > > For more options, visit this group at > > > > > http://groups.google.com/group/puppet-users?hl=en. > > > > > > -- > > > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > > > To post to this group, send email to puppet-users@googlegroups.com(mailto: > puppet-users@googlegroups.com). > > > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com (mailto: > puppet-users%2Bunsubscribe@googlegroups.com). > > > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > > > > -- > > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > > To post to this group, send email to puppet-users@googlegroups.com(mailto: > puppet-users@googlegroups.com). > > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com (mailto: > puppet-users+unsubscribe@googlegroups.com). > > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Luke Bigum
2011-Jun-17 15:06 UTC
[Puppet Users] Re: Puppet recipe to copy and execute a shell file
I''m out of ideas and I''d resort to hacking the script a bit to get some debugging output. Try just this in QoS.sh to try identify what''s failing: export LAN=eth1 export WAN=eth0 CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match ip tos 0x880xff classid 1:12" OUT=$($CMD) > /tmp/QoS.out 2>&1 RET=$? print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 2345 -j TOS --set-tos 0x28" OUT=$($CMD) >> /tmp/QoS.out 2>&1 RET=$? print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 CMD="iptables-save" OUT=$($CMD) >> /tmp/QoS.out 2>&1 RET=$? print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 Or something like that. On Jun 17, 4:01 pm, Annie Rana <annier...@gmail.com> wrote:> Thanks again Peter but sorry it didn''t work out either. > > On Fri, Jun 17, 2011 at 3:52 PM, Peter Bukowinski <pmb...@gmail.com> wrote: > > In your QoS.sh file, make sure to use explicit paths to executables, e.g: > > > use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' > > > -- > > Peter M. Bukowinski > > Systems Engineer > > Janelia Farm Research Campus, HHMI > > > On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote: > > > > Hi Luke, > > > What''s your shell script expected to > > > do? > > > The shell script would generate Iptables rules > > > > How do you know it didn''t work? > > > I can check using ipatbles -L or iptables -t mangle -L commands > > > > If you run it by hand in a root shell, does it work then? > > > Yes > > > > If so, > > > there might be an environment problem when running from Puppet, like > > > $PATH or something. Try set the parameter "logoutput => true" in the > > > exec resource. > > > I did but no affect. > > > > Thanks again, much appreciated your help and time. > > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum <Luke.Bi...@lmax.com(mailto: > > Luke.Bi...@lmax.com)> wrote: > > > > How do you know it didn''t work? What''s your shell script expected to > > > > do? If you run it by hand in a root shell, does it work then? If so, > > > > there might be an environment problem when running from Puppet, like > > > > $PATH or something. Try set the parameter "logoutput => true" in the > > > > exec resource. > > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com (mailto: > > annier...@gmail.com)> wrote: > > > > > Thanks but it couldn''t work though i got the message that shell > > script is > > > > > successfully executed. > > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum <Luke.Bi...@lmax.com(mailto: > > Luke.Bi...@lmax.com)> wrote: > > > > > > Annie, > > > > > > >http://docs.puppetlabs.com/references/stable/type.html#exec > > > > > > > By default the expected return code is probably zero, your script > > is > > > > > > returning 1. Whether this is correct or not I don''t know, but you > > can > > > > > > tell puppet to expect a different return code: > > > > > > > exec { ''/etc/shell_file'': > > > > > > require => File[''/etc/shell_file''], > > > > > > returns => 1, > > > > > > } > > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com (mailto: > > annier...@gmail.com)> wrote: > > > > > > > I apologize for posting wrong log messages, here is the correct > > log: > > > > > > > > notice: Starting catalog run > > > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: created > > > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: change > > from notrun to 0 failed: > > > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of 0 at > > > > > > /etc/puppet/manifests/site.pp:10 > > > > > > > notice: Finished catalog run in 0.46 seconds > > > > > > > > Any help please? > > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana <annier...@gmail.com(mailto: > > annier...@gmail.com)> wrote: > > > > > > > > Hi Peter, thanks for your reply. I managed to copy the shell > > file > > > > > > puppet > > > > > > > > client using the file resource recipe you specified but exec is > > > > > > throwing an > > > > > > > > error, which is as follows: > > > > > > > > > info: No classes to store > > > > > > > > info: Caching catalog at /var/lib/puppet/state/localconfig.yaml > > > > > > > > notice: Starting catalog run > > > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: change > > from absent to file failed: > > > > > > > > Could not set file on ensure: No such file or directory - > > > > > > > > /tmp/QoS/QoS.sh.puppettmp at /etc/puppet/manifests/site.pp:7 > > > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: Dependency > > file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 > > > > > > > > failures > > > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: Skipping > > because of failed > > > > > > dependencies > > > > > > > > notice: Finished catalog run in 0.38 seconds > > > > > > > > > When I tried running the shell script manually using the > > following > > > > > > command > > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh);echo $?'' > > > > > > > > > , it worked fine printing 0 at the end. Any help what is wrong > > with > > > > > > exec > > > > > > > > resource recipe? > > > > > > > > > Thanks in advance for your time. > > > > > > > > > Regards, > > > > > > > > > A. > > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < > > pmb...@gmail.com (mailto:pmb...@gmail.com) > > > > > > > wrote: > > > > > > > > > > It sounds like you haven''t set up the puppet fileserver yet. > > Choose a > > > > > > > > > directory that will hold files you want to copy to clients. I > > use > > > > > > > > > /opt/files, so that''s what is in my example. Create > > fileserver.conf in > > > > > > the > > > > > > > > > same directory as puppet.conf and add these lines: > > > > > > > > > > [files] > > > > > > > > > path /opt/files > > > > > > > > > allow *.client.domain > > > > > > > > > > Put your shell file in the path you specified. Now you just > > need to > > > > > > set up > > > > > > > > > a file and exec resource. Note the source item in the file > > resource > > > > > > and the > > > > > > > > > require item in exec. > > > > > > > > > > file { ''/etc/shell_file'': > > > > > > > > > ensure => present, > > > > > > > > > owner => ''root'', > > > > > > > > > group => ''root'', > > > > > > > > > mode => ''0755'', > > > > > > > > > source => ''puppet://puppet/files/shell_file'', > > > > > > > > > } > > > > > > > > > > exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] > > } > > > > > > > > > > -- > > > > > > > > > Peter M. Bukowinski > > > > > > > > > Systems Engineer > > > > > > > > > Janelia Farm Research Campus, HHMI > > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > > > > > > > > > > Hi all, I am new to puppet. I need a sample recipe to > > write/copy a > > > > > > > > > > shell file on puppet client. The shell file exists on > > puppet server. > > > > > > > > > > Once the file is written, I also want to execute it. I have > > tried > > > > > > > > > > using file resource with ensure command to copy at /etc but > > > > > > permission > > > > > > > > > > was denied and moreover with a different directory path > > (\tmp) it > > > > > > just > > > > > > > > > > created an empty file. Can anyone please help? > > > > > > > > > > > Regards, > > > > > > > > > > > A. > > > > > > > > > > > -- > > > > > > > > > > You received this message because you are subscribed to the > > Google > > > > > > > > > Groups "Puppet Users" group. > > > > > > > > > > To post to this group, send email to > > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com) > > > > > > (mailto: > > > > > > > > > puppet-users@googlegroups.com (mailto: > > puppet-users@googlegroups.com)). > > > > > > > > > > To unsubscribe from this group, send email to > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > puppet-users%2Bunsubscribe@googlegroups.com) (mailto: > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > puppet-users%2Bunsubscribe@googlegroups.com)). > > > > > > > > > > For more options, visit this group at > > > > > > > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > > > > > > -- > > > > > > > > > You received this message because you are subscribed to the > > Google > > > > > > Groups > > > > > > > > > "Puppet Users" group. > > > > > > > > > To post to this group, send email to > > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). > > > > > > > > > To unsubscribe from this group, send email to > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > puppet-users%2Bunsubscribe@googlegroups.com). > > > > > > > > > For more options, visit this group at > > > > > > > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > > > -- > > > > > > You received this message because you are subscribed to the Google > > Groups > > > > > > "Puppet Users" group. > > > > > > To post to this group, send email to puppet-users@googlegroups.com(mailto: > > puppet-users@googlegroups.com). > > > > > > To unsubscribe from this group, send email to > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > puppet-users%2Bunsubscribe@googlegroups.com). > > > > > > For more options, visit this group at > > > > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > -- > > > > You received this message because you are subscribed to the Google > > Groups "Puppet Users" group. > > > > To post to this group, send email to puppet-users@googlegroups.com(mailto: > > puppet-users@googlegroups.com). > > > > To unsubscribe from this group, send email to > > puppet-users+unsubscribe@googlegroups.com (mailto: > > puppet-users%2Bunsubscribe@googlegroups.com). > > > > For more options, visit this group at > >http://groups.google.com/group/puppet-users?hl=en. > > > > -- > > > You received this message because you are subscribed to the Google > > Groups "Puppet Users" group. > > > To post to this group, send email to puppet-users@googlegroups.com(mailto: > > puppet-users@googlegroups.com). > > > To unsubscribe from this group, send email to > > puppet-users+unsubscribe@googlegroups.com (mailto: > > puppet-users+unsubscribe@googlegroups.com). > > > For more options, visit this group at > >http://groups.google.com/group/puppet-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Puppet Users" group. > > To post to this group, send email to puppet-users@googlegroups.com. > > To unsubscribe from this group, send email to > > puppet-users+unsubscribe@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 15:30 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
Hi Luke, I replaced my shell script with the one you wrote. Same old error message appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh returned 1 instead of o at /etc/puppet/manifests/site.pp''. Your script didn''t generated any log at client machine. Now I am sure about one thing that there is no issue with the shell script itself. The exec command is having hiccup even before executing the shell. I even tried command paremeter in exec but no use. Do you know anyother way to execute bash shell in puppet? Thanks much, Annie On Fri, Jun 17, 2011 at 4:06 PM, Luke Bigum <Luke.Bigum@lmax.com> wrote:> I''m out of ideas and I''d resort to hacking the script a bit to get > some debugging output. Try just this in QoS.sh to try identify what''s > failing: > > export LAN=eth1 > export WAN=eth0 > CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match > ip tos 0x880xff classid 1:12" > OUT=$($CMD) > /tmp/QoS.out 2>&1 > RET=$? > print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport > 2345 -j TOS --set-tos 0x28" > OUT=$($CMD) >> /tmp/QoS.out 2>&1 > RET=$? > print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > CMD="iptables-save" > OUT=$($CMD) >> /tmp/QoS.out 2>&1 > RET=$? > print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > > > Or something like that. > > On Jun 17, 4:01 pm, Annie Rana <annier...@gmail.com> wrote: > > Thanks again Peter but sorry it didn''t work out either. > > > > On Fri, Jun 17, 2011 at 3:52 PM, Peter Bukowinski <pmb...@gmail.com> > wrote: > > > In your QoS.sh file, make sure to use explicit paths to executables, > e.g: > > > > > use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' > > > > > -- > > > Peter M. Bukowinski > > > Systems Engineer > > > Janelia Farm Research Campus, HHMI > > > > > On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote: > > > > > > Hi Luke, > > > > What''s your shell script expected to > > > > do? > > > > The shell script would generate Iptables rules > > > > > > How do you know it didn''t work? > > > > I can check using ipatbles -L or iptables -t mangle -L commands > > > > > > If you run it by hand in a root shell, does it work then? > > > > Yes > > > > > > If so, > > > > there might be an environment problem when running from Puppet, like > > > > $PATH or something. Try set the parameter "logoutput => true" in the > > > > exec resource. > > > > I did but no affect. > > > > > > Thanks again, much appreciated your help and time. > > > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum <Luke.Bi...@lmax.com > (mailto: > > > Luke.Bi...@lmax.com)> wrote: > > > > > How do you know it didn''t work? What''s your shell script expected > to > > > > > do? If you run it by hand in a root shell, does it work then? If > so, > > > > > there might be an environment problem when running from Puppet, > like > > > > > $PATH or something. Try set the parameter "logoutput => true" in > the > > > > > exec resource. > > > > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com (mailto: > > > annier...@gmail.com)> wrote: > > > > > > Thanks but it couldn''t work though i got the message that shell > > > script is > > > > > > successfully executed. > > > > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum <Luke.Bi...@lmax.com > (mailto: > > > Luke.Bi...@lmax.com)> wrote: > > > > > > > Annie, > > > > > > > > >http://docs.puppetlabs.com/references/stable/type.html#exec > > > > > > > > > By default the expected return code is probably zero, your > script > > > is > > > > > > > returning 1. Whether this is correct or not I don''t know, but > you > > > can > > > > > > > tell puppet to expect a different return code: > > > > > > > > > exec { ''/etc/shell_file'': > > > > > > > require => File[''/etc/shell_file''], > > > > > > > returns => 1, > > > > > > > } > > > > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com (mailto: > > > annier...@gmail.com)> wrote: > > > > > > > > I apologize for posting wrong log messages, here is the > correct > > > log: > > > > > > > > > > notice: Starting catalog run > > > > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: > created > > > > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: change > > > from notrun to 0 failed: > > > > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of 0 at > > > > > > > /etc/puppet/manifests/site.pp:10 > > > > > > > > notice: Finished catalog run in 0.46 seconds > > > > > > > > > > Any help please? > > > > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana < > annier...@gmail.com(mailto: > > > annier...@gmail.com)> wrote: > > > > > > > > > Hi Peter, thanks for your reply. I managed to copy the > shell > > > file > > > > > > > puppet > > > > > > > > > client using the file resource recipe you specified but > exec is > > > > > > > throwing an > > > > > > > > > error, which is as follows: > > > > > > > > > > > info: No classes to store > > > > > > > > > info: Caching catalog at > /var/lib/puppet/state/localconfig.yaml > > > > > > > > > notice: Starting catalog run > > > > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: > change > > > from absent to file failed: > > > > > > > > > Could not set file on ensure: No such file or directory - > > > > > > > > > /tmp/QoS/QoS.sh.puppettmp at > /etc/puppet/manifests/site.pp:7 > > > > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: > Dependency > > > file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 > > > > > > > > > failures > > > > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: Skipping > > > because of failed > > > > > > > dependencies > > > > > > > > > notice: Finished catalog run in 0.38 seconds > > > > > > > > > > > When I tried running the shell script manually using the > > > following > > > > > > > command > > > > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh);echo $?'' > > > > > > > > > > > , it worked fine printing 0 at the end. Any help what is > wrong > > > with > > > > > > > exec > > > > > > > > > resource recipe? > > > > > > > > > > > Thanks in advance for your time. > > > > > > > > > > > Regards, > > > > > > > > > > > A. > > > > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < > > > pmb...@gmail.com (mailto:pmb...@gmail.com) > > > > > > > > wrote: > > > > > > > > > > > > It sounds like you haven''t set up the puppet fileserver > yet. > > > Choose a > > > > > > > > > > directory that will hold files you want to copy to > clients. I > > > use > > > > > > > > > > /opt/files, so that''s what is in my example. Create > > > fileserver.conf in > > > > > > > the > > > > > > > > > > same directory as puppet.conf and add these lines: > > > > > > > > > > > > [files] > > > > > > > > > > path /opt/files > > > > > > > > > > allow *.client.domain > > > > > > > > > > > > Put your shell file in the path you specified. Now you > just > > > need to > > > > > > > set up > > > > > > > > > > a file and exec resource. Note the source item in the > file > > > resource > > > > > > > and the > > > > > > > > > > require item in exec. > > > > > > > > > > > > file { ''/etc/shell_file'': > > > > > > > > > > ensure => present, > > > > > > > > > > owner => ''root'', > > > > > > > > > > group => ''root'', > > > > > > > > > > mode => ''0755'', > > > > > > > > > > source => ''puppet://puppet/files/shell_file'', > > > > > > > > > > } > > > > > > > > > > > > exec { ''/etc/shell_file'': require => > File[''/etc/shell_file''] > > > } > > > > > > > > > > > > -- > > > > > > > > > > Peter M. Bukowinski > > > > > > > > > > Systems Engineer > > > > > > > > > > Janelia Farm Research Campus, HHMI > > > > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > > > > > > > > > > > > Hi all, I am new to puppet. I need a sample recipe to > > > write/copy a > > > > > > > > > > > shell file on puppet client. The shell file exists on > > > puppet server. > > > > > > > > > > > Once the file is written, I also want to execute it. I > have > > > tried > > > > > > > > > > > using file resource with ensure command to copy at /etc > but > > > > > > > permission > > > > > > > > > > > was denied and moreover with a different directory path > > > (\tmp) it > > > > > > > just > > > > > > > > > > > created an empty file. Can anyone please help? > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > A. > > > > > > > > > > > > > -- > > > > > > > > > > > You received this message because you are subscribed to > the > > > Google > > > > > > > > > > Groups "Puppet Users" group. > > > > > > > > > > > To post to this group, send email to > > > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com) > > > > > > > (mailto: > > > > > > > > > > puppet-users@googlegroups.com (mailto: > > > puppet-users@googlegroups.com)). > > > > > > > > > > > To unsubscribe from this group, send email to > > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > > puppet-users%2Bunsubscribe@googlegroups.com) (mailto: > > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > > puppet-users%2Bunsubscribe@googlegroups.com)). > > > > > > > > > > > For more options, visit this group at > > > > > > > > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > > > > > > > > -- > > > > > > > > > > You received this message because you are subscribed to > the > > > Google > > > > > > > Groups > > > > > > > > > > "Puppet Users" group. > > > > > > > > > > To post to this group, send email to > > > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). > > > > > > > > > > To unsubscribe from this group, send email to > > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > > puppet-users%2Bunsubscribe@googlegroups.com). > > > > > > > > > > For more options, visit this group at > > > > > > > > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > > > > > -- > > > > > > > You received this message because you are subscribed to the > Google > > > Groups > > > > > > > "Puppet Users" group. > > > > > > > To post to this group, send email to > puppet-users@googlegroups.com(mailto: > > > puppet-users@googlegroups.com). > > > > > > > To unsubscribe from this group, send email to > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > > puppet-users%2Bunsubscribe@googlegroups.com). > > > > > > > For more options, visit this group at > > > > > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > > > -- > > > > > You received this message because you are subscribed to the Google > > > Groups "Puppet Users" group. > > > > > To post to this group, send email to > puppet-users@googlegroups.com(mailto: > > > puppet-users@googlegroups.com). > > > > > To unsubscribe from this group, send email to > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > > puppet-users%2Bunsubscribe@googlegroups.com). > > > > > For more options, visit this group at > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > > -- > > > > You received this message because you are subscribed to the Google > > > Groups "Puppet Users" group. > > > > To post to this group, send email to puppet-users@googlegroups.com > (mailto: > > > puppet-users@googlegroups.com). > > > > To unsubscribe from this group, send email to > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > > puppet-users+unsubscribe@googlegroups.com). > > > > For more options, visit this group at > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Puppet Users" group. > > > To post to this group, send email to puppet-users@googlegroups.com. > > > To unsubscribe from this group, send email to > > > puppet-users+unsubscribe@googlegroups.com. > > > For more options, visit this group at > > >http://groups.google.com/group/puppet-users?hl=en. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 15:31 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
Hi Luke, I replaced my shell script with the one you wrote. Same old error message appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh returned 1 instead of o at /etc/puppet/manifests/site.pp'' . Your script didn''t generate any log at client machine. Now I am sure about one thing that there is no issue with the shell script itself. The exec command is having hiccup even before executing the shell. I even tried command paremeter in exec but no use. Do you know anyother way to execute bash shell in puppet? Thanks much, Annie On Fri, Jun 17, 2011 at 4:30 PM, Annie Rana <annierana@gmail.com> wrote:> Hi Luke, > > I replaced my shell script with the one you wrote. Same old error message > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh returned 1 > instead of o at /etc/puppet/manifests/site.pp''. Your script didn''t generated > any log at client machine. Now I am sure about one thing that there is no > issue with the shell script itself. The exec command is having hiccup even > before executing the shell. I even tried command paremeter in exec but no > use. Do you know anyother way to execute bash shell in puppet? > > Thanks much, > > Annie > > On Fri, Jun 17, 2011 at 4:06 PM, Luke Bigum <Luke.Bigum@lmax.com> wrote: > >> I''m out of ideas and I''d resort to hacking the script a bit to get >> some debugging output. Try just this in QoS.sh to try identify what''s >> failing: >> >> export LAN=eth1 >> export WAN=eth0 >> CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match >> ip tos 0x880xff classid 1:12" >> OUT=$($CMD) > /tmp/QoS.out 2>&1 >> RET=$? >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >> CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport >> 2345 -j TOS --set-tos 0x28" >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 >> RET=$? >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >> CMD="iptables-save" >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 >> RET=$? >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >> >> >> Or something like that. >> >> On Jun 17, 4:01 pm, Annie Rana <annier...@gmail.com> wrote: >> > Thanks again Peter but sorry it didn''t work out either. >> > >> > On Fri, Jun 17, 2011 at 3:52 PM, Peter Bukowinski <pmb...@gmail.com> >> wrote: >> > > In your QoS.sh file, make sure to use explicit paths to executables, >> e.g: >> > >> > > use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' >> > >> > > -- >> > > Peter M. Bukowinski >> > > Systems Engineer >> > > Janelia Farm Research Campus, HHMI >> > >> > > On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote: >> > >> > > > Hi Luke, >> > > > What''s your shell script expected to >> > > > do? >> > > > The shell script would generate Iptables rules >> > >> > > > How do you know it didn''t work? >> > > > I can check using ipatbles -L or iptables -t mangle -L commands >> > >> > > > If you run it by hand in a root shell, does it work then? >> > > > Yes >> > >> > > > If so, >> > > > there might be an environment problem when running from Puppet, like >> > > > $PATH or something. Try set the parameter "logoutput => true" in the >> > > > exec resource. >> > > > I did but no affect. >> > >> > > > Thanks again, much appreciated your help and time. >> > > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum <Luke.Bi...@lmax.com >> (mailto: >> > > Luke.Bi...@lmax.com)> wrote: >> > > > > How do you know it didn''t work? What''s your shell script expected >> to >> > > > > do? If you run it by hand in a root shell, does it work then? If >> so, >> > > > > there might be an environment problem when running from Puppet, >> like >> > > > > $PATH or something. Try set the parameter "logoutput => true" in >> the >> > > > > exec resource. >> > >> > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com (mailto: >> > > annier...@gmail.com)> wrote: >> > > > > > Thanks but it couldn''t work though i got the message that shell >> > > script is >> > > > > > successfully executed. >> > >> > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum < >> Luke.Bi...@lmax.com(mailto: >> > > Luke.Bi...@lmax.com)> wrote: >> > > > > > > Annie, >> > >> > > > > > >http://docs.puppetlabs.com/references/stable/type.html#exec >> > >> > > > > > > By default the expected return code is probably zero, your >> script >> > > is >> > > > > > > returning 1. Whether this is correct or not I don''t know, but >> you >> > > can >> > > > > > > tell puppet to expect a different return code: >> > >> > > > > > > exec { ''/etc/shell_file'': >> > > > > > > require => File[''/etc/shell_file''], >> > > > > > > returns => 1, >> > > > > > > } >> > >> > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com (mailto: >> > > annier...@gmail.com)> wrote: >> > > > > > > > I apologize for posting wrong log messages, here is the >> correct >> > > log: >> > >> > > > > > > > notice: Starting catalog run >> > > > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: >> created >> > > > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: >> change >> > > from notrun to 0 failed: >> > > > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of 0 at >> > > > > > > /etc/puppet/manifests/site.pp:10 >> > > > > > > > notice: Finished catalog run in 0.46 seconds >> > >> > > > > > > > Any help please? >> > >> > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana < >> annier...@gmail.com(mailto: >> > > annier...@gmail.com)> wrote: >> > > > > > > > > Hi Peter, thanks for your reply. I managed to copy the >> shell >> > > file >> > > > > > > puppet >> > > > > > > > > client using the file resource recipe you specified but >> exec is >> > > > > > > throwing an >> > > > > > > > > error, which is as follows: >> > >> > > > > > > > > info: No classes to store >> > > > > > > > > info: Caching catalog at >> /var/lib/puppet/state/localconfig.yaml >> > > > > > > > > notice: Starting catalog run >> > > > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: >> change >> > > from absent to file failed: >> > > > > > > > > Could not set file on ensure: No such file or directory - >> > > > > > > > > /tmp/QoS/QoS.sh.puppettmp at >> /etc/puppet/manifests/site.pp:7 >> > > > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: >> Dependency >> > > file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 >> > > > > > > > > failures >> > > > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: >> Skipping >> > > because of failed >> > > > > > > dependencies >> > > > > > > > > notice: Finished catalog run in 0.38 seconds >> > >> > > > > > > > > When I tried running the shell script manually using the >> > > following >> > > > > > > command >> > >> > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh);echo $?'' >> > >> > > > > > > > > , it worked fine printing 0 at the end. Any help what is >> wrong >> > > with >> > > > > > > exec >> > > > > > > > > resource recipe? >> > >> > > > > > > > > Thanks in advance for your time. >> > >> > > > > > > > > Regards, >> > >> > > > > > > > > A. >> > >> > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < >> > > pmb...@gmail.com (mailto:pmb...@gmail.com) >> > > > > > > > wrote: >> > >> > > > > > > > > > It sounds like you haven''t set up the puppet fileserver >> yet. >> > > Choose a >> > > > > > > > > > directory that will hold files you want to copy to >> clients. I >> > > use >> > > > > > > > > > /opt/files, so that''s what is in my example. Create >> > > fileserver.conf in >> > > > > > > the >> > > > > > > > > > same directory as puppet.conf and add these lines: >> > >> > > > > > > > > > [files] >> > > > > > > > > > path /opt/files >> > > > > > > > > > allow *.client.domain >> > >> > > > > > > > > > Put your shell file in the path you specified. Now you >> just >> > > need to >> > > > > > > set up >> > > > > > > > > > a file and exec resource. Note the source item in the >> file >> > > resource >> > > > > > > and the >> > > > > > > > > > require item in exec. >> > >> > > > > > > > > > file { ''/etc/shell_file'': >> > > > > > > > > > ensure => present, >> > > > > > > > > > owner => ''root'', >> > > > > > > > > > group => ''root'', >> > > > > > > > > > mode => ''0755'', >> > > > > > > > > > source => ''puppet://puppet/files/shell_file'', >> > > > > > > > > > } >> > >> > > > > > > > > > exec { ''/etc/shell_file'': require => >> File[''/etc/shell_file''] >> > > } >> > >> > > > > > > > > > -- >> > > > > > > > > > Peter M. Bukowinski >> > > > > > > > > > Systems Engineer >> > > > > > > > > > Janelia Farm Research Campus, HHMI >> > >> > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: >> > >> > > > > > > > > > > Hi all, I am new to puppet. I need a sample recipe to >> > > write/copy a >> > > > > > > > > > > shell file on puppet client. The shell file exists on >> > > puppet server. >> > > > > > > > > > > Once the file is written, I also want to execute it. I >> have >> > > tried >> > > > > > > > > > > using file resource with ensure command to copy at >> /etc but >> > > > > > > permission >> > > > > > > > > > > was denied and moreover with a different directory >> path >> > > (\tmp) it >> > > > > > > just >> > > > > > > > > > > created an empty file. Can anyone please help? >> > >> > > > > > > > > > > Regards, >> > >> > > > > > > > > > > A. >> > >> > > > > > > > > > > -- >> > > > > > > > > > > You received this message because you are subscribed >> to the >> > > Google >> > > > > > > > > > Groups "Puppet Users" group. >> > > > > > > > > > > To post to this group, send email to >> > > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com) >> > > > > > > (mailto: >> > > > > > > > > > puppet-users@googlegroups.com (mailto: >> > > puppet-users@googlegroups.com)). >> > > > > > > > > > > To unsubscribe from this group, send email to >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: >> > > puppet-users%2Bunsubscribe@googlegroups.com) (mailto: >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: >> > > puppet-users%2Bunsubscribe@googlegroups.com)). >> > > > > > > > > > > For more options, visit this group at >> > > > > > > > > >http://groups.google.com/group/puppet-users?hl=en. >> > >> > > > > > > > > > -- >> > > > > > > > > > You received this message because you are subscribed to >> the >> > > Google >> > > > > > > Groups >> > > > > > > > > > "Puppet Users" group. >> > > > > > > > > > To post to this group, send email to >> > > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com). >> > > > > > > > > > To unsubscribe from this group, send email to >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: >> > > puppet-users%2Bunsubscribe@googlegroups.com). >> > > > > > > > > > For more options, visit this group at >> > > > > > > > > >http://groups.google.com/group/puppet-users?hl=en. >> > >> > > > > > > -- >> > > > > > > You received this message because you are subscribed to the >> Google >> > > Groups >> > > > > > > "Puppet Users" group. >> > > > > > > To post to this group, send email to >> puppet-users@googlegroups.com(mailto: >> > > puppet-users@googlegroups.com). >> > > > > > > To unsubscribe from this group, send email to >> > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: >> > > puppet-users%2Bunsubscribe@googlegroups.com). >> > > > > > > For more options, visit this group at >> > > > > > >http://groups.google.com/group/puppet-users?hl=en. >> > >> > > > > -- >> > > > > You received this message because you are subscribed to the Google >> > > Groups "Puppet Users" group. >> > > > > To post to this group, send email to >> puppet-users@googlegroups.com(mailto: >> > > puppet-users@googlegroups.com). >> > > > > To unsubscribe from this group, send email to >> > > puppet-users+unsubscribe@googlegroups.com (mailto: >> > > puppet-users%2Bunsubscribe@googlegroups.com). >> > > > > For more options, visit this group at >> > >http://groups.google.com/group/puppet-users?hl=en. >> > >> > > > -- >> > > > You received this message because you are subscribed to the Google >> > > Groups "Puppet Users" group. >> > > > To post to this group, send email to puppet-users@googlegroups.com >> (mailto: >> > > puppet-users@googlegroups.com). >> > > > To unsubscribe from this group, send email to >> > > puppet-users+unsubscribe@googlegroups.com (mailto: >> > > puppet-users+unsubscribe@googlegroups.com). >> > > > For more options, visit this group at >> > >http://groups.google.com/group/puppet-users?hl=en. >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> Groups >> > > "Puppet Users" group. >> > > To post to this group, send email to puppet-users@googlegroups.com. >> > > To unsubscribe from this group, send email to >> > > puppet-users+unsubscribe@googlegroups.com. >> > > For more options, visit this group at >> > >http://groups.google.com/group/puppet-users?hl=en. >> > >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To post to this group, send email to puppet-users@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-users+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> >> >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Luke Bigum
2011-Jun-17 15:50 UTC
[Puppet Users] Re: Puppet recipe to copy and execute a shell file
Wouldn''t have worked anyway, change "print" to "echo" and I forgot #!/ bin/bash... That''s what I get for writing code from memory ;) That''s strange, I just put this in my Puppet server: node ''puppetmaster'' { file { ''/etc/shell_file'': ensure => present, owner => ''root'', group => ''root'', mode => ''0755'', source => ''puppet:///modules/puppet/shell_file'', } exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } } [root@co1puppet01 live]# cat ../../modules/live/puppet/files/ shell_file #!/bin/bash export LAN=eth1 export WAN=eth0 CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match ip tos 0x880xff classid 1:12" OUT=$($CMD) RET=$? echo "Command ''$CMD'' returned $RET" 2>&1 > /tmp/QoS.out echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport 2345 -j TOS --set-tos 0x28" OUT=$($CMD) RET=$? echo "Command ''$CMD'' returned $RET" 2>&1 >> /tmp/QoS.out echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out CMD="iptables-save" OUT=$($CMD) RET=$? echo "Command ''$CMD'' returned $RET" 2>&1 >> /tmp/QoS.out echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out [root@puppetmaster live]# puppetd --test info: Caching catalog for puppetmaster info: Applying configuration version ''1308324915'' notice: /Stage[main]//Node[puppetmaster]/Exec[/etc/shell_file]/ returns: executed successfully notice: Finished catalog run in 1.04 seconds [root@puppetmaster]# cat /tmp/QoS.out Command ''tc filter add dev eth0 parent 1:0 prio 4 protocol ip u32 match ip tos 0x880xff classid 1:12'' returned 1 Command ''tc filter add dev eth0 parent 1:0 prio 4 protocol ip u32 match ip tos 0x880xff classid 1:12'' output '''' Command ''iptables -t mangle -A FORWARD -i eth1 -o eth0 -p udp --sport 2345 -j TOS --set-tos 0x28'' returned 2 Command ''iptables -t mangle -A FORWARD -i eth1 -o eth0 -p udp --sport 2345 -j TOS --set-tos 0x28'' output '''' Command ''iptables-save'' returned 0 Command ''iptables-save'' output ''# Generated by iptables-save v1.3.5 on Fri Jun 17 15:48:48 2011 *mangle :PREROUTING ACCEPT [3642:790381] :INPUT ACCEPT [2591:636935] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [2551:866979] :POSTROUTING ACCEPT [2551:866979] COMMIT # Completed on Fri Jun 17 15:48:48 2011 # Generated by iptables-save v1.3.5 on Fri Jun 17 15:48:48 2011 *filter :INPUT ACCEPT [2637:639987] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [2588:875945] COMMIT # Completed on Fri Jun 17 15:48:48 2011'' I''m running out of ideas. You don''t have noexec on /tmp do you? No, you said you could run it as root... Anyone else? On Jun 17, 4:31 pm, Annie Rana <annier...@gmail.com> wrote:> Hi Luke, > > I replaced my shell script with the one you wrote. Same old error message > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh returned 1 > instead of o at /etc/puppet/manifests/site.pp'' > . Your script didn''t generate any log at client machine. Now I am sure about > one thing that there is no issue with the shell script itself. The exec > command is having hiccup even before executing the shell. I even tried > command paremeter in exec but no use. Do you know anyother way to execute > bash shell in puppet? > > Thanks much, > > Annie > > On Fri, Jun 17, 2011 at 4:30 PM, Annie Rana <annier...@gmail.com> wrote: > > Hi Luke, > > > I replaced my shell script with the one you wrote. Same old error message > > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh returned 1 > > instead of o at /etc/puppet/manifests/site.pp''. Your script didn''t generated > > any log at client machine. Now I am sure about one thing that there is no > > issue with the shell script itself. The exec command is having hiccup even > > before executing the shell. I even tried command paremeter in exec but no > > use. Do you know anyother way to execute bash shell in puppet? > > > Thanks much, > > > Annie > > > On Fri, Jun 17, 2011 at 4:06 PM, Luke Bigum <Luke.Bi...@lmax.com> wrote: > > >> I''m out of ideas and I''d resort to hacking the script a bit to get > >> some debugging output. Try just this in QoS.sh to try identify what''s > >> failing: > > >> export LAN=eth1 > >> export WAN=eth0 > >> CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match > >> ip tos 0x880xff classid 1:12" > >> OUT=$($CMD) > /tmp/QoS.out 2>&1 > >> RET=$? > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > >> CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport > >> 2345 -j TOS --set-tos 0x28" > >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 > >> RET=$? > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > >> CMD="iptables-save" > >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 > >> RET=$? > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > > >> Or something like that. > > >> On Jun 17, 4:01 pm, Annie Rana <annier...@gmail.com> wrote: > >> > Thanks again Peter but sorry it didn''t work out either. > > >> > On Fri, Jun 17, 2011 at 3:52 PM, Peter Bukowinski <pmb...@gmail.com> > >> wrote: > >> > > In your QoS.sh file, make sure to use explicit paths to executables, > >> e.g: > > >> > > use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' > > >> > > -- > >> > > Peter M. Bukowinski > >> > > Systems Engineer > >> > > Janelia Farm Research Campus, HHMI > > >> > > On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote: > > >> > > > Hi Luke, > >> > > > What''s your shell script expected to > >> > > > do? > >> > > > The shell script would generate Iptables rules > > >> > > > How do you know it didn''t work? > >> > > > I can check using ipatbles -L or iptables -t mangle -L commands > > >> > > > If you run it by hand in a root shell, does it work then? > >> > > > Yes > > >> > > > If so, > >> > > > there might be an environment problem when running from Puppet, like > >> > > > $PATH or something. Try set the parameter "logoutput => true" in the > >> > > > exec resource. > >> > > > I did but no affect. > > >> > > > Thanks again, much appreciated your help and time. > >> > > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum <Luke.Bi...@lmax.com > >> (mailto: > >> > > Luke.Bi...@lmax.com)> wrote: > >> > > > > How do you know it didn''t work? What''s your shell script expected > >> to > >> > > > > do? If you run it by hand in a root shell, does it work then? If > >> so, > >> > > > > there might be an environment problem when running from Puppet, > >> like > >> > > > > $PATH or something. Try set the parameter "logoutput => true" in > >> the > >> > > > > exec resource. > > >> > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com (mailto: > >> > > annier...@gmail.com)> wrote: > >> > > > > > Thanks but it couldn''t work though i got the message that shell > >> > > script is > >> > > > > > successfully executed. > > >> > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum < > >> Luke.Bi...@lmax.com(mailto: > >> > > Luke.Bi...@lmax.com)> wrote: > >> > > > > > > Annie, > > >> > > > > > >http://docs.puppetlabs.com/references/stable/type.html#exec > > >> > > > > > > By default the expected return code is probably zero, your > >> script > >> > > is > >> > > > > > > returning 1. Whether this is correct or not I don''t know, but > >> you > >> > > can > >> > > > > > > tell puppet to expect a different return code: > > >> > > > > > > exec { ''/etc/shell_file'': > >> > > > > > > require => File[''/etc/shell_file''], > >> > > > > > > returns => 1, > >> > > > > > > } > > >> > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com (mailto: > >> > > annier...@gmail.com)> wrote: > >> > > > > > > > I apologize for posting wrong log messages, here is the > >> correct > >> > > log: > > >> > > > > > > > notice: Starting catalog run > >> > > > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: > >> created > >> > > > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: > >> change > >> > > from notrun to 0 failed: > >> > > > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of 0 at > >> > > > > > > /etc/puppet/manifests/site.pp:10 > >> > > > > > > > notice: Finished catalog run in 0.46 seconds > > >> > > > > > > > Any help please? > > >> > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana < > >> annier...@gmail.com(mailto: > >> > > annier...@gmail.com)> wrote: > >> > > > > > > > > Hi Peter, thanks for your reply. I managed to copy the > >> shell > >> > > file > >> > > > > > > puppet > >> > > > > > > > > client using the file resource recipe you specified but > >> exec is > >> > > > > > > throwing an > >> > > > > > > > > error, which is as follows: > > >> > > > > > > > > info: No classes to store > >> > > > > > > > > info: Caching catalog at > >> /var/lib/puppet/state/localconfig.yaml > >> > > > > > > > > notice: Starting catalog run > >> > > > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: > >> change > >> > > from absent to file failed: > >> > > > > > > > > Could not set file on ensure: No such file or directory - > >> > > > > > > > > /tmp/QoS/QoS.sh.puppettmp at > >> /etc/puppet/manifests/site.pp:7 > >> > > > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: > >> Dependency > >> > > file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 > >> > > > > > > > > failures > >> > > > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: > >> Skipping > >> > > because of failed > >> > > > > > > dependencies > >> > > > > > > > > notice: Finished catalog run in 0.38 seconds > > >> > > > > > > > > When I tried running the shell script manually using the > >> > > following > >> > > > > > > command > > >> > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh);echo$?'' > > >> > > > > > > > > , it worked fine printing 0 at the end. Any help what is > >> wrong > >> > > with > >> > > > > > > exec > >> > > > > > > > > resource recipe? > > >> > > > > > > > > Thanks in advance for your time. > > >> > > > > > > > > Regards, > > >> > > > > > > > > A. > > >> > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < > >> > > pmb...@gmail.com (mailto:pmb...@gmail.com) > >> > > > > > > > wrote: > > >> > > > > > > > > > It sounds like you haven''t set up the puppet fileserver > >> yet. > >> > > Choose a > >> > > > > > > > > > directory that will hold files you want to copy to > >> clients. I > >> > > use > >> > > > > > > > > > /opt/files, so that''s what is in my example. Create > >> > > fileserver.conf in > >> > > > > > > the > >> > > > > > > > > > same directory as puppet.conf and add these lines: > > >> > > > > > > > > > [files] > >> > > > > > > > > > path /opt/files > >> > > > > > > > > > allow *.client.domain > > >> > > > > > > > > > Put your shell file in the path you specified. Now you > >> just > >> > > need to > >> > > > > > > set up > >> > > > > > > > > > a file and exec resource. Note the source item in the > >> file > >> > > resource > >> > > > > > > and the > >> > > > > > > > > > require item in exec. > > >> > > > > > > > > > file { ''/etc/shell_file'': > >> > > > > > > > > > ensure => present, > >> > > > > > > > > > owner => ''root'', > >> > > > > > > > > > group => ''root'', > >> > > > > > > > > > mode => ''0755'', > >> > > > > > > > > > source => ''puppet://puppet/files/shell_file'', > >> > > > > > > > > > } > > >> > > > > > > > > > exec { ''/etc/shell_file'': require => > >> File[''/etc/shell_file''] > >> > > } > > >> > > > > > > > > > -- > >> > > > > > > > > > Peter M. Bukowinski > >> > > > > > > > > > Systems Engineer > >> > > > > > > > > > Janelia Farm Research Campus, HHMI > > >> > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana wrote: > > >> > > > > > > > > > > Hi all, I am new to puppet. I need a sample recipe to > >> > > write/copy a > >> > > > > > > > > > > shell file on puppet client. The shell file exists on > >> > > puppet server. > >> > > > > > > > > > > Once the file is written, I also want to execute it. I > >> have > >> > > tried > >> > > > > > > > > > > using file resource with ensure command to copy at > >> /etc but > >> > > > > > > permission > >> > > > > > > > > > > was denied and moreover with a different directory > >> path > >> > > (\tmp) it > >> > > > > > > just > >> > > > > > > > > > > created an empty file. Can anyone please help? > > >> > > > > > > > > > > Regards, > > >> > > > > > > > > > > A. > > >> > > > > > > > > > > -- > >> > > > > > > > > > > You received this message because you are subscribed > >> to the > >> > > Google > >> > > > > > > > > > Groups "Puppet Users" group. > >> > > > > > > > > > > To post to this group, send email to > >> > > puppet-users@googlegroups.com (mailto:puppet-users@googlegroups.com) > >> > > > > > > (mailto: > >> > > > > > > > > > puppet-users@googlegroups.com (mailto: > >> > > puppet-users@googlegroups.com)). > >> > > > > > > > > > > To unsubscribe from this group, send email to > >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > >> > > puppet-users%2Bunsubscribe@googlegroups.com) (mailto: > >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > >> > > puppet-users%2Bunsubscribe@googlegroups.com)). > > ... > > read more »-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 17:43 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
Hi, Thanks much for help. Some how I managed to execute the original shell script using command in exec "command=>''sh /tmp/QoS/QoS.sh''" and I used path parameter as well "path=>''/sbin:/sbin/ipatbles:/bin:/usr/bin''" but I have to run file and exec recipes separately one after another otherwise exec is executed first if both are placed in one recipe and causing file not found error. Is there any way to define the sequence of execution? Regards, Annie On Fri, Jun 17, 2011 at 4:50 PM, Luke Bigum <Luke.Bigum@lmax.com> wrote:> Wouldn''t have worked anyway, change "print" to "echo" and I forgot #!/ > bin/bash... That''s what I get for writing code from memory ;) > > That''s strange, I just put this in my Puppet server: > > node ''puppetmaster'' { > file { ''/etc/shell_file'': > ensure => present, > owner => ''root'', > group => ''root'', > mode => ''0755'', > source => ''puppet:///modules/puppet/shell_file'', > } > > exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } > } > > [root@co1puppet01 live]# cat ../../modules/live/puppet/files/ > shell_file > #!/bin/bash > export LAN=eth1 > export WAN=eth0 > > CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match > ip tos 0x880xff classid 1:12" > OUT=$($CMD) > RET=$? > echo "Command ''$CMD'' returned $RET" 2>&1 > /tmp/QoS.out > echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out > > CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport > 2345 -j TOS --set-tos 0x28" > OUT=$($CMD) > RET=$? > echo "Command ''$CMD'' returned $RET" 2>&1 >> /tmp/QoS.out > echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out > > CMD="iptables-save" > OUT=$($CMD) > RET=$? > echo "Command ''$CMD'' returned $RET" 2>&1 >> /tmp/QoS.out > echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out > > [root@puppetmaster live]# puppetd --test > info: Caching catalog for puppetmaster > info: Applying configuration version ''1308324915'' > notice: /Stage[main]//Node[puppetmaster]/Exec[/etc/shell_file]/ > returns: executed successfully > notice: Finished catalog run in 1.04 seconds > > [root@puppetmaster]# cat /tmp/QoS.out > Command ''tc filter add dev eth0 parent 1:0 prio 4 protocol ip u32 > match ip tos 0x880xff classid 1:12'' returned 1 > Command ''tc filter add dev eth0 parent 1:0 prio 4 protocol ip u32 > match ip tos 0x880xff classid 1:12'' output '''' > Command ''iptables -t mangle -A FORWARD -i eth1 -o eth0 -p udp --sport > 2345 -j TOS --set-tos 0x28'' returned 2 > Command ''iptables -t mangle -A FORWARD -i eth1 -o eth0 -p udp --sport > 2345 -j TOS --set-tos 0x28'' output '''' > Command ''iptables-save'' returned 0 > Command ''iptables-save'' output ''# Generated by iptables-save v1.3.5 on > Fri Jun 17 15:48:48 2011 > *mangle > :PREROUTING ACCEPT [3642:790381] > :INPUT ACCEPT [2591:636935] > :FORWARD ACCEPT [0:0] > :OUTPUT ACCEPT [2551:866979] > :POSTROUTING ACCEPT [2551:866979] > COMMIT > # Completed on Fri Jun 17 15:48:48 2011 > # Generated by iptables-save v1.3.5 on Fri Jun 17 15:48:48 2011 > *filter > :INPUT ACCEPT [2637:639987] > :FORWARD ACCEPT [0:0] > :OUTPUT ACCEPT [2588:875945] > COMMIT > # Completed on Fri Jun 17 15:48:48 2011'' > > I''m running out of ideas. You don''t have noexec on /tmp do you? No, > you said you could run it as root... Anyone else? > > On Jun 17, 4:31 pm, Annie Rana <annier...@gmail.com> wrote: > > Hi Luke, > > > > I replaced my shell script with the one you wrote. Same old error message > > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh returned > 1 > > instead of o at /etc/puppet/manifests/site.pp'' > > . Your script didn''t generate any log at client machine. Now I am sure > about > > one thing that there is no issue with the shell script itself. The exec > > command is having hiccup even before executing the shell. I even tried > > command paremeter in exec but no use. Do you know anyother way to execute > > bash shell in puppet? > > > > Thanks much, > > > > Annie > > > > On Fri, Jun 17, 2011 at 4:30 PM, Annie Rana <annier...@gmail.com> wrote: > > > Hi Luke, > > > > > I replaced my shell script with the one you wrote. Same old error > message > > > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh > returned 1 > > > instead of o at /etc/puppet/manifests/site.pp''. Your script didn''t > generated > > > any log at client machine. Now I am sure about one thing that there is > no > > > issue with the shell script itself. The exec command is having hiccup > even > > > before executing the shell. I even tried command paremeter in exec but > no > > > use. Do you know anyother way to execute bash shell in puppet? > > > > > Thanks much, > > > > > Annie > > > > > On Fri, Jun 17, 2011 at 4:06 PM, Luke Bigum <Luke.Bi...@lmax.com> > wrote: > > > > >> I''m out of ideas and I''d resort to hacking the script a bit to get > > >> some debugging output. Try just this in QoS.sh to try identify what''s > > >> failing: > > > > >> export LAN=eth1 > > >> export WAN=eth0 > > >> CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match > > >> ip tos 0x880xff classid 1:12" > > >> OUT=$($CMD) > /tmp/QoS.out 2>&1 > > >> RET=$? > > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > > >> CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport > > >> 2345 -j TOS --set-tos 0x28" > > >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 > > >> RET=$? > > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > > >> CMD="iptables-save" > > >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 > > >> RET=$? > > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 > > > > >> Or something like that. > > > > >> On Jun 17, 4:01 pm, Annie Rana <annier...@gmail.com> wrote: > > >> > Thanks again Peter but sorry it didn''t work out either. > > > > >> > On Fri, Jun 17, 2011 at 3:52 PM, Peter Bukowinski <pmb...@gmail.com > > > > >> wrote: > > >> > > In your QoS.sh file, make sure to use explicit paths to > executables, > > >> e.g: > > > > >> > > use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' > > > > >> > > -- > > >> > > Peter M. Bukowinski > > >> > > Systems Engineer > > >> > > Janelia Farm Research Campus, HHMI > > > > >> > > On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote: > > > > >> > > > Hi Luke, > > >> > > > What''s your shell script expected to > > >> > > > do? > > >> > > > The shell script would generate Iptables rules > > > > >> > > > How do you know it didn''t work? > > >> > > > I can check using ipatbles -L or iptables -t mangle -L commands > > > > >> > > > If you run it by hand in a root shell, does it work then? > > >> > > > Yes > > > > >> > > > If so, > > >> > > > there might be an environment problem when running from Puppet, > like > > >> > > > $PATH or something. Try set the parameter "logoutput => true" in > the > > >> > > > exec resource. > > >> > > > I did but no affect. > > > > >> > > > Thanks again, much appreciated your help and time. > > >> > > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum < > Luke.Bi...@lmax.com > > >> (mailto: > > >> > > Luke.Bi...@lmax.com)> wrote: > > >> > > > > How do you know it didn''t work? What''s your shell script > expected > > >> to > > >> > > > > do? If you run it by hand in a root shell, does it work then? > If > > >> so, > > >> > > > > there might be an environment problem when running from > Puppet, > > >> like > > >> > > > > $PATH or something. Try set the parameter "logoutput => true" > in > > >> the > > >> > > > > exec resource. > > > > >> > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com (mailto: > > >> > > annier...@gmail.com)> wrote: > > >> > > > > > Thanks but it couldn''t work though i got the message that > shell > > >> > > script is > > >> > > > > > successfully executed. > > > > >> > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum < > > >> Luke.Bi...@lmax.com(mailto: > > >> > > Luke.Bi...@lmax.com)> wrote: > > >> > > > > > > Annie, > > > > >> > > > > > > > http://docs.puppetlabs.com/references/stable/type.html#exec > > > > >> > > > > > > By default the expected return code is probably zero, your > > >> script > > >> > > is > > >> > > > > > > returning 1. Whether this is correct or not I don''t know, > but > > >> you > > >> > > can > > >> > > > > > > tell puppet to expect a different return code: > > > > >> > > > > > > exec { ''/etc/shell_file'': > > >> > > > > > > require => File[''/etc/shell_file''], > > >> > > > > > > returns => 1, > > >> > > > > > > } > > > > >> > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com(mailto: > > >> > > annier...@gmail.com)> wrote: > > >> > > > > > > > I apologize for posting wrong log messages, here is the > > >> correct > > >> > > log: > > > > >> > > > > > > > notice: Starting catalog run > > >> > > > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: > > >> created > > >> > > > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: > > >> change > > >> > > from notrun to 0 failed: > > >> > > > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of 0 > at > > >> > > > > > > /etc/puppet/manifests/site.pp:10 > > >> > > > > > > > notice: Finished catalog run in 0.46 seconds > > > > >> > > > > > > > Any help please? > > > > >> > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana < > > >> annier...@gmail.com(mailto: > > >> > > annier...@gmail.com)> wrote: > > >> > > > > > > > > Hi Peter, thanks for your reply. I managed to copy the > > >> shell > > >> > > file > > >> > > > > > > puppet > > >> > > > > > > > > client using the file resource recipe you specified > but > > >> exec is > > >> > > > > > > throwing an > > >> > > > > > > > > error, which is as follows: > > > > >> > > > > > > > > info: No classes to store > > >> > > > > > > > > info: Caching catalog at > > >> /var/lib/puppet/state/localconfig.yaml > > >> > > > > > > > > notice: Starting catalog run > > >> > > > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: > > >> change > > >> > > from absent to file failed: > > >> > > > > > > > > Could not set file on ensure: No such file or > directory - > > >> > > > > > > > > /tmp/QoS/QoS.sh.puppettmp at > > >> /etc/puppet/manifests/site.pp:7 > > >> > > > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: > > >> Dependency > > >> > > file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 > > >> > > > > > > > > failures > > >> > > > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: > > >> Skipping > > >> > > because of failed > > >> > > > > > > dependencies > > >> > > > > > > > > notice: Finished catalog run in 0.38 seconds > > > > >> > > > > > > > > When I tried running the shell script manually using > the > > >> > > following > > >> > > > > > > command > > > > >> > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh);echo$?'' > > > > >> > > > > > > > > , it worked fine printing 0 at the end. Any help what > is > > >> wrong > > >> > > with > > >> > > > > > > exec > > >> > > > > > > > > resource recipe? > > > > >> > > > > > > > > Thanks in advance for your time. > > > > >> > > > > > > > > Regards, > > > > >> > > > > > > > > A. > > > > >> > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < > > >> > > pmb...@gmail.com (mailto:pmb...@gmail.com) > > >> > > > > > > > wrote: > > > > >> > > > > > > > > > It sounds like you haven''t set up the puppet > fileserver > > >> yet. > > >> > > Choose a > > >> > > > > > > > > > directory that will hold files you want to copy to > > >> clients. I > > >> > > use > > >> > > > > > > > > > /opt/files, so that''s what is in my example. Create > > >> > > fileserver.conf in > > >> > > > > > > the > > >> > > > > > > > > > same directory as puppet.conf and add these lines: > > > > >> > > > > > > > > > [files] > > >> > > > > > > > > > path /opt/files > > >> > > > > > > > > > allow *.client.domain > > > > >> > > > > > > > > > Put your shell file in the path you specified. Now > you > > >> just > > >> > > need to > > >> > > > > > > set up > > >> > > > > > > > > > a file and exec resource. Note the source item in > the > > >> file > > >> > > resource > > >> > > > > > > and the > > >> > > > > > > > > > require item in exec. > > > > >> > > > > > > > > > file { ''/etc/shell_file'': > > >> > > > > > > > > > ensure => present, > > >> > > > > > > > > > owner => ''root'', > > >> > > > > > > > > > group => ''root'', > > >> > > > > > > > > > mode => ''0755'', > > >> > > > > > > > > > source => ''puppet://puppet/files/shell_file'', > > >> > > > > > > > > > } > > > > >> > > > > > > > > > exec { ''/etc/shell_file'': require => > > >> File[''/etc/shell_file''] > > >> > > } > > > > >> > > > > > > > > > -- > > >> > > > > > > > > > Peter M. Bukowinski > > >> > > > > > > > > > Systems Engineer > > >> > > > > > > > > > Janelia Farm Research Campus, HHMI > > > > >> > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana > wrote: > > > > >> > > > > > > > > > > Hi all, I am new to puppet. I need a sample recipe > to > > >> > > write/copy a > > >> > > > > > > > > > > shell file on puppet client. The shell file exists > on > > >> > > puppet server. > > >> > > > > > > > > > > Once the file is written, I also want to execute > it. I > > >> have > > >> > > tried > > >> > > > > > > > > > > using file resource with ensure command to copy at > > >> /etc but > > >> > > > > > > permission > > >> > > > > > > > > > > was denied and moreover with a different directory > > >> path > > >> > > (\tmp) it > > >> > > > > > > just > > >> > > > > > > > > > > created an empty file. Can anyone please help? > > > > >> > > > > > > > > > > Regards, > > > > >> > > > > > > > > > > A. > > > > >> > > > > > > > > > > -- > > >> > > > > > > > > > > You received this message because you are > subscribed > > >> to the > > >> > > Google > > >> > > > > > > > > > Groups "Puppet Users" group. > > >> > > > > > > > > > > To post to this group, send email to > > >> > > puppet-users@googlegroups.com (mailto: > puppet-users@googlegroups.com) > > >> > > > > > > (mailto: > > >> > > > > > > > > > puppet-users@googlegroups.com (mailto: > > >> > > puppet-users@googlegroups.com)). > > >> > > > > > > > > > > To unsubscribe from this group, send email to > > >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > >> > > puppet-users%2Bunsubscribe@googlegroups.com) (mailto: > > >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: > > >> > > puppet-users%2Bunsubscribe@googlegroups.com)). > > > > ... > > > > read more » > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nathan Clemons
2011-Jun-17 17:50 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
You want: file { "blah": ... } exec {"blah2": ... require => File[''blah''] } That way you ensure the file is created before you try to run the exec. -- Nathan Clemons http://www.livemocha.com The worlds largest online language learning community On Fri, Jun 17, 2011 at 10:43 AM, Annie Rana <annierana@gmail.com> wrote:> Hi, > > Thanks much for help. Some how I managed to execute the original shell > script using command in exec "command=>''sh /tmp/QoS/QoS.sh''" and I used path > parameter as well "path=>''/sbin:/sbin/ipatbles:/bin:/usr/bin''" but I have to > run file and exec recipes separately one after another otherwise exec is > executed first if both are placed in one recipe and causing file not found > error. Is there any way to define the sequence of execution? > > Regards, > > Annie > > > On Fri, Jun 17, 2011 at 4:50 PM, Luke Bigum <Luke.Bigum@lmax.com> wrote: > >> Wouldn''t have worked anyway, change "print" to "echo" and I forgot #!/ >> bin/bash... That''s what I get for writing code from memory ;) >> >> That''s strange, I just put this in my Puppet server: >> >> node ''puppetmaster'' { >> file { ''/etc/shell_file'': >> ensure => present, >> owner => ''root'', >> group => ''root'', >> mode => ''0755'', >> source => ''puppet:///modules/puppet/shell_file'', >> } >> >> exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } >> } >> >> [root@co1puppet01 live]# cat ../../modules/live/puppet/files/ >> shell_file >> #!/bin/bash >> export LAN=eth1 >> export WAN=eth0 >> >> CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match >> ip tos 0x880xff classid 1:12" >> OUT=$($CMD) >> RET=$? >> echo "Command ''$CMD'' returned $RET" 2>&1 > /tmp/QoS.out >> echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out >> >> CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport >> 2345 -j TOS --set-tos 0x28" >> OUT=$($CMD) >> RET=$? >> echo "Command ''$CMD'' returned $RET" 2>&1 >> /tmp/QoS.out >> echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out >> >> CMD="iptables-save" >> OUT=$($CMD) >> RET=$? >> echo "Command ''$CMD'' returned $RET" 2>&1 >> /tmp/QoS.out >> echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out >> >> [root@puppetmaster live]# puppetd --test >> info: Caching catalog for puppetmaster >> info: Applying configuration version ''1308324915'' >> notice: /Stage[main]//Node[puppetmaster]/Exec[/etc/shell_file]/ >> returns: executed successfully >> notice: Finished catalog run in 1.04 seconds >> >> [root@puppetmaster]# cat /tmp/QoS.out >> Command ''tc filter add dev eth0 parent 1:0 prio 4 protocol ip u32 >> match ip tos 0x880xff classid 1:12'' returned 1 >> Command ''tc filter add dev eth0 parent 1:0 prio 4 protocol ip u32 >> match ip tos 0x880xff classid 1:12'' output '''' >> Command ''iptables -t mangle -A FORWARD -i eth1 -o eth0 -p udp --sport >> 2345 -j TOS --set-tos 0x28'' returned 2 >> Command ''iptables -t mangle -A FORWARD -i eth1 -o eth0 -p udp --sport >> 2345 -j TOS --set-tos 0x28'' output '''' >> Command ''iptables-save'' returned 0 >> Command ''iptables-save'' output ''# Generated by iptables-save v1.3.5 on >> Fri Jun 17 15:48:48 2011 >> *mangle >> :PREROUTING ACCEPT [3642:790381] >> :INPUT ACCEPT [2591:636935] >> :FORWARD ACCEPT [0:0] >> :OUTPUT ACCEPT [2551:866979] >> :POSTROUTING ACCEPT [2551:866979] >> COMMIT >> # Completed on Fri Jun 17 15:48:48 2011 >> # Generated by iptables-save v1.3.5 on Fri Jun 17 15:48:48 2011 >> *filter >> :INPUT ACCEPT [2637:639987] >> :FORWARD ACCEPT [0:0] >> :OUTPUT ACCEPT [2588:875945] >> COMMIT >> # Completed on Fri Jun 17 15:48:48 2011'' >> >> I''m running out of ideas. You don''t have noexec on /tmp do you? No, >> you said you could run it as root... Anyone else? >> >> On Jun 17, 4:31 pm, Annie Rana <annier...@gmail.com> wrote: >> > Hi Luke, >> > >> > I replaced my shell script with the one you wrote. Same old error >> message >> > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh returned >> 1 >> > instead of o at /etc/puppet/manifests/site.pp'' >> > . Your script didn''t generate any log at client machine. Now I am sure >> about >> > one thing that there is no issue with the shell script itself. The exec >> > command is having hiccup even before executing the shell. I even tried >> > command paremeter in exec but no use. Do you know anyother way to >> execute >> > bash shell in puppet? >> > >> > Thanks much, >> > >> > Annie >> > >> > On Fri, Jun 17, 2011 at 4:30 PM, Annie Rana <annier...@gmail.com> >> wrote: >> > > Hi Luke, >> > >> > > I replaced my shell script with the one you wrote. Same old error >> message >> > > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh >> returned 1 >> > > instead of o at /etc/puppet/manifests/site.pp''. Your script didn''t >> generated >> > > any log at client machine. Now I am sure about one thing that there is >> no >> > > issue with the shell script itself. The exec command is having hiccup >> even >> > > before executing the shell. I even tried command paremeter in exec but >> no >> > > use. Do you know anyother way to execute bash shell in puppet? >> > >> > > Thanks much, >> > >> > > Annie >> > >> > > On Fri, Jun 17, 2011 at 4:06 PM, Luke Bigum <Luke.Bi...@lmax.com> >> wrote: >> > >> > >> I''m out of ideas and I''d resort to hacking the script a bit to get >> > >> some debugging output. Try just this in QoS.sh to try identify what''s >> > >> failing: >> > >> > >> export LAN=eth1 >> > >> export WAN=eth0 >> > >> CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match >> > >> ip tos 0x880xff classid 1:12" >> > >> OUT=$($CMD) > /tmp/QoS.out 2>&1 >> > >> RET=$? >> > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >> > >> CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport >> > >> 2345 -j TOS --set-tos 0x28" >> > >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 >> > >> RET=$? >> > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >> > >> CMD="iptables-save" >> > >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 >> > >> RET=$? >> > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >> > >> > >> Or something like that. >> > >> > >> On Jun 17, 4:01 pm, Annie Rana <annier...@gmail.com> wrote: >> > >> > Thanks again Peter but sorry it didn''t work out either. >> > >> > >> > On Fri, Jun 17, 2011 at 3:52 PM, Peter Bukowinski < >> pmb...@gmail.com> >> > >> wrote: >> > >> > > In your QoS.sh file, make sure to use explicit paths to >> executables, >> > >> e.g: >> > >> > >> > > use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' >> > >> > >> > > -- >> > >> > > Peter M. Bukowinski >> > >> > > Systems Engineer >> > >> > > Janelia Farm Research Campus, HHMI >> > >> > >> > > On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote: >> > >> > >> > > > Hi Luke, >> > >> > > > What''s your shell script expected to >> > >> > > > do? >> > >> > > > The shell script would generate Iptables rules >> > >> > >> > > > How do you know it didn''t work? >> > >> > > > I can check using ipatbles -L or iptables -t mangle -L commands >> > >> > >> > > > If you run it by hand in a root shell, does it work then? >> > >> > > > Yes >> > >> > >> > > > If so, >> > >> > > > there might be an environment problem when running from Puppet, >> like >> > >> > > > $PATH or something. Try set the parameter "logoutput => true" >> in the >> > >> > > > exec resource. >> > >> > > > I did but no affect. >> > >> > >> > > > Thanks again, much appreciated your help and time. >> > >> > > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum < >> Luke.Bi...@lmax.com >> > >> (mailto: >> > >> > > Luke.Bi...@lmax.com)> wrote: >> > >> > > > > How do you know it didn''t work? What''s your shell script >> expected >> > >> to >> > >> > > > > do? If you run it by hand in a root shell, does it work >> then? If >> > >> so, >> > >> > > > > there might be an environment problem when running from >> Puppet, >> > >> like >> > >> > > > > $PATH or something. Try set the parameter "logoutput => >> true" in >> > >> the >> > >> > > > > exec resource. >> > >> > >> > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com(mailto: >> > >> > > annier...@gmail.com)> wrote: >> > >> > > > > > Thanks but it couldn''t work though i got the message that >> shell >> > >> > > script is >> > >> > > > > > successfully executed. >> > >> > >> > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum < >> > >> Luke.Bi...@lmax.com(mailto: >> > >> > > Luke.Bi...@lmax.com)> wrote: >> > >> > > > > > > Annie, >> > >> > >> > > > > > > >> http://docs.puppetlabs.com/references/stable/type.html#exec >> > >> > >> > > > > > > By default the expected return code is probably zero, >> your >> > >> script >> > >> > > is >> > >> > > > > > > returning 1. Whether this is correct or not I don''t know, >> but >> > >> you >> > >> > > can >> > >> > > > > > > tell puppet to expect a different return code: >> > >> > >> > > > > > > exec { ''/etc/shell_file'': >> > >> > > > > > > require => File[''/etc/shell_file''], >> > >> > > > > > > returns => 1, >> > >> > > > > > > } >> > >> > >> > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com(mailto: >> > >> > > annier...@gmail.com)> wrote: >> > >> > > > > > > > I apologize for posting wrong log messages, here is the >> > >> correct >> > >> > > log: >> > >> > >> > > > > > > > notice: Starting catalog run >> > >> > > > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh >> )]/ensure: >> > >> created >> > >> > > > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: >> > >> change >> > >> > > from notrun to 0 failed: >> > >> > > > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of >> 0 at >> > >> > > > > > > /etc/puppet/manifests/site.pp:10 >> > >> > > > > > > > notice: Finished catalog run in 0.46 seconds >> > >> > >> > > > > > > > Any help please? >> > >> > >> > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana < >> > >> annier...@gmail.com(mailto: >> > >> > > annier...@gmail.com)> wrote: >> > >> > > > > > > > > Hi Peter, thanks for your reply. I managed to copy >> the >> > >> shell >> > >> > > file >> > >> > > > > > > puppet >> > >> > > > > > > > > client using the file resource recipe you specified >> but >> > >> exec is >> > >> > > > > > > throwing an >> > >> > > > > > > > > error, which is as follows: >> > >> > >> > > > > > > > > info: No classes to store >> > >> > > > > > > > > info: Caching catalog at >> > >> /var/lib/puppet/state/localconfig.yaml >> > >> > > > > > > > > notice: Starting catalog run >> > >> > > > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh)]/ensure: >> > >> change >> > >> > > from absent to file failed: >> > >> > > > > > > > > Could not set file on ensure: No such file or >> directory - >> > >> > > > > > > > > /tmp/QoS/QoS.sh.puppettmp at >> > >> /etc/puppet/manifests/site.pp:7 >> > >> > > > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: >> > >> Dependency >> > >> > > file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 >> > >> > > > > > > > > failures >> > >> > > > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: >> > >> Skipping >> > >> > > because of failed >> > >> > > > > > > dependencies >> > >> > > > > > > > > notice: Finished catalog run in 0.38 seconds >> > >> > >> > > > > > > > > When I tried running the shell script manually using >> the >> > >> > > following >> > >> > > > > > > command >> > >> > >> > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh);echo$?'' >> > >> > >> > > > > > > > > , it worked fine printing 0 at the end. Any help what >> is >> > >> wrong >> > >> > > with >> > >> > > > > > > exec >> > >> > > > > > > > > resource recipe? >> > >> > >> > > > > > > > > Thanks in advance for your time. >> > >> > >> > > > > > > > > Regards, >> > >> > >> > > > > > > > > A. >> > >> > >> > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < >> > >> > > pmb...@gmail.com (mailto:pmb...@gmail.com) >> > >> > > > > > > > wrote: >> > >> > >> > > > > > > > > > It sounds like you haven''t set up the puppet >> fileserver >> > >> yet. >> > >> > > Choose a >> > >> > > > > > > > > > directory that will hold files you want to copy to >> > >> clients. I >> > >> > > use >> > >> > > > > > > > > > /opt/files, so that''s what is in my example. Create >> > >> > > fileserver.conf in >> > >> > > > > > > the >> > >> > > > > > > > > > same directory as puppet.conf and add these lines: >> > >> > >> > > > > > > > > > [files] >> > >> > > > > > > > > > path /opt/files >> > >> > > > > > > > > > allow *.client.domain >> > >> > >> > > > > > > > > > Put your shell file in the path you specified. Now >> you >> > >> just >> > >> > > need to >> > >> > > > > > > set up >> > >> > > > > > > > > > a file and exec resource. Note the source item in >> the >> > >> file >> > >> > > resource >> > >> > > > > > > and the >> > >> > > > > > > > > > require item in exec. >> > >> > >> > > > > > > > > > file { ''/etc/shell_file'': >> > >> > > > > > > > > > ensure => present, >> > >> > > > > > > > > > owner => ''root'', >> > >> > > > > > > > > > group => ''root'', >> > >> > > > > > > > > > mode => ''0755'', >> > >> > > > > > > > > > source => ''puppet://puppet/files/shell_file'', >> > >> > > > > > > > > > } >> > >> > >> > > > > > > > > > exec { ''/etc/shell_file'': require => >> > >> File[''/etc/shell_file''] >> > >> > > } >> > >> > >> > > > > > > > > > -- >> > >> > > > > > > > > > Peter M. Bukowinski >> > >> > > > > > > > > > Systems Engineer >> > >> > > > > > > > > > Janelia Farm Research Campus, HHMI >> > >> > >> > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana >> wrote: >> > >> > >> > > > > > > > > > > Hi all, I am new to puppet. I need a sample >> recipe to >> > >> > > write/copy a >> > >> > > > > > > > > > > shell file on puppet client. The shell file >> exists on >> > >> > > puppet server. >> > >> > > > > > > > > > > Once the file is written, I also want to execute >> it. I >> > >> have >> > >> > > tried >> > >> > > > > > > > > > > using file resource with ensure command to copy >> at >> > >> /etc but >> > >> > > > > > > permission >> > >> > > > > > > > > > > was denied and moreover with a different >> directory >> > >> path >> > >> > > (\tmp) it >> > >> > > > > > > just >> > >> > > > > > > > > > > created an empty file. Can anyone please help? >> > >> > >> > > > > > > > > > > Regards, >> > >> > >> > > > > > > > > > > A. >> > >> > >> > > > > > > > > > > -- >> > >> > > > > > > > > > > You received this message because you are >> subscribed >> > >> to the >> > >> > > Google >> > >> > > > > > > > > > Groups "Puppet Users" group. >> > >> > > > > > > > > > > To post to this group, send email to >> > >> > > puppet-users@googlegroups.com (mailto: >> puppet-users@googlegroups.com) >> > >> > > > > > > (mailto: >> > >> > > > > > > > > > puppet-users@googlegroups.com (mailto: >> > >> > > puppet-users@googlegroups.com)). >> > >> > > > > > > > > > > To unsubscribe from this group, send email to >> > >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: >> > >> > > puppet-users%2Bunsubscribe@googlegroups.com) (mailto: >> > >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com (mailto: >> > >> > > puppet-users%2Bunsubscribe@googlegroups.com)). >> > >> > ... >> > >> > read more » >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To post to this group, send email to puppet-users@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-users+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Annie Rana
2011-Jun-17 18:01 UTC
Re: [Puppet Users] Re: Puppet recipe to copy and execute a shell file
Thanks much Nathan, it worked like a charm. :) Thank you Peter and Luke; keep up the good work. Regards, A. On Fri, Jun 17, 2011 at 6:50 PM, Nathan Clemons <nathan@livemocha.com>wrote:> You want: > > file { "blah": > ... > } > exec {"blah2": > ... > require => File[''blah''] > } > > That way you ensure the file is created before you try to run the exec. > > -- > Nathan Clemons > http://www.livemocha.com > The worlds largest online language learning community > > > > On Fri, Jun 17, 2011 at 10:43 AM, Annie Rana <annierana@gmail.com> wrote: > >> Hi, >> >> Thanks much for help. Some how I managed to execute the original shell >> script using command in exec "command=>''sh /tmp/QoS/QoS.sh''" and I used path >> parameter as well "path=>''/sbin:/sbin/ipatbles:/bin:/usr/bin''" but I have to >> run file and exec recipes separately one after another otherwise exec is >> executed first if both are placed in one recipe and causing file not found >> error. Is there any way to define the sequence of execution? >> >> Regards, >> >> Annie >> >> >> On Fri, Jun 17, 2011 at 4:50 PM, Luke Bigum <Luke.Bigum@lmax.com> wrote: >> >>> Wouldn''t have worked anyway, change "print" to "echo" and I forgot #!/ >>> bin/bash... That''s what I get for writing code from memory ;) >>> >>> That''s strange, I just put this in my Puppet server: >>> >>> node ''puppetmaster'' { >>> file { ''/etc/shell_file'': >>> ensure => present, >>> owner => ''root'', >>> group => ''root'', >>> mode => ''0755'', >>> source => ''puppet:///modules/puppet/shell_file'', >>> } >>> >>> exec { ''/etc/shell_file'': require => File[''/etc/shell_file''] } >>> } >>> >>> [root@co1puppet01 live]# cat ../../modules/live/puppet/files/ >>> shell_file >>> #!/bin/bash >>> export LAN=eth1 >>> export WAN=eth0 >>> >>> CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 match >>> ip tos 0x880xff classid 1:12" >>> OUT=$($CMD) >>> RET=$? >>> echo "Command ''$CMD'' returned $RET" 2>&1 > /tmp/QoS.out >>> echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out >>> >>> CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp --sport >>> 2345 -j TOS --set-tos 0x28" >>> OUT=$($CMD) >>> RET=$? >>> echo "Command ''$CMD'' returned $RET" 2>&1 >> /tmp/QoS.out >>> echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out >>> >>> CMD="iptables-save" >>> OUT=$($CMD) >>> RET=$? >>> echo "Command ''$CMD'' returned $RET" 2>&1 >> /tmp/QoS.out >>> echo "Command ''$CMD'' output ''$OUT''" 2>&1 >> /tmp/QoS.out >>> >>> [root@puppetmaster live]# puppetd --test >>> info: Caching catalog for puppetmaster >>> info: Applying configuration version ''1308324915'' >>> notice: /Stage[main]//Node[puppetmaster]/Exec[/etc/shell_file]/ >>> returns: executed successfully >>> notice: Finished catalog run in 1.04 seconds >>> >>> [root@puppetmaster]# cat /tmp/QoS.out >>> Command ''tc filter add dev eth0 parent 1:0 prio 4 protocol ip u32 >>> match ip tos 0x880xff classid 1:12'' returned 1 >>> Command ''tc filter add dev eth0 parent 1:0 prio 4 protocol ip u32 >>> match ip tos 0x880xff classid 1:12'' output '''' >>> Command ''iptables -t mangle -A FORWARD -i eth1 -o eth0 -p udp --sport >>> 2345 -j TOS --set-tos 0x28'' returned 2 >>> Command ''iptables -t mangle -A FORWARD -i eth1 -o eth0 -p udp --sport >>> 2345 -j TOS --set-tos 0x28'' output '''' >>> Command ''iptables-save'' returned 0 >>> Command ''iptables-save'' output ''# Generated by iptables-save v1.3.5 on >>> Fri Jun 17 15:48:48 2011 >>> *mangle >>> :PREROUTING ACCEPT [3642:790381] >>> :INPUT ACCEPT [2591:636935] >>> :FORWARD ACCEPT [0:0] >>> :OUTPUT ACCEPT [2551:866979] >>> :POSTROUTING ACCEPT [2551:866979] >>> COMMIT >>> # Completed on Fri Jun 17 15:48:48 2011 >>> # Generated by iptables-save v1.3.5 on Fri Jun 17 15:48:48 2011 >>> *filter >>> :INPUT ACCEPT [2637:639987] >>> :FORWARD ACCEPT [0:0] >>> :OUTPUT ACCEPT [2588:875945] >>> COMMIT >>> # Completed on Fri Jun 17 15:48:48 2011'' >>> >>> I''m running out of ideas. You don''t have noexec on /tmp do you? No, >>> you said you could run it as root... Anyone else? >>> >>> On Jun 17, 4:31 pm, Annie Rana <annier...@gmail.com> wrote: >>> > Hi Luke, >>> > >>> > I replaced my shell script with the one you wrote. Same old error >>> message >>> > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh >>> returned 1 >>> > instead of o at /etc/puppet/manifests/site.pp'' >>> > . Your script didn''t generate any log at client machine. Now I am sure >>> about >>> > one thing that there is no issue with the shell script itself. The exec >>> > command is having hiccup even before executing the shell. I even tried >>> > command paremeter in exec but no use. Do you know anyother way to >>> execute >>> > bash shell in puppet? >>> > >>> > Thanks much, >>> > >>> > Annie >>> > >>> > On Fri, Jun 17, 2011 at 4:30 PM, Annie Rana <annier...@gmail.com> >>> wrote: >>> > > Hi Luke, >>> > >>> > > I replaced my shell script with the one you wrote. Same old error >>> message >>> > > appeared again ''change from notrun to 0 failed: /tmp/QoS/QoS.sh >>> returned 1 >>> > > instead of o at /etc/puppet/manifests/site.pp''. Your script didn''t >>> generated >>> > > any log at client machine. Now I am sure about one thing that there >>> is no >>> > > issue with the shell script itself. The exec command is having hiccup >>> even >>> > > before executing the shell. I even tried command paremeter in exec >>> but no >>> > > use. Do you know anyother way to execute bash shell in puppet? >>> > >>> > > Thanks much, >>> > >>> > > Annie >>> > >>> > > On Fri, Jun 17, 2011 at 4:06 PM, Luke Bigum <Luke.Bi...@lmax.com> >>> wrote: >>> > >>> > >> I''m out of ideas and I''d resort to hacking the script a bit to get >>> > >> some debugging output. Try just this in QoS.sh to try identify >>> what''s >>> > >> failing: >>> > >>> > >> export LAN=eth1 >>> > >> export WAN=eth0 >>> > >> CMD="tc filter add dev ${WAN} parent 1:0 prio 4 protocol ip u32 >>> match >>> > >> ip tos 0x880xff classid 1:12" >>> > >> OUT=$($CMD) > /tmp/QoS.out 2>&1 >>> > >> RET=$? >>> > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >>> > >> CMD="iptables -t mangle -A FORWARD -i ${LAN} -o ${WAN} -p udp >>> --sport >>> > >> 2345 -j TOS --set-tos 0x28" >>> > >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 >>> > >> RET=$? >>> > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >>> > >> CMD="iptables-save" >>> > >> OUT=$($CMD) >> /tmp/QoS.out 2>&1 >>> > >> RET=$? >>> > >> print "Command $CMD returned $RET" >> /tmp/QoS.out 2>&1 >>> > >>> > >> Or something like that. >>> > >>> > >> On Jun 17, 4:01 pm, Annie Rana <annier...@gmail.com> wrote: >>> > >> > Thanks again Peter but sorry it didn''t work out either. >>> > >>> > >> > On Fri, Jun 17, 2011 at 3:52 PM, Peter Bukowinski < >>> pmb...@gmail.com> >>> > >> wrote: >>> > >> > > In your QoS.sh file, make sure to use explicit paths to >>> executables, >>> > >> e.g: >>> > >>> > >> > > use ''/sbin/iptables -blah …'' NOT ''iptables -blah …'' >>> > >>> > >> > > -- >>> > >> > > Peter M. Bukowinski >>> > >> > > Systems Engineer >>> > >> > > Janelia Farm Research Campus, HHMI >>> > >>> > >> > > On Friday, June 17, 2011 at 10:44 AM, Annie Rana wrote: >>> > >>> > >> > > > Hi Luke, >>> > >> > > > What''s your shell script expected to >>> > >> > > > do? >>> > >> > > > The shell script would generate Iptables rules >>> > >>> > >> > > > How do you know it didn''t work? >>> > >> > > > I can check using ipatbles -L or iptables -t mangle -L >>> commands >>> > >>> > >> > > > If you run it by hand in a root shell, does it work then? >>> > >> > > > Yes >>> > >>> > >> > > > If so, >>> > >> > > > there might be an environment problem when running from >>> Puppet, like >>> > >> > > > $PATH or something. Try set the parameter "logoutput => true" >>> in the >>> > >> > > > exec resource. >>> > >> > > > I did but no affect. >>> > >>> > >> > > > Thanks again, much appreciated your help and time. >>> > >> > > > On Fri, Jun 17, 2011 at 3:26 PM, Luke Bigum < >>> Luke.Bi...@lmax.com >>> > >> (mailto: >>> > >> > > Luke.Bi...@lmax.com)> wrote: >>> > >> > > > > How do you know it didn''t work? What''s your shell script >>> expected >>> > >> to >>> > >> > > > > do? If you run it by hand in a root shell, does it work >>> then? If >>> > >> so, >>> > >> > > > > there might be an environment problem when running from >>> Puppet, >>> > >> like >>> > >> > > > > $PATH or something. Try set the parameter "logoutput => >>> true" in >>> > >> the >>> > >> > > > > exec resource. >>> > >>> > >> > > > > On Jun 17, 3:18 pm, Annie Rana <annier...@gmail.com(mailto: >>> > >> > > annier...@gmail.com)> wrote: >>> > >> > > > > > Thanks but it couldn''t work though i got the message that >>> shell >>> > >> > > script is >>> > >> > > > > > successfully executed. >>> > >>> > >> > > > > > On Fri, Jun 17, 2011 at 2:44 PM, Luke Bigum < >>> > >> Luke.Bi...@lmax.com(mailto: >>> > >> > > Luke.Bi...@lmax.com)> wrote: >>> > >> > > > > > > Annie, >>> > >>> > >> > > > > > > >>> http://docs.puppetlabs.com/references/stable/type.html#exec >>> > >>> > >> > > > > > > By default the expected return code is probably zero, >>> your >>> > >> script >>> > >> > > is >>> > >> > > > > > > returning 1. Whether this is correct or not I don''t >>> know, but >>> > >> you >>> > >> > > can >>> > >> > > > > > > tell puppet to expect a different return code: >>> > >>> > >> > > > > > > exec { ''/etc/shell_file'': >>> > >> > > > > > > require => File[''/etc/shell_file''], >>> > >> > > > > > > returns => 1, >>> > >> > > > > > > } >>> > >>> > >> > > > > > > On Jun 17, 2:36 pm, Annie Rana <annier...@gmail.com(mailto: >>> > >> > > annier...@gmail.com)> wrote: >>> > >> > > > > > > > I apologize for posting wrong log messages, here is >>> the >>> > >> correct >>> > >> > > log: >>> > >>> > >> > > > > > > > notice: Starting catalog run >>> > >> > > > > > > > notice: //File[/tmp/QoS/QoS.sh (http://QoS.sh >>> )]/ensure: >>> > >> created >>> > >> > > > > > > > err: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]/returns: >>> > >> change >>> > >> > > from notrun to 0 failed: >>> > >> > > > > > > > /tmp/QoS/QoS.sh (http://QoS.sh) returned 1 instead of >>> 0 at >>> > >> > > > > > > /etc/puppet/manifests/site.pp:10 >>> > >> > > > > > > > notice: Finished catalog run in 0.46 seconds >>> > >>> > >> > > > > > > > Any help please? >>> > >>> > >> > > > > > > > On Fri, Jun 17, 2011 at 2:09 PM, Annie Rana < >>> > >> annier...@gmail.com(mailto: >>> > >> > > annier...@gmail.com)> wrote: >>> > >> > > > > > > > > Hi Peter, thanks for your reply. I managed to copy >>> the >>> > >> shell >>> > >> > > file >>> > >> > > > > > > puppet >>> > >> > > > > > > > > client using the file resource recipe you specified >>> but >>> > >> exec is >>> > >> > > > > > > throwing an >>> > >> > > > > > > > > error, which is as follows: >>> > >>> > >> > > > > > > > > info: No classes to store >>> > >> > > > > > > > > info: Caching catalog at >>> > >> /var/lib/puppet/state/localconfig.yaml >>> > >> > > > > > > > > notice: Starting catalog run >>> > >> > > > > > > > > err: //File[/tmp/QoS/QoS.sh (http://QoS.sh >>> )]/ensure: >>> > >> change >>> > >> > > from absent to file failed: >>> > >> > > > > > > > > Could not set file on ensure: No such file or >>> directory - >>> > >> > > > > > > > > /tmp/QoS/QoS.sh.puppettmp at >>> > >> /etc/puppet/manifests/site.pp:7 >>> > >> > > > > > > > > notice: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: >>> > >> Dependency >>> > >> > > file[/tmp/QoS/QoS.sh (http://QoS.sh)] has 1 >>> > >> > > > > > > > > failures >>> > >> > > > > > > > > warning: //Exec[/tmp/QoS/QoS.sh (http://QoS.sh)]: >>> > >> Skipping >>> > >> > > because of failed >>> > >> > > > > > > dependencies >>> > >> > > > > > > > > notice: Finished catalog run in 0.38 seconds >>> > >>> > >> > > > > > > > > When I tried running the shell script manually using >>> the >>> > >> > > following >>> > >> > > > > > > command >>> > >>> > >> > > > > > > > > ''/tmp/QoS/QoS.sh (http://QoS.sh);echo$?'' >>> > >>> > >> > > > > > > > > , it worked fine printing 0 at the end. Any help >>> what is >>> > >> wrong >>> > >> > > with >>> > >> > > > > > > exec >>> > >> > > > > > > > > resource recipe? >>> > >>> > >> > > > > > > > > Thanks in advance for your time. >>> > >>> > >> > > > > > > > > Regards, >>> > >>> > >> > > > > > > > > A. >>> > >>> > >> > > > > > > > > On Thu, Jun 16, 2011 at 8:42 PM, Peter Bukowinski < >>> > >> > > pmb...@gmail.com (mailto:pmb...@gmail.com) >>> > >> > > > > > > > wrote: >>> > >>> > >> > > > > > > > > > It sounds like you haven''t set up the puppet >>> fileserver >>> > >> yet. >>> > >> > > Choose a >>> > >> > > > > > > > > > directory that will hold files you want to copy to >>> > >> clients. I >>> > >> > > use >>> > >> > > > > > > > > > /opt/files, so that''s what is in my example. >>> Create >>> > >> > > fileserver.conf in >>> > >> > > > > > > the >>> > >> > > > > > > > > > same directory as puppet.conf and add these lines: >>> > >>> > >> > > > > > > > > > [files] >>> > >> > > > > > > > > > path /opt/files >>> > >> > > > > > > > > > allow *.client.domain >>> > >>> > >> > > > > > > > > > Put your shell file in the path you specified. Now >>> you >>> > >> just >>> > >> > > need to >>> > >> > > > > > > set up >>> > >> > > > > > > > > > a file and exec resource. Note the source item in >>> the >>> > >> file >>> > >> > > resource >>> > >> > > > > > > and the >>> > >> > > > > > > > > > require item in exec. >>> > >>> > >> > > > > > > > > > file { ''/etc/shell_file'': >>> > >> > > > > > > > > > ensure => present, >>> > >> > > > > > > > > > owner => ''root'', >>> > >> > > > > > > > > > group => ''root'', >>> > >> > > > > > > > > > mode => ''0755'', >>> > >> > > > > > > > > > source => ''puppet://puppet/files/shell_file'', >>> > >> > > > > > > > > > } >>> > >>> > >> > > > > > > > > > exec { ''/etc/shell_file'': require => >>> > >> File[''/etc/shell_file''] >>> > >> > > } >>> > >>> > >> > > > > > > > > > -- >>> > >> > > > > > > > > > Peter M. Bukowinski >>> > >> > > > > > > > > > Systems Engineer >>> > >> > > > > > > > > > Janelia Farm Research Campus, HHMI >>> > >>> > >> > > > > > > > > > On Thursday, June 16, 2011 at 3:17 PM, annierana >>> wrote: >>> > >>> > >> > > > > > > > > > > Hi all, I am new to puppet. I need a sample >>> recipe to >>> > >> > > write/copy a >>> > >> > > > > > > > > > > shell file on puppet client. The shell file >>> exists on >>> > >> > > puppet server. >>> > >> > > > > > > > > > > Once the file is written, I also want to execute >>> it. I >>> > >> have >>> > >> > > tried >>> > >> > > > > > > > > > > using file resource with ensure command to copy >>> at >>> > >> /etc but >>> > >> > > > > > > permission >>> > >> > > > > > > > > > > was denied and moreover with a different >>> directory >>> > >> path >>> > >> > > (\tmp) it >>> > >> > > > > > > just >>> > >> > > > > > > > > > > created an empty file. Can anyone please help? >>> > >>> > >> > > > > > > > > > > Regards, >>> > >>> > >> > > > > > > > > > > A. >>> > >>> > >> > > > > > > > > > > -- >>> > >> > > > > > > > > > > You received this message because you are >>> subscribed >>> > >> to the >>> > >> > > Google >>> > >> > > > > > > > > > Groups "Puppet Users" group. >>> > >> > > > > > > > > > > To post to this group, send email to >>> > >> > > puppet-users@googlegroups.com (mailto: >>> puppet-users@googlegroups.com) >>> > >> > > > > > > (mailto: >>> > >> > > > > > > > > > puppet-users@googlegroups.com (mailto: >>> > >> > > puppet-users@googlegroups.com)). >>> > >> > > > > > > > > > > To unsubscribe from this group, send email to >>> > >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com(mailto: >>> > >> > > puppet-users%2Bunsubscribe@googlegroups.com) (mailto: >>> > >> > > > > > > > > > puppet-users+unsubscribe@googlegroups.com(mailto: >>> > >> > > puppet-users%2Bunsubscribe@googlegroups.com)). >>> > >>> > ... >>> > >>> > read more » >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Puppet Users" group. >>> To post to this group, send email to puppet-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> puppet-users+unsubscribe@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/puppet-users?hl=en. >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To post to this group, send email to puppet-users@googlegroups.com. >> To unsubscribe from this group, send email to >> puppet-users+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.