This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docpublic:systemes:linux:cfengine3 [2013/07/19 12:31] PROCACCIA [bootstrap client] |
docpublic:systemes:linux:cfengine3 [2013/12/24 15:14] (current) procacci@tem-tsp.eu [references] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== cfengine3 ==== | + | ===== cfengine3 |
===== references ===== | ===== references ===== | ||
Line 18: | Line 18: | ||
* http:// | * http:// | ||
* http:// | * http:// | ||
- | ===== install ===== | + | * https:// |
+ | ===== install | ||
* https:// | * https:// | ||
Line 93: | Line 94: | ||
===== install client ===== | ===== install client ===== | ||
- | here we install manually cfengine package on the client (next we'll do it automatically via cobbler) | + | here we install manually cfengine package on the client (next we'll do it |
< | < | ||
Line 227: | Line 228: | ||
- | ==== Access control ==== | + | ===== Server |
- | in def.cf | + | ==== IP subnets control ==== |
+ | |||
+ | in order to allow clients on from specific subnets , declare our subnets | ||
< | < | ||
Line 248: | Line 251: | ||
< | < | ||
Jul 17 15:21:53 cfengine3 cf-serverd[8890]: | Jul 17 15:21:53 cfengine3 cf-serverd[8890]: | ||
+ | </ | ||
+ | |||
+ | ===== sample site policy ===== | ||
+ | |||
+ | Now that client and server are installed and communicate correctly, we are going to really get some job done with cfengine. | ||
+ | |||
+ | ==== ldap + nfs context ==== | ||
+ | |||
+ | In that sample site / lab auto configuration we want to allow users to connect to client station through ldap authentication and NFS mount of homedirectories. that involves creating / copying files and restart services upon chnages to these files. | ||
+ | |||
+ | ==== classes ==== | ||
+ | |||
+ | we create a promise file to declare our local classes => groups of machines (beware that - are replace with _ for hotsname classes association) | ||
+ | |||
+ | < | ||
+ | [root@cfengine3 masterfiles]# | ||
+ | bundle common disi_classes | ||
+ | { | ||
+ | classes: | ||
+ | |||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== policy ==== | ||
+ | |||
+ | then we translate our needs in terms of cfengine promises in a dedicated promise file for that purpose | ||
+ | |||
+ | < | ||
+ | [root@cfengine3 masterfiles]# | ||
+ | bundle agent disi_policies | ||
+ | { | ||
+ | files: | ||
+ | |||
+ | salle_b01|disi_hosts:: | ||
+ | |||
+ | "/ | ||
+ | copy_from => secure_cp("/ | ||
+ | perms => m(" | ||
+ | |||
+ | b01_02:: | ||
+ | |||
+ | "/ | ||
+ | copy_from => secure_cp("/ | ||
+ | perms => m(" | ||
+ | |||
+ | salle_b01|disi_hosts:: | ||
+ | |||
+ | "/ | ||
+ | copy_from => secure_cp("/ | ||
+ | perms => m(" | ||
+ | classes => if_repaired(" | ||
+ | |||
+ | "/ | ||
+ | link_from => ln_s("/ | ||
+ | |||
+ | |||
+ | commands: | ||
+ | autofs_restart:: | ||
+ | "/ | ||
+ | |||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== bundlesequence ==== | ||
+ | finally we need to tell cfengine server bundlesequence to use our promises above through promises.cf file | ||
+ | |||
+ | < | ||
+ | [root@cfengine3 masterfiles]# | ||
+ | ############################################################################### | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | ############################################################################### | ||
+ | body common control | ||
+ | { | ||
+ | | ||
+ | |||
+ | # Common bundles first for best practice | ||
+ | " | ||
+ | # Design Center | ||
+ | " | ||
+ | # Agent bundles from here | ||
+ | " | ||
+ | |||
+ | # classes / groups de machines | ||
+ | " | ||
+ | # disi policies | ||
+ | " | ||
+ | }; | ||
+ | | ||
+ | # Global common bundles | ||
+ | " | ||
+ | # Control body for all agents | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | # COPBL/ | ||
+ | " | ||
+ | # Design Center | ||
+ | # MARKER FOR CF-SKETCH INPUT INSERTION | ||
+ | " | ||
+ | # User services from here | ||
+ | " | ||
+ | | ||
+ | # classes disi | ||
+ | " | ||
+ | # disi policies | ||
+ | " | ||
+ | }; | ||
+ | | ||
+ | } | ||
+ | ############################################################################### | ||
+ | bundle agent main | ||
+ | { | ||
+ | | ||
+ | any:: | ||
+ | |||
+ | " | ||
+ | comment => "Just a pre-defined policy bundled with the package", | ||
+ | | ||
+ | } | ||
+ | ############################################################################### | ||
+ | </ | ||
+ | |||
+ | ==== directory access rules ==== | ||
+ | |||
+ | note that in cf-disi-policies.cf above we ditribute/ | ||
+ | |||
+ | < | ||
+ | copy_from => secure_cp("/ | ||
+ | </ | ||
+ | / | ||
+ | |||
+ | < | ||
+ | # disi masterdir | ||
+ | " | ||
+ | comment => " | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Now that " | ||
+ | < | ||
+ | [root@cfengine3 masterfiles]# | ||
+ | bundle server access_rules() | ||
+ | { | ||
+ | | ||
+ | any:: | ||
+ | # disi | ||
+ | " | ||
+ | | ||
+ | comment => "Grant access to the policy disi updates", | ||
+ | admit => { " | ||
+ | </ | ||
+ | |||
+ | otherwise you get an error on the client telling you | ||
+ | |||
+ | < | ||
+ | verbose: Server returned error ' Unspecified server refusal (see verbose server output)' | ||
+ | 2013-07-11T18: | ||
+ | </ | ||
+ | |||
+ | ==== secure_cp ==== | ||
+ | |||
+ | I first used remote_cp instaed of secure_cp to ciopy files, howerver when the file changed on the server it wasn't replaced on the client because it was more recent ! | ||
+ | |||
+ | indeed from libraries/ | ||
+ | |||
+ | < | ||
+ | body copy_from secure_cp(from, | ||
+ | { | ||
+ | source | ||
+ | servers | ||
+ | compare | ||
+ | encrypt | ||
+ | verify | ||
+ | } | ||
+ | |||
+ | ## | ||
+ | |||
+ | body copy_from remote_cp(from, | ||
+ | { | ||
+ | servers | ||
+ | source | ||
+ | compare | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | and from https:// | ||
+ | |||
+ | |||
+ | ===== bootstrap cfengine from cobbler ===== | ||
+ | |||
+ | we use cobbler to install +100 stations (fedora) via PXEboot + kickstart. | ||
+ | in order to fully automate the install + configuration of those stations we need to tell cobbler in its post install process to install cfengine and bootstrap the client station on the cfengine server | ||
+ | |||
+ | reference | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | in our kickstart template we call 2 snippets to do the job | ||
+ | < | ||
+ | [root@cobbler2 cobbler]# grep disi kickstarts/ | ||
+ | $SNIPPET(' | ||
+ | $SNIPPET(' | ||
+ | </ | ||
+ | |||
+ | those snippet repectlively install cfengine and then bootstrap the client the easy way since the version 3.2.0, if you are willing to automatically accept keys from the clients , cf http:// | ||
+ | |||
+ | < | ||
+ | [root@cobbler2 snippets]# cat disi_post_install_packages | ||
+ | yum -y install cfengine-community | ||
+ | yum -y install autofs | ||
+ | |||
+ | [root@cobbler2 snippets]# cat disi_cfengine_bootstrap | ||
+ | # start cfengine3 registration | ||
+ | / | ||
+ | # end cfengine3 registration | ||
</ | </ |