Puppet combined with SVN version control system for centralized backup and recovery of versions

Source: Internet
Author: User
Tags svn client version control system tortoisesvn collabnet

First, Introduction

By installing and deploying the Puppet/C/S model, puppet server manages the entire lifecycle of all the controllers: from initialization to software upgrades, from profile creation to test deployment, from system maintenance to server migrations, and more. Puppet is able to continuously interact with the controlled machine to enable timely detection and update of the configuration files. In conjunction with the SVN version control system, puppet can save the currently running environment in version to the SVN version control system prior to the update, making it easy to recover later through puppet update errors or to rollback to one of the previous environments.

Ii. Introduction of the environment
  sequence     server type                     Version/IP parameter 1   &N Bsp puppetmaster         RHEL6.4 x86_64 (192.168.100.110) 2    puppetagent       & nbsp     RHEL5.8 x86_64 (192.168.100.111) and RHEL5.7 x86_64 (192.168.100.112) 3    SVN service side     R HEL6.4 x86_64 (192.168.100.110) 4    SVN service side     RHEL6.4 x86_64 (192.168.100.110) and Windows 8.1 x86_ 64 (192.168.100.2) Number       type       hostname/software name     System/software version                     Other information 1    software    subversion        1 .6.11-7    rpm                 Package 2    software   &N Bsp TortoiseSVN        1.8.2.24708-x64-svn-1.8.3        msi  
III. deployment Process 1 SVN server-side deployment

1.1 Installing related Packages

[[email protected] ~]# yum install subversion[[email protected] ~]# svnserve –version  #通过查看版本验证安装是否成功svnserve, version 1.6.11 (r934486)   compiled Apr 12 2012, 11:09:11Copyright (C) 2000-2009 CollabNet.Subversion is open source software, see http://subversion.tigris.org/This product includes 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 Creating the first repository

[[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 to SVN server via APACHE+SSL security authentication

2.1 Installing related Packages

[[email protected] ~]# yum install httpd httpd-devel mod_dav_svn

2.2 Creating an SVN virtual host

[[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 Creating the SVN permissions configuration file

[[email protected] svndata]# vim puppet/conf/authz  [groups]admin = puppet[admin:/]@admin = rw[/]* = r[$name:/]test = rw">>/svndata/puppet/conf/authz2.4    创建用户名及密码并设置相应权限[[email protected] ~]# /usr/bin/htpasswd -c /svndata/puppet/conf/authfile puppet #创建SVN服务器账户puppet密码为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 Configuring 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 via browser

[[email protected] svndata]# /etc/rc.d/init.d/httpd restart #重启httpd服务http://192.168.100.110:8142/svndata/

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-1.png "/>SVN version control test Interface

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-2.png "/>SVN version control test Interface

2.7 Accessing tests from other Linux nodes

[[email protected] ~]# svn checkout http://192.168.100.110:8142/svndata/ /mnt/authentication Realm: < Http://192.168.100.110:8142> Puppet Subversion repositorypassword for ' root ': Authentication realm: 

2.8 Accessing tests through the Windows client TortoiseSVN

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-3.png "/>SVN version control test Interface

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-4.png "/>SVN version control test Interface

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-5.png "/>SVN version control test Interface

Note: because it is also an import version, the contents of the view are empty

3 Consolidating puppet server side

3.1 Importing the puppet Server module catalog into the repository

[[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, they can also be imported in the following ways

[[email protected] ~]# svn import /etc/puppet/environments/testing  file:///svndata/puppet -m "Puppet Initial repository"

3.2 Access to SVN server via IE browser

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-6.png "/>SVN version control test Interface

3.3 Checkout the latest repository to local via Windows client TortoiseSVN

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-7.png "/>SVN version control test Interface

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-8.png "/>SVN version control test Interface

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-9.png "/>SVN version control test Interface

3.4     Delete the Puppetserver-side testing directory and export the data from the repository

[[email protected] ~]# cd /etc/puppet/environments/testing/[[email protected] testing]# rm -rf *  #删除之前建议备份[[email protected] testing]# svn checkouthttp://192.168.100.110:8142/svndata/puppet  /etc/puppet/environments/testing Authentication realm: 
4 Deploying SVN Hooks

4.1 Setting Pre-commit

Setting the Pre-commit hook can submit a file to the SNV server before the puppet syntax is checked, the syntax passes the commit succeeds, and the syntax error commits the failure.

[[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-comm It hook to check Puppet syntax-pp files# Modified from http://mail.madstop.com/pipermail/puppet-users/2007-March/002 034.html# Access http://projects.puppetlabs.com/projects/1/wiki/puppet_version_controlREPOS= "$" txn= "$" tmpfile= ' Mktemp ' export home=/svnlook=/usr/bin/svnlook$svnlook changed-t "$TXN" "$REPOS" | awk '/^[^d].*\.pp$/{print $} ' | While read Linedo     $SVNLOOK cat-t "$TXN" "$REPOS" "$line" > $tmpfile    if [$?-ne 0]   & Nbsp;then        echo "warning:failed to Checkout $line" >&2    fi#    pup Pet--color=false--confdir=/etc/puppet--vardir=/var/lib/puppet--parseonly--ignoreimport $tmpfile >>/var/log /puppet/svn_pre-commit.log 2>&1   &NBSP;p uppet--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 &N Bsp  fidoneres=$?rm-f $tmpfileif [$res-ne 0]then    exit $RESFI

4.2 Setting Post-commit

Set the Post-commit hook after the file is correctly submitted to the SVN server, the puppetmaster module directory /etc/puppet/environments/testing will automatically update the latest repository from the SNV server to local.

#!/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 Side deployment test

5.1 Local Testing

1) Export the version database file to local

[[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, at this time the version of the repository version plus 1

[[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; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-12.png "/>SVN version Control test interface

650) this.width=650; "alt=" SVN version Control Test Interface "src=" Http://kisspuppet.com/img/svn-puppet-13.png "/>SVN version Control test interface

This article is from the "Fire" blog, so be sure to keep this source http://fire7758.blog.51cto.com/993821/1659853

Puppet combined with SVN version control system for centralized backup and recovery of versions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.