Re: [Puppet Users] r10k and dynamic environments

2014-03-26 Thread Jacob Fleming-Gale
Hi Steven,

r10k does not accept Puppet variables or facts as it run's outside of
Puppet, the confusion is because Gary's example is using the awesome r10k
puppet module by Zack to setup the r10k configuration, hence it can use the
puppet facts or variables to create and manage the /etc/r10k.yaml
configuration file.

The created r10k configuration file should something like the example
below, which deploys environment directories with manifests and modules to
/etc/puppetlabs/puppet/environments and environmental hieradata to
/etc/puppetlabs/puppet/hieradata


# The location to use for storing cached Git repos
:cachedir: '/var/cache/r10k'

# A list of git repositories to create
:sources:
  # This will clone the git repository and instantiate an environment per
  # branch in /etc/puppetlabs/puppet/environments
  :local:
remote: 'git://localhost/puppet-environments-nohiera.git'
basedir: '/etc/puppetlabs/puppet/environments'

  :hieradata:
remote: 'git://localhost/puppet-hieradata.git'
basedir: '/etc/puppetlabs/puppet/hieradata'

:purgedirs:
 - '/etc/puppetlabs/puppet/environments'




Regards
Jacob







On 26 March 2014 17:40, Steven James  wrote:

> Hi all.
>
> I'm trying to get r10k to pull down a hieradata repo, and deploy it to the
> appropriate
>
> I've added the following section to /etc/r10k.yaml
>
>  hda-hieradata:
>
> remote: 'ssh://g...@stash.blah.com.au/puppet/blah-hieradata.git'
>
> basedir: "/etc/puppet/environments/${::environment}/hieradata/"
>
> prefix: true
>
>
> I also tried - basedir: "{::confdir}/hiera" - which also didn't work.
>
>
> Is r10k able to use variables in the basedir?
>
>
> This post would suggest that it may be possible;
>
>
> http://garylarizza.com/blog/2014/03/07/puppet-workflow-part-3b/
>
>
> e.g. 'basedir'
> => "${::settings::confdir}/hiera",
>
>
> Any thoughts from anybody?
>
>
> Regs,
>
>
> Steven
>
> --
> 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/CAB_ORUsw53%2B3MrnixWXUxoO5G2RZgqjymNNPu2zs0WB-LTNbdQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOQMBgxRKZkzHxsB0hpUXBWkmJq3oXOWyd-QQ8N0GR%3D6Yo24Ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError:

2014-01-19 Thread Jacob Fleming-Gale
Hi Jyotir,

The filename and the defined type names need to be the same, you can either
rename the define to accounts::system_users or rename the file to system.pp

Jacob


On 20 January 2014 14:52, jyotir bhandari  wrote:

> Hi
>
> I am getting error when i try to add system user including fields
> mentioned in system_user.pp, if I manually mention all the fields in
> init.pp, it just works fine.
>
> [root@server accounts]# pwd
> /etc/puppet/modules/accounts
> [root@server accounts]# tree
> .
> `-- manifests
> |-- init.pp
> `-- system_users.pp
>
> 1 directory, 2 files
>
>
> *init.pp*
>
> class accounts {
>@accounts::system { 'demo':
>comment => 'demo users',
>password => 'fndjsafjdashbjfsdhj',
>}
> }
>
> *system_users.pp*
>
> define accounts::system ($comment,$password){
> user { $title:
>ensure => 'present',
>shell => '/bin/bash',
>managehome => true,
>comment => $comment,
>password => $password,
>  }
> }
>
>
> Jyotir
>
>
> --
> 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/b0655764-7abb-481b-a49a-cd2410b8bc20%40googlegroups.com
> .
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOQMBgyQympH2rjhqZCnsTbguUPCVBz1ccwJdUk_%2BsFg69WFRg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] matching all current "ipaddress_ethX" facts

2013-12-02 Thread Jacob Fleming-Gale
the has_ip_network function that's part of puppet-stdlib may help, it
matches all interfaces against a network address and return a boolean if a
match is found.

https://github.com/puppetlabs/puppetlabs-stdlib#has_ip_network


On 3 December 2013 04:18, jcbollinger  wrote:

