Re: [Puppet Users] how to check existences of a file in a ERB template?

2016-04-13 Thread Sans
That was a brilliant idea!! You are a super-star!!
Worked like a charm!! 

-San
 

On Tuesday, March 29, 2016 at 8:05:23 PM UTC+1, Ramin K wrote:

>
> I think it's simpler to make PHP do the work because templates are 
> evaluated on the master. 
>
> if(file_exists('/var/www/<%= @title %>/wp-content/wp-extra-config.php')')) 
>require_once(ABSPATH . 'wp-content/wp-extra-config.php'); 
>
> Or whatever the if PHP syntax would be 
>
> Ramin 
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c0a31b7c-3867-42a6-8793-7897ab480dc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] how to check existences of a file in a ERB template?

2016-03-29 Thread Ramin K

On 3/28/16 12:44 PM, Sans wrote:

Hi there,

I'm setting up a multi-tenancy WordPress environment, where multiple
sites are structured as: /var/www/. Long story short: I want
to put a line in the wp-config.php based on existences of a file in
wp-content (under each site_location, provided by my users) directory,
which I don't actively managed. So, I have this in the template that
generates the wp-config.php file:

|
<%-ifFile.exist?('/var/www/'+@title+'/wp-content/wp-extra-config.php')-%>
require_once(ABSPATH . 'wp-content/wp-extra-config.php');
<%-end-%>
|

where @title is the site_name that comes from a hiera hash. But it's not
working and I think the reason being Puppet checking the existences of
|wp-extra-config.php| file on the master during the compilation, hence
setting it as false, for obvious reason. I cannot have it as a fact,
because of the multi-tenancy and existences of that file varies from
project to project. How do I go around this issue?

-San


I think it's simpler to make PHP do the work because templates are 
evaluated on the master.


if(file_exists('/var/www/<%= @title %>/wp-content/wp-extra-config.php')'))
  require_once(ABSPATH . 'wp-content/wp-extra-config.php');

Or whatever the if PHP syntax would be

Ramin

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/56FAD1E0.1050309%40badapple.net.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] how to check existences of a file in a ERB template?

2016-03-29 Thread Henrik Lindberg

On 29/03/16 12:40, Sans wrote:

Hi Trevor,

I don't think "Templates" are technically executed on the Master -
that's for the client/agents. The asset(s) we define in the template has
to native to the agent. You can say everything gets complied on the
master. Correct me, if I'm wrong.



ERB (as well as EPP) templates are only loaded and evaluated when 
compiling the catalog. They have no role on the agent - it just receives 
the produced text.


Regards
- henrik


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/56FA9D6C.8010303%40puppetlabs.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] how to check existences of a file in a ERB template?

2016-03-29 Thread Sans
Hi Trevor,

I don't think "Templates" are technically executed on the Master - that's 
for the client/agents. The asset(s) we define in the template has to native 
to the agent. You can say everything gets complied on the master. Correct 
me, if I'm wrong.

w.r.t. custom-fact, as I said, it cannot be done, if I understood it 
correctly. I have a hiera hash like this:

wordpress::params::install_dir: '/var/www'
wordpress::client_hash:
'wp007':
client_enabled: true
wp_site_domain: 'wp007.com '

'wp008':
client_enabled: true
wp_site_domain: 'wp008.com '
.

and then in the init.pp, I process the info this way:

$client_hash = hiera_hash('wordpress::client_hash')
create_resources("@wordpress::sites",$client_hash)

where wordpress::sites is a define()type that loops through that array. The 
value (of the fact), in this case, has to change dynamically, on the fly. 
Meaning, has_wp_extra_config has to change during the puppet-run for 
clients, e.g. wp007 and wp008, which I don't think possible with a fact. 

-San


On Tuesday, March 29, 2016 at 10:50:09 AM UTC+1, Trevor Vaughan wrote:
>
> Hi San,
>
> Templates are executed on the master and so it will be checking the 
> existence on the master as written.
>
> You'll need to write a custom fact (they're easy) 
> https://docs.puppetlabs.com/facter/3.1/custom_facts.html. Something like 
> a boolean 'has_wp_extra_config' would be ideal.
>
> Then, in your template, change your line to <%- if @has_wp_extra_config 
> -%> and you should be good to go.
>
> Trevor
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/3dafad56-1209-4b82-80af-66cf36869231%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] how to check existences of a file in a ERB template?

2016-03-29 Thread Sans
Hi Trevor,

I don't think "Templates" are technically executed on the Master - that's 
for the client/agents. The asset(s) we define in the template has to native 
to the agent. You can say everything gets complied on the master. Correct 
me, if I'm wrong.

w.r.t. custom-fact, as I said, it cannot be done, if I understood it 
correctly. I have a hiera hash like this:

wordpress::params::install_dir: '/var/www'
wordpress::client_hash:
'wp007':
client_enabled: true
wp_site_domain: 'abccap-dev.kurtosysweb.com'

'wp008':
client_enabled: true
wp_site_domain: 'abccap-dev.kurtosysweb.com'
.

and then in the init.pp, I process the info this way:

