Beginner Question: Structure of a full "application"

49 views
Skip to first unread message

Kevin Breit

unread,
Jan 29, 2014, 8:05:37 AM1/29/14
to puppet...@googlegroups.com
I am trying to make Puppet provision an OpenStack node from a base Ubuntu 12.04 install. Unfortunately, I'm new to Puppet and having problems conceptualizing how the programming logic should work. At this time I have a Puppet master and Puppet agent for script development. Here are the steps I expect to have Puppet take:

1. Install and configure NTP
2. Update apt repositories with proper OpenStack Havana PPA
3. Install proper OpenStack packages (probably just openstack-compute and mysql-client, maybe a few others)
4. Develop configuration files based on templates

Step 1 is done as I developed a simple NTP module. Step 2 is where I'm getting caught up. Last night I discovered the puppet-apt module but I'm not quite sure how to call it. I feel like I'm thinking in traditional programming language flow where I can call most anything at any time. In my site.pp there is a node section where I do an "include apt" but beyond that, I don't know how to pass arguments and call functions to the apt module. Do I create a custom manifest for this or include code in the node statement?

Any help is appreciated. Thank you.

jcbollinger

unread,
Jan 29, 2014, 5:31:31 PM1/29/14
to puppet...@googlegroups.com


On Wednesday, January 29, 2014 7:05:37 AM UTC-6, Kevin Breit wrote:
I am trying to make Puppet provision an OpenStack node from a base Ubuntu 12.04 install. Unfortunately, I'm new to Puppet and having problems conceptualizing how the programming logic should work.


You are experiencing an even more fundamental problem: conceptualizing Puppet manifest development as "programming".  You will do yourself a favor by starting from the understanding that manifest development is an exercise in modeling (of the target machine configuration).  Manifests describe properties of the target system, and some elements of how those are related to each other.  The puppet agent figures out the details of getting from here to there.

 
At this time I have a Puppet master and Puppet agent for script development. Here are the steps I expect to have Puppet take:

1. Install and configure NTP


No, you want Puppet to ensure that NTP is installed, and that it is configured in some specific way.  These are some of the details of the model you want to construct.

 
2. Update apt repositories with proper OpenStack Havana PPA


Again, no, you want Puppet to ensure that your nodes' apt sources are configured to include those.

 
3. Install proper OpenStack packages (probably just openstack-compute and mysql-client, maybe a few others)
4. Develop configuration files based on templates



Etc.

 
Step 1 is done as I developed a simple NTP module. Step 2 is where I'm getting caught up. Last night I discovered the puppet-apt module but I'm not quite sure how to call it.


You don't "call" Puppet classes, modules, or resource types.  (But there are functions in Puppet that you can call.)  You use Puppet modules in your manifests by declaring one or more of the classes they define, and/or by declaring instances of one or more of their defined types (just like declaring instances of built-in resource types).

 
I feel like I'm thinking in traditional programming language flow where I can call most anything at any time. In my site.pp there is a node section where I do an "include apt" but beyond that, I don't know how to pass arguments and call functions to the apt module. Do I create a custom manifest for this or include code in the node statement?



As far as I am aware, puppetlabs-apt does not define any functions of its own.  It does provide a defined type or two that are intended for module users.  Instances of these are declared just like resources of any other type.  Examples are presented in the module docs at https://forge.puppetlabs.com/puppetlabs/apt .

Where you should put your declarations is not a question with a clear-cut answer, but for the time being it is reasonable to put them into the appropriate node block.  If you find yourself repeating node block contents (e.g. the same apt::source resources in multiple node blocks) then you should consider wrapping up those duplicate declarations into a class, in a module, so that your nodes just declare the class.

 
Any help is appreciated. Thank you.


There is pretty good DSL documentation available on-line from PuppetLabs.  See http://docs.puppetlabs.com/puppet/3/reference/.  I would recommend to every Puppet user that they should read the "The Puppet Language" section, and at least skim the "Generated References"/"Resource Types" and "Generated References"/"Functions" sections.


John

xav

unread,
Jan 29, 2014, 5:46:46 PM1/29/14
to puppet...@googlegroups.com
Just a pointer here to a bunch of really good OpenStack Puppet modules:

https://github.com/stackforge/puppet-openstack

https://github.com/hastexo/kickstack

There's some gaps, such as HA for controller components, monitoring, etc
- but the structure and ease of use is excellent.

Particularly, for your use case, take a look at Florian's Kickstack
module - I did see a 10 min video where he goes through the use of it,
but I can't find the link to hand now... What I like about the
Kickstack module is the way roles and profiles have been arranged to
make application of intended config fast and easy.

Reply all
Reply to author
Forward
0 new messages