>
>
> On Friday, November 29, 2013 5:46:11 AM UTC-6, cko wrote:
>>
>> Thanks, i think i got something here:
>>
>> Facter.add("ip_prodlan") do
>>confine :kernel => "Linux"
>>setcode do
>>   Facter::Util::Resolution.exec("/sbin/ifconfig | /bin/grep
>> '20.20.\\|30.31.\\|200.30.80.\\|120.' | /bin/awk '{ print $2 }' |
>> /bin/cut -d':' -f2 | /usr/bin/head -n1")
>>end
>> end
>>
>>
>
> I really think that's a sub-optimal approach.  Facter is already providing
> all the facts you need for this job.  You ought to be analyzing those
> instead of creating a new one.  Here's an outline:
>
>1. Obtain a list of all defined network interfaces for the target node
>by splitting the value of the $::interfaces fact around commas.
>2. For each interface name test the value of the
>$::ipaddress_ fact against the subnet mask(s) of interest.
>3. Take appropriate action and/or return a result.
>
> That should ultimately be done in a custom function, but as I said, it
> could be prototyped via an inline template.
>
>
>
>> I'm currently using the custom fact to print the production LAN ip
>> address in /etc/motd .
>> It usually returns the correct value. But in some cases the "puppet agent
>> -t" command changes the file in a *different* way than "service puppet
>> restart" does. Any idea?
>>
>>
>
> If performing a catalog run via "puppet agent -t" exhibits inconsistent
> behavior then I have trouble believing that forcing one via "service puppet
> restart" is always consistent.  Do note, by the way, that the latter is a
> rather rough way to force a catalog run -- if the agent is running in
> daemon mode then you can trigger an immediate catalog run by sending it
> SIGUSR1.
>
> Perhaps your interfaces are going up and down.  If the key interface
> happens to be down when Facter runs then its IP address probably will not
> be reported by ifconfig, so you might not see any of the subnets you're
> looking for.
>
>
>
>> Another question:
>>
>> I want my custom fact to do something like this:
>> if the "Resolution.exec" returns 0 (nothing) then ip_prodlan should use
>> the value of the fact "$ipaddress".
>> Is it possible to do something like this?
>>
>>
>
> Probably, but don't.  Perform this sort of test and data selection in your
> manifests, not in Facter.
>
>
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/b3166eb0-3fc2-4688-ac78-ad5ff5dd6c4e%40googlegroups.com
> .
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOQMBgyaALZT6FSpq2OCqgsqRTnv4eDvZryg0JEYWrgX2Nf_wg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Problems with Fact returning the version of an installed RPM.

2013-11-15 Thread Jacob Fleming-Gale
Hi Richie,

Using the iptables_version fact thats part of the puppetlabs firewall
module, you can tweak that to change the command to return the rpm version
as in Dan's example.

The below code will return the full version string for the sqlite rpm

Jacob


Facter.add(:sqlite_version) do
  confine :kernel => :linux
  setcode do
version = Facter::Util::Resolution.exec('rpm -q --qf
\'%{version}-%{release}-%{arch}\' sqlite')
if version
  version.match(/^\d+.*$/).to_s
else
  nil
end
  end
end


On 16 November 2013 00:24, Dan White  wrote:

> OK.  Time for a possibly silly question:
>
> How are you getting the name of the RPM into the Ruby code ?
>
>
> “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)
>
> --
> *From: *"Richie Rees" 
> *To: *puppet-users@googlegroups.com
> *Sent: *Friday, November 15, 2013 8:57:29 AM
> *Subject: *Re: [Puppet Users] Problems with Fact returning the version of
> an installed RPM.
>
>
> Thanks Ygor, gold stars for you and pints of beer, unfortunately this
> still doesn't return the version to the fact. Do i have to pass the
> resulting string to a variable and then pass the variable back ?
>
>
>
> On Friday, 15 November 2013 12:46:13 UTC, Ygor wrote:
>>
>> http://www.rpm.org/wiki/Docs/QueryFormat
>>
>> rpm -qa --queryformat '%{version}\n' rpm_name
>>
>> “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)
>>
>> --
>> *From: *"Richie Rees" 
>> *To: *puppet...@googlegroups.com
>> *Sent: *Friday, November 15, 2013 6:31:13 AM
>> *Subject: *[Puppet Users] Problems with Fact returning the version of an
>> installed RPM.
>>
>> Hi,
>>
>> Have written what I think is a simple fact to return the version of an
>> installed RPM, but when I use the returned variable its blank so perhaps
>> someone can point me in the write direction, or somone might know a better
>> way to do this. Here is the fact :-
>>
>> require 'facter'
>> Facter.add('rpmbversion') do
>>   setcode do
>> Facter::Util::Resolution.exec("rpm -qia rpm_name | grep Version | sed
>> 's/Version : //g' |cut -f1-5 -d' '")
>>   end
>> end
>>
>>
>> Thanks in Advance :)
>>
>> Richie.
>>
>> --
>> 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/3c1bbea6-9333-46d3-9f4e-c49206cc284d%40googlegroups.com
>> .
>> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/814610a1-b722-4834-8fe7-af7650f25142%40googlegroups.com
> .
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/493959620.4560965.1384525444271.JavaMail.root%40sz0126a.westchester.pa.mail.comcast.net
> .
>
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOQMBgzkMVEVNcv-nR9yMMAR52eC0nqUCNcCqponB45Hoq%2BuMg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Firewall Issues

