configi.old icon indicating copy to clipboard operation
configi.old copied to clipboard

getting started guide

Open josephholsten opened this issue 8 years ago • 12 comments
trafficstars

I'd love to start playing with configi, noticed there isn't an obvious tutorial, introduction or getting-started-guide on http://configi.org

I think it would be great to at least say how to run http://configi.org/#example-policy

I expect most folks would also want a little more guidance than http://configi.org/modules/modules/template.html has.

I'd love to throw together a doc showing a standard "deployment" pattern:

  • install package
  • template a config
  • start a service
  • add a crontab

and "user" pattern:

  • add group
  • add users
  • set ssh keys
  • set passwords
  • manage sudoers file

Does that sound useful?

josephholsten avatar Sep 13 '17 00:09 josephholsten

👍

golgote avatar Sep 13 '17 06:09 golgote

Hello!

Indeed it's going to be useful. Just ask here if you have questions or if you encounter any problems.

Thank you very much.

tongson avatar Sep 14 '17 16:09 tongson

Is a simple make supposed to generate the compiled cfg-agent? I'm seeing a bin/cfg-agent.lua, but not the compiled form.

josephholsten avatar Sep 14 '17 16:09 josephholsten

Change the DEFAULT_GOAL in the top-level Makefile to release. That should compile the executable.

tongson avatar Sep 15 '17 04:09 tongson

Hmm, where's the best place to document that for regular users? A README? The download page?

josephholsten avatar Sep 15 '17 05:09 josephholsten

The DEFAULT_GOAL was/should be release. I held off too long for 2.0.0. I will change that now.

... and done.

tongson avatar Sep 15 '17 05:09 tongson

awesome, on to the next!

so I thought I'd see what happened when I ran the example policy on my ubuntu box:

file.directory"/tmp/dir"{
  comment = "Create directory if running on Gentoo",
  context = fact.osfamily.gentoo,
     mode = 0700,
   notify = "touch"
}

yum.present"mtr"{
  context = fact.osfamily.centos
}

file.absent"/tmp/dir"{
  notify = "touch"
}

file.touch"/tmp/dir"{
  comment = "Handle 'touch' notifications. This is only executed once.",
   handle = "touch"
}

And I'm seeing:

$ cfg-agent -f policy.lua 
[string "file.directory"/tmp/dir"{..."]:3: attempt to index a function value (field 'osfamily')
stack traceback:
	[string "file.directory"/tmp/dir"{..."]:3: in main chunk
	(...tail calls...)
	[string "cfg-core.cli"]:136: in function 'cfg-core.cli.main'
	[string "cfg-core.cli"]:285: in function 'cfg-core.cli.opt'
	[string "bin.cfg-agent"]:22: in local 'func'
	[string "cfg-agent"]:36: in main chunk

My lua is a bit rusty, do I need to explicitly call the fact function? Am I supposed to set fact myself?

Also, it appears http://configi.org/reference/factid/ will need some love after I'm done here ;-)

josephholsten avatar Sep 15 '17 05:09 josephholsten

ah, $ cfg-agent -F -f policy.lua!

josephholsten avatar Sep 15 '17 05:09 josephholsten

one thing I'm noticing: occasionally I get what appear to be complete hangs. With -v, I get as far as Applying policy: cfg/policy.lua and then nothing. Not seeing any logging or process death with a SIGTERM.

pstree seems to indicate sadness coming from dpkg-preconfigure:

$ pstree 24594
cfg-agent───apt-get───sh───dpkg-preconfigu─┬─dpkg-preconfigu
                                           ├─postfix.config.
                                           └─whiptail

josephholsten avatar Sep 15 '17 07:09 josephholsten

Sadly, I haven't tested in Ubuntu/Debian recently.

I'll fire up a Debian container for testing.

tongson avatar Sep 15 '17 07:09 tongson

no worries, it seems to be from the mutt package.

BTW, I've been looking around at other curricula and I'm going to start with a straightforward port of https://learn.chef.io/tracks/infrastructure-automation.

I'm also considering making this happen inside a docker container, so if there's a platform you're most comfortable with, I can just use that.

josephholsten avatar Sep 15 '17 08:09 josephholsten

Sound good.

About needing to pass -F. There's a bug that's requiring the factid module when it shouldn't be. I'll look into that.

tongson avatar Sep 20 '17 05:09 tongson