$client_hash = hiera_hash('wordpress::client_hash')
create_resources("@wordpress::sites",$client_hash)

where wordpress::sites is a define()type that loops through that array. The 
value (of the fact), in this case, has to change dynamically, on the fly. 
Meaning, has_wp_extra_config has to change during the puppet-run for 
clients, e.g. wp007 and wp008, which I don't think possible with a fact. 

-San
   
 




The main issue is 


On Tuesday, March 29, 2016 at 10:50:09 AM UTC+1, Trevor Vaughan wrote:
>
> Hi San,
>
> Templates are executed on the master and so it will be checking the 
> existence on the master as written.
>
> You'll need to write a custom fact (they're easy) 
> https://docs.puppetlabs.com/facter/3.1/custom_facts.html 
> .
>  
> Something like a boolean 'has_wp_extra_config' would be ideal.
>
> Then, in your template, change your line to <%- if @has_wp_extra_config 
> -%> and you should be good to go.
>
> Trevor
>
> On Mon, Mar 28, 2016 at 3:44 PM, Sans > 
> wrote:
>
>> Hi there,
>>
>> I'm setting up a multi-tenancy WordPress environment, where multiple 
>> sites are structured as: /var/www/. Long story short: I want 
>> to put a line in the wp-config.php based on existences of a file in 
>> wp-content (under each site_location, provided by my users) directory, 
>> which I don't actively managed. So, I have this in the template that 
>> generates the wp-config.php file: 
>>
>> <%- if File.exist?('/var/www/'+@title+'/wp-content/wp-extra-config.php') 
>> -%>
>> require_once(ABSPATH . 'wp-content/wp-extra-config.php');
>> <%- end -%>
>>
>> where @title is the site_name that comes from a hiera hash. But it's not 
>> working and I think the reason being Puppet checking the existences of 
>> wp-extra-config.php file on the master during the compilation, hence 
>> setting it as false, for obvious reason. I cannot have it as a fact, 
>> because of the multi-tenancy and existences of that file varies from 
>> project to project. How do I go around this issue?
>>
>> -San 
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to puppet-users...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/puppet-users/15dd9afc-a55c-45d3-ab22-ed3ffc68fc3c%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Trevor Vaughan
> Vice President, Onyx Point, Inc
> (410) 541-6699
>
> -- This account not approved for unencrypted proprietary information --
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/708b15ef-c37e-458f-b6b4-2bbb7bc6cbbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] how to check existences of a file in a ERB template?

2016-03-29 Thread Trevor Vaughan
Hi San,

Templates are executed on the master and so it will be checking the
existence on the master as written.

You'll need to write a custom fact (they're easy)
https://docs.puppetlabs.com/facter/3.1/custom_facts.html. Something like a
boolean 'has_wp_extra_config' would be ideal.

Then, in your template, change your line to <%- if @has_wp_extra_config -%>
and you should be good to go.

Trevor

On Mon, Mar 28, 2016 at 3:44 PM, Sans  wrote:

> Hi there,
>
> I'm setting up a multi-tenancy WordPress environment, where multiple sites
> are structured as: /var/www/. Long story short: I want to put
> a line in the wp-config.php based on existences of a file in wp-content
> (under each site_location, provided by my users) directory, which I don't
> actively managed. So, I have this in the template that generates the
> wp-config.php file:
>
> <%- if File.exist?('/var/www/'+@title+'/wp-content/wp-extra-config.php') -
> %>
> require_once(ABSPATH . 'wp-content/wp-extra-config.php');
> <%- end -%>
>
> where @title is the site_name that comes from a hiera hash. But it's not
> working and I think the reason being Puppet checking the existences of
> wp-extra-config.php file on the master during the compilation, hence
> setting it as false, for obvious reason. I cannot have it as a fact,
> because of the multi-tenancy and existences of that file varies from
> project to project. How do I go around this issue?
>
> -San
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/15dd9afc-a55c-45d3-ab22-ed3ffc68fc3c%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699

-- This account not approved for unencrypted proprietary information --

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CANs%2BFoWSAHHzbV%2BpMU2aUX8R33shmBdL58j-wt6mk3bii157kA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] how to check existences of a file in a ERB template?

2016-03-28 Thread Sans
Hi there,

I'm setting up a multi-tenancy WordPress environment, where multiple sites 
are structured as: /var/www/. Long story short: I want to put a 
line in the wp-config.php based on existences of a file in wp-content 
(under each site_location, provided by my users) directory, which I don't 
actively managed. So, I have this in the template that generates the 
wp-config.php file: 

<%- if File.exist?('/var/www/'+@title+'/wp-content/wp-extra-config.php') -%>
require_once(ABSPATH . 'wp-content/wp-extra-config.php');
<%- end -%>

where @title is the site_name that comes from a hiera hash. But it's not 
working and I think the reason being Puppet checking the existences of 
wp-extra-config.php file on the master during the compilation, hence 
setting it as false, for obvious reason. I cannot have it as a fact, 
because of the multi-tenancy and existences of that file varies from 
project to project. How do I go around this issue?

-San 


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/15dd9afc-a55c-45d3-ab22-ed3ffc68fc3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.