2013-11-05 Thread Jacob Fleming-Gale
Hi Danny,

Are you able to post the contents of the classes containing the firewall
resources?

Jacob

On Wednesday, November 6, 2013, Danny Roberts wrote:

> We are using the puppetlabs-firewall module (
> https://forge.puppetlabs.com/puppetlabs/firewall) and we were having the
> issue where by the rules would cause the client to lose connectivity on
> it's first run. We solved these issues using the advise found here:
> https://github.com/puppetlabs/puppetlabs-firewall/issues/239#issuecomment-26443579
>
> But no we are having an issue in that our "pre" rules do not get applied
> even on successive runs of puppet. Our logic for firewall in site.pp is:
>
> class firewall-myrules {
>
> Firewall {
> before  => Class['my-firewall-base::post'],
> require => Class['my-firewall-base::pre'],
> }
>
> class { ['my-firewall-base::pre', 'firewall', 
> 'my-firewall-base::post']: }
> ->
> resources { 'firewall': purge => true }
> }
>
> Any ideas what might be causing these issues?
>
>  --
> 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  'cvml', 'puppet-users%2bunsubscr...@googlegroups.com');>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/7d308d7d-fdbe-46e4-8f93-031a7cd986e5%40googlegroups.com
> .
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOQMBgw-wgBhkrniZLEzwxa4wuZA67euMKf6pohYmiE36vt6_g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Puppet Templates to cope with potential multiple sessions settings in the config file

2013-11-04 Thread Jacob Fleming-Gale
Hi Richie,


There's a few options available with the Ruby ERB templating in Puppet,
depending on how you want to control the output, these pages are a good
introduction to ERB and Puppet.

  http://docs.puppetlabs.com/guides/templating.html
  http://docs.puppetlabs.com/learning/templates.html

Here's a few quick examples for you, based on your question.


option one: provide an array of all the component numbers required.

components = ['1','2','3']
~~~
<% @components.each { |item| -%>
LAUNCH_STRING.Component<%= item %>="Blah"
PROCESS_FOOTPRINT.Component<%= item %>-"Blah"

<% } -%>
~~~


option two: provide the number of components required

components = 4
~~~
<% (1..@components).each { |item| -%>
LAUNCH_STRING.Component<%= item %>="Blah"
PROCESS_FOOTPRINT.Component<%= item %>-"Blah"

<% } -%>


option three: provide an array of component names, the component number is
extracted by index position in the array.

components = ['blah', 'Blah', 'blaH']
~~~
<% @components.to_enum.with_index(1).each { |item, index| -%>
LAUNCH_STRING.Component<%= index %>="<%= item %>"
PROCESS_FOOTPRINT.Component<%= index %>-"<%= item %>"

<% } -%>
~~~


Regards
Jacob


On 4 November 2013 21:31, Richie Rees  wrote:

> Hi,
>
> Here is my dilemma,  have a class that installs an rpm then copies over
> the configuration files. Static files are published as files, variable
> files are published using templates with variables provided from foreman
> smart variable.  The binaries being installed can be used to create
> multiple instances of the same application based on a session id. So if you
> put in three instances in the config file it will launch three instances,
> so it would look like this :-
>
> LAUNCH_STRING.Component1="Blah"
> PROCESS_FOOTPRINT.Component1-"Blah"
>
> LAUNCH_STRING.Component2="Blah"
> PROCESS_FOOTPRINT.Component2-"Blah"
>
> LAUNCH_STRING.Component3="Blah"
> PROCESS_FOOTPRINT.Component3-"Blah"
>
> The problem is how can I recursively add these to the template file from
> an integer variable based on the number of sessions required. I remember
> seeing you could do this but now I have gone back to find it all my
> "googling" turns up how to recursively copy directories over. I hope that
> explanation is clear enough.
>
> Thanks,
>
> Richie.
>
> --
> 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/73498c38-3f7f-4c31-8707-13cd38e7f17d%40googlegroups.com
> .
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAOQMBgx5jwUeRQq%2BL9Ko77s9ozkdj-S4kVRb%3DQtKjyXx04LmPA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.