John Naggets
2013-May-30 20:04 UTC
[Puppet Users] Run a File resource only if another file is missing
Hi, I would like to run the File resource below: file { ''autoconfig.php'': path => ''/var/www/owncloud/config/autoconfig.php'', ensure => file, owner => ''www-data'', group => ''www-data'', content => template("owncloud/autoconfig.php.erb"), } only when a specific file (in my case: /var/www/owncloud/config/config.php) is missing. Is this somehow possible? Couldn''t find my case in the puppet documentation... Thanks! John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Dan White
2013-May-30 21:26 UTC
Re: [Puppet Users] Run a File resource only if another file is missing
Short Answer: You need to create a custom fact that would drive the decision to create the new file resource. I just went thru this issue and also performing an action based on whether or not a package (RPM in my case) is installed. Same answer to both. For the existence of a file, you can do this: #!/bin/bash test -f /var/www/owncloud/config/config.php rc=$? echo "is_my_file_there=${rc}" That goes into /etc/facter/facts.d/ as an executable shell script and then in your manifest: if $::is_my_file_there != 0 { file { ''autoconfig.php'': ..... } } “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Original Message ----- From: "John Naggets" <hostingnuggets@gmail.com> To: puppet-users@googlegroups.com Sent: Thursday, May 30, 2013 4:04:29 PM Subject: [Puppet Users] Run a File resource only if another file is missing Hi, I would like to run the File resource below: file { ''autoconfig.php'': path => ''/var/www/owncloud/config/autoconfig.php'', ensure => file, owner => ''www-data'', group => ''www-data'', content => template("owncloud/autoconfig.php.erb"), } only when a specific file (in my case: /var/www/owncloud/config/config.php) is missing. Is this somehow possible? Couldn''t find my case in the puppet documentation... Thanks! John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en . For more options, visit https://groups.google.com/groups/opt_out . -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Matthias Saou
2013-May-31 08:00 UTC
Re: [Puppet Users] Run a File resource only if another file is missing
There are other ways. None are nice and clean, but a custom fact just for this seems overkill. Here''s a quick example of how I''ve implemented creating a default ~/.gitconfig for users if it doesn''t exist, but not modify it if it''s already there or has been modified. $gitconfig_user_name = $mymodule::uservar::fullname[$title] $gitconfig_user_email = "${title}@example.com" file { "${home}/.gitconfig": owner => $owner, group => $group, mode => ''0644'', require => Exec["create-gitconfig-${title}"], } exec { "create-gitconfig-${title}": command => template(''mymodule/user/gitconfig.erb''), require => User[$title], creates => "${home}/.gitconfig", } The gitconfig.erb has the following content : /bin/cat > <%= home %>/.gitconfig << EOF [user] name = <%= @gitconfig_user_name %> email = <%= @gitconfig_user_email %> EOF Basically, just don''t have either ''source'' nor ''content'' for your file resource, and create the initial content using an exec with the ''creates'' condition. Matthias Dan White <ygor@comcast.net> wrote:> Short Answer: You need to create a custom fact that would drive the > decision to create the new file resource. > > I just went thru this issue and also performing an action based on > whether or not a package (RPM in my case) is installed. > > Same answer to both. > > For the existence of a file, you can do this: > > #!/bin/bash > test -f /var/www/owncloud/config/config.php > rc=$? > echo "is_my_file_there=${rc}" > > That goes into /etc/facter/facts.d/ as an executable shell script and > then in your manifest: > > if $::is_my_file_there != 0 { > file { ''autoconfig.php'': > ..... > } > } > > > “Sometimes I think the surest sign that intelligent life exists > elsewhere in the universe is that none of it has tried to contact > us.” Bill Waterson (Calvin & Hobbes) > > ----- Original Message ----- > From: "John Naggets" <hostingnuggets@gmail.com> > To: puppet-users@googlegroups.com > Sent: Thursday, May 30, 2013 4:04:29 PM > Subject: [Puppet Users] Run a File resource only if another file is > missing > > Hi, > > I would like to run the File resource below: > > file { ''autoconfig.php'': > path => ''/var/www/owncloud/config/autoconfig.php'', > ensure => file, > owner => ''www-data'', > group => ''www-data'', > content => template("owncloud/autoconfig.php.erb"), > } > > only when a specific file (in my > case: /var/www/owncloud/config/config.php) is missing. Is this > somehow possible? Couldn''t find my case in the puppet > documentation... > > Thanks! > John > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Dan White
2013-May-31 12:36 UTC
Re: [Puppet Users] Run a File resource only if another file is missing
That is an excellent example, but I think you miss the original point: Your example deals with only one file resource - the dot-gitconfig file Suppose you only wanted to perform this action if git was installed on the system, and do nothing if it was not ? This additional requirement puts it closer to the original question and this is where a custom fact is called for in the opinion of several folks on the list including myself. If you can offer an example that demonstrates otherwise, I would welcome it. I do not believe it possible without the custom fact and I have several hours of frustrated tinkering to show for it. I wanted to set a parameter in a config file but only if (the config file exists and/or the associated package is installed) and found I could not do it completely from within the manifest. “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Original Message ----- From: "Matthias Saou" <matthias@saou.eu> To: puppet-users@googlegroups.com Sent: Friday, May 31, 2013 4:00:15 AM Subject: Re: [Puppet Users] Run a File resource only if another file is missing There are other ways. None are nice and clean, but a custom fact just for this seems overkill. Here''s a quick example of how I''ve implemented creating a default ~/.gitconfig for users if it doesn''t exist, but not modify it if it''s already there or has been modified. $gitconfig_user_name = $mymodule::uservar::fullname[$title] $gitconfig_user_email = "${title}@example.com" file { "${home}/.gitconfig": owner => $owner, group => $group, mode => ''0644'', require => Exec["create-gitconfig-${title}"], } exec { "create-gitconfig-${title}": command => template(''mymodule/user/gitconfig.erb''), require => User[$title], creates => "${home}/.gitconfig", } The gitconfig.erb has the following content : /bin/cat > <%= home %>/.gitconfig << EOF [user] name = <%= @gitconfig_user_name %> email = <%= @gitconfig_user_email %> EOF Basically, just don''t have either ''source'' nor ''content'' for your file resource, and create the initial content using an exec with the ''creates'' condition. Matthias Dan White <ygor@comcast.net> wrote:> Short Answer: You need to create a custom fact that would drive the > decision to create the new file resource. > > I just went thru this issue and also performing an action based on > whether or not a package (RPM in my case) is installed. > > Same answer to both. > > For the existence of a file, you can do this: > > #!/bin/bash > test -f /var/www/owncloud/config/config.php > rc=$? > echo "is_my_file_there=${rc}" > > That goes into /etc/facter/facts.d/ as an executable shell script and > then in your manifest: > > if $::is_my_file_there != 0 { > file { ''autoconfig.php'': > ..... > } > } > > > “Sometimes I think the surest sign that intelligent life exists > elsewhere in the universe is that none of it has tried to contact > us.” Bill Waterson (Calvin & Hobbes) > > ----- Original Message ----- > From: "John Naggets" <hostingnuggets@gmail.com> > To: puppet-users@googlegroups.com > Sent: Thursday, May 30, 2013 4:04:29 PM > Subject: [Puppet Users] Run a File resource only if another file is > missing > > Hi, > > I would like to run the File resource below: > > file { ''autoconfig.php'': > path => ''/var/www/owncloud/config/autoconfig.php'', > ensure => file, > owner => ''www-data'', > group => ''www-data'', > content => template("owncloud/autoconfig.php.erb"), > } > > only when a specific file (in my > case: /var/www/owncloud/config/config.php) is missing. Is this > somehow possible? Couldn''t find my case in the puppet > documentation... > > Thanks! > John > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Matthias Saou
2013-May-31 12:57 UTC
Re: [Puppet Users] Run a File resource only if another file is missing
Hi, Indeed, I had missed that John was mentioning two different files ("config.php" vs. "autoconfig.php"). In that case, my only bit of (useless) advice is : You''re not using puppet in the way it''s most efficient, as it''s not meant to manage nodes based on changes it doesn''t make itself. Custom fact, it is... Matthias Dan White <ygor@comcast.net> wrote:> That is an excellent example, but I think you miss the original point: > > Your example deals with only one file resource - the dot-gitconfig > file Suppose you only wanted to perform this action if git was > installed on the system, and do nothing if it was not ? > > This additional requirement puts it closer to the original question > and this is where a custom fact is called for in the opinion of > several folks on the list including myself. > > If you can offer an example that demonstrates otherwise, I would > welcome it. I do not believe it possible without the custom fact and > I have several hours of frustrated tinkering to show for it. I > wanted to set a parameter in a config file but only if (the config > file exists and/or the associated package is installed) and found I > could not do it completely from within the manifest. > > “Sometimes I think the surest sign that intelligent life exists > elsewhere in the universe is that none of it has tried to contact > us.” Bill Waterson (Calvin & Hobbes) > > ----- Original Message ----- > From: "Matthias Saou" <matthias@saou.eu> > To: puppet-users@googlegroups.com > Sent: Friday, May 31, 2013 4:00:15 AM > Subject: Re: [Puppet Users] Run a File resource only if another file > is missing > > There are other ways. None are nice and clean, but a custom fact just > for this seems overkill. > > Here''s a quick example of how I''ve implemented creating a default > ~/.gitconfig for users if it doesn''t exist, but not modify it if it''s > already there or has been modified. > > $gitconfig_user_name = $mymodule::uservar::fullname[$title] > $gitconfig_user_email = "${title}@example.com" > file { "${home}/.gitconfig": > owner => $owner, > group => $group, > mode => ''0644'', > require => Exec["create-gitconfig-${title}"], > } > exec { "create-gitconfig-${title}": > command => template(''mymodule/user/gitconfig.erb''), > require => User[$title], > creates => "${home}/.gitconfig", > } > > The gitconfig.erb has the following content : > /bin/cat > <%= home %>/.gitconfig << EOF > [user] > name = <%= @gitconfig_user_name %> > email = <%= @gitconfig_user_email %> > EOF > > Basically, just don''t have either ''source'' nor ''content'' for your file > resource, and create the initial content using an exec with the > ''creates'' condition. > > Matthias > > Dan White <ygor@comcast.net> wrote: > > > Short Answer: You need to create a custom fact that would drive the > > decision to create the new file resource. > > > > I just went thru this issue and also performing an action based on > > whether or not a package (RPM in my case) is installed. > > > > Same answer to both. > > > > For the existence of a file, you can do this: > > > > #!/bin/bash > > test -f /var/www/owncloud/config/config.php > > rc=$? > > echo "is_my_file_there=${rc}" > > > > That goes into /etc/facter/facts.d/ as an executable shell script > > and then in your manifest: > > > > if $::is_my_file_there != 0 { > > file { ''autoconfig.php'': > > ..... > > } > > } > > > > > > “Sometimes I think the surest sign that intelligent life exists > > elsewhere in the universe is that none of it has tried to contact > > us.” Bill Waterson (Calvin & Hobbes) > > > > ----- Original Message ----- > > From: "John Naggets" <hostingnuggets@gmail.com> > > To: puppet-users@googlegroups.com > > Sent: Thursday, May 30, 2013 4:04:29 PM > > Subject: [Puppet Users] Run a File resource only if another file is > > missing > > > > Hi, > > > > I would like to run the File resource below: > > > > file { ''autoconfig.php'': > > path => ''/var/www/owncloud/config/autoconfig.php'', > > ensure => file, > > owner => ''www-data'', > > group => ''www-data'', > > content => template("owncloud/autoconfig.php.erb"), > > } > > > > only when a specific file (in my > > case: /var/www/owncloud/config/config.php) is missing. Is this > > somehow possible? Couldn''t find my case in the puppet > > documentation... > > > > Thanks! > > John > > > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Nan Liu
2013-May-31 14:52 UTC
Re: [Puppet Users] Run a File resource only if another file is missing
On Fri, May 31, 2013 at 1:00 AM, Matthias Saou <matthias@saou.eu> wrote:> There are other ways. None are nice and clean, but a custom fact just > for this seems overkill. > > Here''s a quick example of how I''ve implemented creating a default > ~/.gitconfig for users if it doesn''t exist, but not modify it if it''s > already there or has been modified. > > $gitconfig_user_name = $mymodule::uservar::fullname[$title] > $gitconfig_user_email = "${title}@example.com" > file { "${home}/.gitconfig": > owner => $owner, > group => $group, > mode => ''0644'', > require => Exec["create-gitconfig-${title}"], > } > exec { "create-gitconfig-${title}": > command => template(''mymodule/user/gitconfig.erb''), > require => User[$title], > creates => "${home}/.gitconfig", > } >A bit off topic, but you should use file attribute replace => false instead of an exec. Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
John Naggets
2013-May-31 16:01 UTC
Re: [Puppet Users] Run a File resource only if another file is missing
Thanks guys for your input. That''s correct I am looking to act upon another file''s nonexistence... I will go with facter. On Friday, May 31, 2013 2:57:56 PM UTC+2, Matthias Saou wrote:> > Hi, > > Indeed, I had missed that John was mentioning two different files > ("config.php" vs. "autoconfig.php"). In that case, my only bit of > (useless) advice is : You''re not using puppet in the way it''s most > efficient, as it''s not meant to manage nodes based on changes it > doesn''t make itself. > > Custom fact, it is... > > Matthias > > Dan White <yg...@comcast.net <javascript:>> wrote: > > > That is an excellent example, but I think you miss the original point: > > > > Your example deals with only one file resource - the dot-gitconfig > > file Suppose you only wanted to perform this action if git was > > installed on the system, and do nothing if it was not ? > > > > This additional requirement puts it closer to the original question > > and this is where a custom fact is called for in the opinion of > > several folks on the list including myself. > > > > If you can offer an example that demonstrates otherwise, I would > > welcome it. I do not believe it possible without the custom fact and > > I have several hours of frustrated tinkering to show for it. I > > wanted to set a parameter in a config file but only if (the config > > file exists and/or the associated package is installed) and found I > > could not do it completely from within the manifest. > > > > “Sometimes I think the surest sign that intelligent life exists > > elsewhere in the universe is that none of it has tried to contact > > us.” Bill Waterson (Calvin & Hobbes) > > > > ----- Original Message ----- > > From: "Matthias Saou" <matt...@saou.eu <javascript:>> > > To: puppet...@googlegroups.com <javascript:> > > Sent: Friday, May 31, 2013 4:00:15 AM > > Subject: Re: [Puppet Users] Run a File resource only if another file > > is missing > > > > There are other ways. None are nice and clean, but a custom fact just > > for this seems overkill. > > > > Here''s a quick example of how I''ve implemented creating a default > > ~/.gitconfig for users if it doesn''t exist, but not modify it if it''s > > already there or has been modified. > > > > $gitconfig_user_name = $mymodule::uservar::fullname[$title] > > $gitconfig_user_email = "${tit...@example.com <javascript:>" > > file { "${home}/.gitconfig": > > owner => $owner, > > group => $group, > > mode => ''0644'', > > require => Exec["create-gitconfig-${title}"], > > } > > exec { "create-gitconfig-${title}": > > command => template(''mymodule/user/gitconfig.erb''), > > require => User[$title], > > creates => "${home}/.gitconfig", > > } > > > > The gitconfig.erb has the following content : > > /bin/cat > <%= home %>/.gitconfig << EOF > > [user] > > name = <%= @gitconfig_user_name %> > > email = <%= @gitconfig_user_email %> > > EOF > > > > Basically, just don''t have either ''source'' nor ''content'' for your file > > resource, and create the initial content using an exec with the > > ''creates'' condition. > > > > Matthias > > > > Dan White <yg...@comcast.net <javascript:>> wrote: > > > > > Short Answer: You need to create a custom fact that would drive the > > > decision to create the new file resource. > > > > > > I just went thru this issue and also performing an action based on > > > whether or not a package (RPM in my case) is installed. > > > > > > Same answer to both. > > > > > > For the existence of a file, you can do this: > > > > > > #!/bin/bash > > > test -f /var/www/owncloud/config/config.php > > > rc=$? > > > echo "is_my_file_there=${rc}" > > > > > > That goes into /etc/facter/facts.d/ as an executable shell script > > > and then in your manifest: > > > > > > if $::is_my_file_there != 0 { > > > file { ''autoconfig.php'': > > > ..... > > > } > > > } > > > > > > > > > “Sometimes I think the surest sign that intelligent life exists > > > elsewhere in the universe is that none of it has tried to contact > > > us.” Bill Waterson (Calvin & Hobbes) > > > > > > ----- Original Message ----- > > > From: "John Naggets" <hosting...@gmail.com <javascript:>> > > > To: puppet...@googlegroups.com <javascript:> > > > Sent: Thursday, May 30, 2013 4:04:29 PM > > > Subject: [Puppet Users] Run a File resource only if another file is > > > missing > > > > > > Hi, > > > > > > I would like to run the File resource below: > > > > > > file { ''autoconfig.php'': > > > path => ''/var/www/owncloud/config/autoconfig.php'', > > > ensure => file, > > > owner => ''www-data'', > > > group => ''www-data'', > > > content => template("owncloud/autoconfig.php.erb"), > > > } > > > > > > only when a specific file (in my > > > case: /var/www/owncloud/config/config.php) is missing. Is this > > > somehow possible? Couldn''t find my case in the puppet > > > documentation... > > > > > > Thanks! > > > John > > > > > > > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
joe
2013-May-31 21:24 UTC
Re: [Puppet Users] Run a File resource only if another file is missing
You should really reconsider how you are going about things and organizing your resources if you have to do stuff like this. Puppet was never meant to be reactionary in this sense. It''s entire purpose is to define the state of the system and enforce that state, not to respond to the state of the system conditionally. On Friday, May 31, 2013 10:01:19 AM UTC-6, John Naggets wrote:> > Thanks guys for your input. That''s correct I am looking to act upon > another file''s nonexistence... I will go with facter. > > On Friday, May 31, 2013 2:57:56 PM UTC+2, Matthias Saou wrote: >> >> Hi, >> >> Indeed, I had missed that John was mentioning two different files >> ("config.php" vs. "autoconfig.php"). In that case, my only bit of >> (useless) advice is : You''re not using puppet in the way it''s most >> efficient, as it''s not meant to manage nodes based on changes it >> doesn''t make itself. >> >> Custom fact, it is... >> >> Matthias >> >> Dan White <yg...@comcast.net> wrote: >> >> > That is an excellent example, but I think you miss the original point: >> > >> > Your example deals with only one file resource - the dot-gitconfig >> > file Suppose you only wanted to perform this action if git was >> > installed on the system, and do nothing if it was not ? >> > >> > This additional requirement puts it closer to the original question >> > and this is where a custom fact is called for in the opinion of >> > several folks on the list including myself. >> > >> > If you can offer an example that demonstrates otherwise, I would >> > welcome it. I do not believe it possible without the custom fact and >> > I have several hours of frustrated tinkering to show for it. I >> > wanted to set a parameter in a config file but only if (the config >> > file exists and/or the associated package is installed) and found I >> > could not do it completely from within the manifest. >> > >> > “Sometimes I think the surest sign that intelligent life exists >> > elsewhere in the universe is that none of it has tried to contact >> > us.” Bill Waterson (Calvin & Hobbes) >> > >> > ----- Original Message ----- >> > From: "Matthias Saou" <matt...@saou.eu> >> > To: puppet...@googlegroups.com >> > Sent: Friday, May 31, 2013 4:00:15 AM >> > Subject: Re: [Puppet Users] Run a File resource only if another file >> > is missing >> > >> > There are other ways. None are nice and clean, but a custom fact just >> > for this seems overkill. >> > >> > Here''s a quick example of how I''ve implemented creating a default >> > ~/.gitconfig for users if it doesn''t exist, but not modify it if it''s >> > already there or has been modified. >> > >> > $gitconfig_user_name = $mymodule::uservar::fullname[$title] >> > $gitconfig_user_email = "${tit...@example.com" >> > file { "${home}/.gitconfig": >> > owner => $owner, >> > group => $group, >> > mode => ''0644'', >> > require => Exec["create-gitconfig-${title}"], >> > } >> > exec { "create-gitconfig-${title}": >> > command => template(''mymodule/user/gitconfig.erb''), >> > require => User[$title], >> > creates => "${home}/.gitconfig", >> > } >> > >> > The gitconfig.erb has the following content : >> > /bin/cat > <%= home %>/.gitconfig << EOF >> > [user] >> > name = <%= @gitconfig_user_name %> >> > email = <%= @gitconfig_user_email %> >> > EOF >> > >> > Basically, just don''t have either ''source'' nor ''content'' for your file >> > resource, and create the initial content using an exec with the >> > ''creates'' condition. >> > >> > Matthias >> > >> > Dan White <yg...@comcast.net> wrote: >> > >> > > Short Answer: You need to create a custom fact that would drive the >> > > decision to create the new file resource. >> > > >> > > I just went thru this issue and also performing an action based on >> > > whether or not a package (RPM in my case) is installed. >> > > >> > > Same answer to both. >> > > >> > > For the existence of a file, you can do this: >> > > >> > > #!/bin/bash >> > > test -f /var/www/owncloud/config/config.php >> > > rc=$? >> > > echo "is_my_file_there=${rc}" >> > > >> > > That goes into /etc/facter/facts.d/ as an executable shell script >> > > and then in your manifest: >> > > >> > > if $::is_my_file_there != 0 { >> > > file { ''autoconfig.php'': >> > > ..... >> > > } >> > > } >> > > >> > > >> > > “Sometimes I think the surest sign that intelligent life exists >> > > elsewhere in the universe is that none of it has tried to contact >> > > us.” Bill Waterson (Calvin & Hobbes) >> > > >> > > ----- Original Message ----- >> > > From: "John Naggets" <hosting...@gmail.com> >> > > To: puppet...@googlegroups.com >> > > Sent: Thursday, May 30, 2013 4:04:29 PM >> > > Subject: [Puppet Users] Run a File resource only if another file is >> > > missing >> > > >> > > Hi, >> > > >> > > I would like to run the File resource below: >> > > >> > > file { ''autoconfig.php'': >> > > path => ''/var/www/owncloud/config/autoconfig.php'', >> > > ensure => file, >> > > owner => ''www-data'', >> > > group => ''www-data'', >> > > content => template("owncloud/autoconfig.php.erb"), >> > > } >> > > >> > > only when a specific file (in my >> > > case: /var/www/owncloud/config/config.php) is missing. Is this >> > > somehow possible? Couldn''t find my case in the puppet >> > > documentation... >> > > >> > > Thanks! >> > > John >> > > >> > > >> > >> >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Matthias Saou
2013-Jun-03 09:44 UTC
Re: [Puppet Users] Run a File resource only if another file is missing
On Fri, 31 May 2013 07:52:25 -0700 Nan Liu <nan.liu@gmail.com> wrote:> A bit off topic, but you should use file attribute replace => false > instead of an exec.Indeed. I'm not sure how I've missed that parameter. And it seems to have existed for a loooooong time. Thanks a lot for correcting me! Matthias -- Matthias Saou ██ ██ ██ ██ Web: http://matthias.saou.eu/ ██████████████ Mail/XMPP: matthias@saou.eu ████ ██████ ████ ██████████████████████ GPG: 4096R/E755CC63 ██ ██████████████ ██ 8D91 7E2E F048 9C9C 46AF ██ ██ ██ ██ 21A9 7A51 7B82 E755 CC63 ████ ████ -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Seemingly Similar Threads
- Can't work with command prompt on Windows XP
- Cannot get the syntax of --include-from right
- Xen hypervisor on CentOS 7.4 with modern UEFI server not booting from grub
- Error: Could not find dependency Yumrepo[puppetlabs-products] for Package[puppet]
- Problem with excludes and includes