I. Introduction
By installing and deploying the puppet C/S model, the puppet server can manage the entire lifecycle of all controlled hosts: from initialization to software upgrade, from configuration file creation to test deployment, from system maintenance to server migration, etc. Puppet can interact with the controlled machine continuously, so as to detect and Update Configuration files in a timely manner. In combination with the SVN version control system, puppet can save the currently running environment to the SVN version control system by version before the update, this makes it easy for you to quickly recover from a puppet update error or to roll back to a previous environment.
II. Environment Introduction
No. server type version/IP parameter 1 puppetmaster rhel6.4 release (192.168.100.110) 2 puppetagent rhel5.8 x86_64 (release) and rhel5.7 x86_64 (release) 3 SVN service rhel6.4 x86_64 (192.168.100.110) 4 SVN service rhel6.4 x86_64 (192.168.100.110) and Windows 8.1 x86_64 (192.168.100.2) serial Type host name/software name system/software version additional information 1 software subversion 1.6.11-7 RPM package 2 software tortoisesvn 1.8.2.24708-x64-svn-1.8.3 MSI
Iii. deployment process 1 SVN server deployment
1.1 install related software packages
[[Email protected] ~] # Yum install subversion [[email protected] ~] # Svnserve-version # Check whether the installation is successful through version Verification svnserve, version 1.6.11 (r93420.) compiled Apr 12 2012, 11: 09: 11 Copyright (c) 2000-2009 collabnet. subversion is open source software, see http://subversion.tigris.org/This Product Development DES software developed by collabnet (http://www.Collab.Net /). the following repository back-end (FS) modules are available: * fs_base: module for working with a Berkeley dB repository. * fs_fs: module for working with a plain file (fsfs) repository. cyrus SASL authentication is available.
1.2 create the first version Library
[[email protected] ~]# mkdir /svndata[[email protected] ~]# svnadmin create /svndata/puppet[[email protected] ~]# ll /svndata/puppet/total 24drwxr-xr-x 2 root root 4096 Oct 22 13:29 confdrwxr-sr-x 6 root root 4096 Oct 22 13:29 db-r--r--r-- 1 root root 2 Oct 22 13:29 formatdrwxr-xr-x 2 root root 4096 Oct 22 13:29 hooksdrwxr-xr-x 2 root root 4096 Oct 22 13:29 locks-rw-r--r-- 1 root root 229 Oct 22 13:29 README.txt
2. Access the svn server through Apache + SSL Security Authentication
2.1 install related software packages
[[email protected] ~]# yum install httpd httpd-devel mod_dav_svn
2.2 create a SVN VM
[[email protected] svndata]# vim /etc/httpd/conf.d/subversion.confLoadModule dav_svn_module modules/mod_dav_svn.soLoadModule authz_svn_module modules/mod_authz_svn.soListen 8142<VirtualHost *:8142><Location /svndata>DAV svnSVNListParentPath onSVNPath "/svndata/puppet"AuthType BasicAuthName "Subversion repository"AuthUserFile "/svndata/puppet/conf/authfile"#AuthzSVNAccessFile /svndata/puppet/conf/svn-acl-confRequire valid-userSVNAutoversioning onModMimeUsePathInfo on</Location></VirtualHost>
2.3 create a SVN permission configuration file
[[Email protected] svndata] # Vim puppet/CONF/authz [groups] admin = puppet [admin:/] @ admin = RW [/] * = R [$ Name: /] test = RW ">/svndata/puppet/CONF/authz2.4 create a user name and password and set the corresponding permissions [[email protected] ~] #/Usr/bin/htpasswd-C/svndata/puppet/CONF/AuthFile Puppet # create a SVN server account puppet with the password redhatnew password: redhatre-type new password: redhatadding password for user puppet [[email protected] ~] # Chown Apache/svndata/puppet-R [[email protected] ~] # Echo "puppet = RedHat">/svndata/puppet/CONF/passwd
2.5 configure SVN Service Information
[[email protected] svndata]# vim /svndata/puppet/conf/svnserve.conf [general] anon-access = noneauth-access = writepassword-db = /svndata/puppet/conf/passwdauthz-db = /svndata/puppet/conf/authzrealm = puppet Repository
2.6 test access through a browser
[[Email protected] svndata] #/etc/rc. d/init. d/httpd restart # restart the HTTPd service http: // 192.168.100.110: 8142/svndata/
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-1.png "alt =" SVN version control test interface "/> SVN version control test interface
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-2.png "alt =" SVN version control test interface "/> SVN version control test interface
2.7 access the test through other Linux nodes
[[email protected] ~]# svn checkout http://192.168.100.110:8142/svndata/ /mnt/Authentication realm:
2.8 test access through Windows client tortoisesvn
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-3.png "alt =" SVN version control test interface "/> SVN version control test interface
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-4.png "alt =" SVN version control test interface "/> SVN version control test interface
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-5.png "alt =" SVN version control test interface "/> SVN version control test interface
Note:Because the import version is also used, the content to be viewed is empty.
3 integrate puppet Server
3.1 import the puppet Server Module Directory to the version Library
[[email protected] ~]# svn import /etc/puppet/environments/testinghttp://192.168.100.110:8142/svndata/puppet -m "Puppet Initial repository" Authentication realm:
Note:Because the svn server and puppetserver are on the same server, you can also import them using the following methods:
[[email protected] ~]# svn import /etc/puppet/environments/testing file:///svndata/puppet -m "Puppet Initial repository"
3.2 access the svn server through IE browser
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-6.png "alt =" SVN version control test interface "/> SVN version control test interface
3.3 Use Windows client tortoisesvn Checkout's latest version library to local
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-7.png "alt =" SVN version control test interface "/> SVN version control test interface
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-8.png "alt =" SVN version control test interface "/> SVN version control test interface
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-9.png "alt =" SVN version control test interface "/> SVN version control test interface
3.4 Delete the puppetserver testing directory and export the data in the version Library
[[Email protected] ~] # Cd/etc/puppet/environments/testing/[[email protected] Testing] # rm-RF * # we recommend that you back up [[email protected] Testing] # SVN checkouthttp: // 192.168.100.110: 8142/svndata/puppet/etc/puppet/environments/testing authentication realm: 4. Deploy SVN hooks
4.1 set pre-commit
Set the pre-commit hook to check the puppet syntax before submitting the file to the SNV server. If the syntax is passed, the file is submitted successfully. If the syntax is incorrect, the file fails to be submitted.
[[email protected] hooks]# chmod 774 pre-commit^C[[email protected] hooks]# cp pre-commit.tmpl pre-commit[[email protected] hooks]# chmod 774 pre-commit [[email protected] hooks]# vim pre-commit #!/bin/sh# SVN pre-commit hook to check Puppet syntax for .pp files# Modified from http://mail.madstop.com/pipermail/puppet-users/2007-March/002034.html# Access http://projects.puppetlabs.com/projects/1/wiki/puppet_version_controlREPOS="$1"TXN="$2"tmpfile=`mktemp`export HOME=/SVNLOOK=/usr/bin/svnlook$SVNLOOK changed -t "$TXN" "$REPOS" | awk ‘/^[^D].*\.pp$/ {print $2}‘ | while read linedo $SVNLOOK cat -t "$TXN" "$REPOS" "$line" > $tmpfile if [ $? -ne 0 ] then echo "Warning: Failed to checkout $line" >&2 fi# puppet --color=false --confdir=/etc/puppet --vardir=/var/lib/puppet --parseonly --ignoreimport $tmpfile >>/var/log/puppet/svn_pre-commit.log 2>&1 puppet --color=false --confdir=/etc/puppet --vardir=/var/lib/puppet --parser --ignoreimport $tmpfile >>/var/log/puppet/svn_pre-commit.log 2>&1 if [ $? -ne 0 ] then echo "Puppet syntax error in $line." >>/var/log/puppet/svn_pre-commit.log 2>&1 exit 2 fidoneres=$?rm -f $tmpfileif [ $res -ne 0 ]then exit $resfi
4.2 set post-commit
Set the post-commit hook to the puppetmaster Module Directory after the file is correctly submitted to the svn server./etc/puppet/environments/testing
The latest version library is automatically updated from the SNV server to the local device.
#!/bin/sh# POST-COMMIT HOOKREPOS="$1"REV="$2"#mailer.py commit "$REPOS" "$REV" /path/to/mailer.confexport LANG=en_US.UTF-8SVN=/usr/bin/svnPUPPET_DIR=/etc/puppet#/usr/bin/svn up /etc/puppet -non-interactive$SVN update $PUPPET_DIR --username puppet --password 123.com >>/var/log/puppet/svn_post-commit.log
5 SVN client deployment test
5.1 local test
1) Export the version database file to the local device.
[[email protected] ~]# svn checkout file:///svndata/puppet /puppet/puppet
2) create and add new directories and files
[[email protected] puppet]# svn add ssh
3) Submit the modified file to the svn server. In this case, add version 1 to the version library.
[[email protected] .svn]# svn commit -m "add ssh modules" /puppet/puppet/*
5.2 remote testing (Linux)
[[email protected] svndata]# svn checkout http://172.16.200.100/svndata/ /mnt/
5.3 client tortoisesvn test (Windows)
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-12.png "alt =" SVN version control test interface "/> SVN version control test interface
650) This. width = 650; "src =" http://kisspuppet.com/img/svn-puppet-13.png "alt =" SVN version control test interface "/> SVN version control test interface
Return to the main directory for communication:
Public Account: puppet2014You can search and join, or scan the following QR code to join
650) This. width = 650; "src =" http://kisspuppet.com/img/weixin.jpg "alt =" Public Account "/> Public Account
QQ chat group: 296934942
650) This. width = 650; "src =" http://kisspuppet.com/img/contact1.jpg "/>
This article is from the "www.kisspuppet.com" blog, please be sure to keep this source http://dreamfire.blog.51cto.com/418026/1566034
Puppet extension 7-Integration of puppet code and Version Control System