spacedog / puppet-cobbler

Manages cobbler
0 stars 11 forks source link

unclear about whether httpd is a pre-req or this module should create necessary resource #2

Open aleks-mariusz opened 7 years ago

aleks-mariusz commented 7 years ago

I'm writing a module that leverages yours and i've gotten it to start running but it dies at the end with:

Notice: /Stage[main]/Cobbler::Install/Package[cobbler]/ensure: created
Notice: /Stage[main]/Cobbler::Install/Package[syslinux]/ensure: created
Notice: /Stage[main]/Cobbler::Install/Package[syslinux-tftpboot]/ensure: created
Notice: /Stage[main]/Cobbler::Config/File[/etc/cobbler/settings]/content: 
--- /etc/cobbler/settings   2014-12-31 17:01:16.000000000 +0000
+++ /tmp/puppet-file20170123-4358-r2gghe    2017-01-23 19:49:41.112227694 +0000
@@ -1,462 +1,107 @@
 ---
[...]
Info: Computing checksum on file /etc/cobbler/settings
Info: /Stage[main]/Cobbler::Config/File[/etc/cobbler/settings]: Filebucketed /etc/cobbler/settings to puppet with sum 94c2950ce13cc744fbb78f63dbdecabb
Notice: /Stage[main]/Cobbler::Config/File[/etc/cobbler/settings]/content: content changed '{md5}94c2950ce13cc744fbb78f63dbdecabb' to '{md5}e8ef5aa5230c43bbe929afee1e938feb'
Error: Failed to apply catalog: Connection refused - connect(2) for "127.0.0.1" port 80
puppetrun: ERROR: failed (rc=1)

It's unclear whether httpd is actually a prerequisite not mentioned for this module to be used?

I was under the (perhaps naive) assumption that this module would set up an httpd service as part of its run, to have an entire working cobbler environment (since one usually includes httpd as part of the installation normal).

Could you please clarify ?

spacedog commented 7 years ago

Hi @aleks-mariusz,

You need to provide some logic in your profile to make it works:

  1. start httpd service first as this modules uses XMLRPC api to manage cobbler resources
  2. httpd uses proxy_pass modulle to proxy request to cobbler xmlrpc service so cobblerd needs to be running before creating any of cobbler resources
  3. create cobbler resources

cobbler httpd config file goes with rpm package and httpd is installed as dependency so the httpd isn't listed as requirements for that module. That module won't manage httpd service/files for you.. you need another module for that.

aleks-mariusz commented 7 years ago

thanks.. i'm trying to figure out the best way to get this handled..

so i do have another module that manages httpd and should start it.. i included it, so i got a little further before running into this message again.. but i haven't gotten to the point where the cobblerd/httpd service starts yet (shouldn't the class start cobblerd at least?)

does the module, before the catalog is applied, try to run the collection stuff on existing providers to see what's there?

aleks-mariusz commented 7 years ago

So i looked at this some more and I have to ask, is this module only designed to be able to manage already installed cobbler systems perhaps, and not really tested/written to be ran/stood up on a freshly installed system to stand up cobbler? I am not sure if i just missed that in the documentation or if that's not clearly mentioned..

Otherwise it seems like a bug that the createresources, before it gets to the point where it's looking at dependencies, is trying to collect the existing cobbler* resources. A catch 22 for a newly set up system before cobbler has been set up.

How would I bootstrap a new cobbler setup, puppet crashes when the cobbler_* providers make the call trying to collect existing resources:

Debug: Prefetching ruby resources for cobbler_distro
Debug: Storing state
Debug: Stored state in 0.11 seconds
Error: Failed to apply catalog: Connection refused - connect(2) for "127.0.0.1" port 80

We can't create those resources UNTIL httpd is set. As a work-around I would have to split up my parent module (that uses your cobbler module), into a separate the initial setup of cobbler into a separate sub-class and leave the management part of the resources in the main class. But this would cause me to have to run puppet in two phases, one where it sets up cobbler and another later that actually does the management (since using a 'require' keyword on your class makes it pre-check whether there's any existing resources).

Perhaps the cobbler_* providers should catch connection refused and treat that as 0 resources?

spacedog commented 7 years ago

I have a httpd profile that sets up vhost config file for cobbler. I have another profile where I use createresource('cobbler*', ....) functions. In my main module I set the following order:

Class['::cobbler'] -> 
Class['::profile::cobbler::apahce'] ->
Class['::profile::cobbler::objects']

I do cobbler first to make sure that cobbler is installed and configured properly. I hope this will help to build a proper order in your module

aleks-mariusz commented 7 years ago

I tried that, but the provider instances code is getting run when calculating the dependencies, and since it causes puppet to crash, it never gets to the httpd/cobblerd part