注:本文侧重于pupput使用git版本控制在线上环境的部署步骤详解。
1:线上puppet加入git版本控制
详细步骤:
pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/environment] root@pts/0 # git init ; cd ..; git clone --bar environment /var/puppet/environment.git Initialized empty Git repository in /etc/puppet/multi-environment/yydev/environment/.git/ Initialized empty Git repository in /var/puppet/environment.git/ warning: You appear to have cloned an empty repository. pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/application] root@pts/0 # git init Initialized empty Git repository in /etc/puppet/multi-environment/yydev/application/.git/ warning: You appear to have cloned an empty repository.
将项目添加到git:
pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/application] 2015-04-15 17:37:53 root@pts/0 # git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # modules/ nothing added to commit but untracked files present (use "git add" to track) pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/application] 2015-04-15 17:37:56 root@pts/0 # git add modules root@pts/0 # git commit -a -m "init repo" [master (root-commit) 8ef11ef] init repo Committer: root <root@pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com> Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email you@example.com If the identity used for this commit is wrong, you can fix it with: git commit --amend --author=‘Your Name <you@example.com>‘ 2 files changed, 24 insertions(+), 0 deletions(-) create mode 100644 modules/httpd/files/1.txt create mode 100644 modules/httpd/manifests/init.pp
配置提交信息:
pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/application] 2015-04-15 17:38:47 root@pts/0 # git config --global user.name "wangyanliang" pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/application] 2015-04-15 17:39:10 root@pts/0 # git config --global user.email "wangyl@youyuan.com"
配置git远程节点名称:
pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/environment] 2015-04-15 17:51:10 root@pts/0 # git remote add origin /var/puppet/environment.git pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/environment] 2015-04-15 17:52:17 root@pts/0 # cd ../application pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/application] 2015-04-15 17:52:35 root@pts/0 # git remote add app_origin /var/puppet/application.git root@pts/0 # git remote -v app_origin /var/puppet/application.git (fetch) app_origin /var/puppet/application.git (push) pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/application] 2015-04-15 17:53:36 root@pts/0 # cd ../environment/; git remote -v origin /var/puppet/environment.git (fetch) origin /var/puppet/environment.git (push) pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/environment] 2015-04-15 17:57:08 root@pts/0 # git remote rm origin pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/environment] 2015-04-15 17:57:18 root@pts/0 # git remote add env_origin /var/puppet/environment.git pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/environment] 2015-04-15 17:57:34 root@pts/0 # git remote -v env_origin /var/puppet/environment.git (fetch) env_origin /var/puppet/environment.git (push)
将更改推送到git仓库:
pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/application] 2015-04-15 17:59:05 root@pts/0 # git push app_origin master:master Counting objects: 8, done. Delta compression using up to 2 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (8/8), 705 bytes, done. Total 8 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (8/8), done. To /var/puppet/application.git * [new branch] master -> master
操作yytest目录:
2015-04-15 18:00:55 root@pts/0 # git clone /var/puppet/environment.git environment fatal: destination path ‘environment‘ already exists and is not an empty directory. pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yytest] 2015-04-15 18:01:10 root@pts/0 # rm -rf environment pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yytest] 2015-04-15 18:01:38 root@pts/0 # git clone /var/puppet/environment.git environment Initialized empty Git repository in /etc/puppet/multi-environment/yytest/environment/.git/root@pts/0 # git clone /var/puppet/application.git application Initialized empty Git repository in /etc/puppet/multi-environment/yytest/application/.git/ pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yytest] 2015-04-15 18:02:56 root@pts/0 # cd environment/modules/ ;ls ssh test pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yytest/environment] 2015-04-16 12:52:53 root@pts/0 # git remote rm origin pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yytest/environment] 2015-04-16 12:53:02 root@pts/0 # git remote add env_origin /var/puppet/environment.git pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yytest/environment] 2015-04-16 12:53:23 root@pts/0 # cd ../application ; git remote rm origin; git remote add app_origin /var/puppet/application.git pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yytest/application] 2015-04-16 12:53:54 root@pts/0 # git remote -v app_origin /var/puppet/application.git (fetch) app_origin /var/puppet/application.git (push)
同样的操作yyprd目录:
pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yytest] root@pts/0 # git clone /var/puppet/application.git application Initialized empty Git repository in /etc/puppet/multi-environment/yyprd/application/.git/ root@pts/0 # git remote rm origin pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yyprd/application] 2015-04-16 12:48:31 root@pts/0 # git remote add app_origin /var/puppet/application.git root@pts/0 # git clone /var/puppet/environment.git environment Initialized empty Git repository in /etc/puppet/multi-environment/yyprd/environment/.git/ pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yyprd] 2015-04-16 11:54:32 root@pts/0 # ls environment/modules/ ssh test root@pts/0 # git remote rm origin pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yyprd/environment] 2015-04-16 12:49:19 root@pts/0 # git remote add env_origin /var/puppet/environment.git
至此puppet线上部署完成:多环境配置统一,并加入git,包含开发,测试,生产。让我看看我们这个环境是怎么协同工作的吧!
2:协同撰写
我们假设用户user1,user2。
user1负责写crontab模块。
user2负责写rsyslog模块。
usr1的实施步骤:
user2的实施步骤:
此文档最近两天会更新,请大家关注!
原文地址:http://linuxadmin.blog.51cto.com/2683824/1633350