注:本文侧重于pupput使用git版本控制在线上环境的部署步骤详解。
1:线上puppet加入git版本控制
详细步骤:
pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/environment] [email protected]/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] [email protected]/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 [email protected]/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 [email protected]/0 # git add modules [email protected]/0 # git commit -a -m "init repo" [master (root-commit) 8ef11ef] init repo Committer: root <[email protected]_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 [email protected] If the identity used for this commit is wrong, you can fix it with: git commit --amend --author=‘Your Name <[email protected]>‘ 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 [email protected]/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 [email protected]/0 # git config --global user.email "[email protected]"
配置git远程节点名称:
pptserver_wangsu_bj_192.168.3.68.centos.yypuppet.com [/etc/puppet/multi-environment/yydev/environment] 2015-04-15 17:51:10 [email protected]/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 [email protected]/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 [email protected]/0 # git remote add app_origin /var/puppet/application.git [email protected]/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 [email protected]/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 [email protected]/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 [email protected]/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 [email protected]/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 [email protected]/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 [email protected]/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 [email protected]/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 [email protected]/0 # git clone /var/puppet/environment.git environment Initialized empty Git repository in /etc/puppet/multi-environment/yytest/environment/.git/[email protected]/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 [email protected]/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 [email protected]/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 [email protected]/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 [email protected]/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 [email protected]/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] [email protected]/0 # git clone /var/puppet/application.git application Initialized empty Git repository in /etc/puppet/multi-environment/yyprd/application/.git/ [email protected]/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 [email protected]/0 # git remote add app_origin /var/puppet/application.git [email protected]/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 [email protected]/0 # ls environment/modules/ ssh test [email protected]/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 [email protected]/0 # git remote add env_origin /var/puppet/environment.git
至此puppet线上部署完成:多环境配置统一,并加入git,包含开发,测试,生产。让我看看我们这个环境是怎么协同工作的吧!
2:协同撰写
我们假设用户user1,user2。
user1负责写crontab模块。
user2负责写rsyslog模块。
usr1的实施步骤:
user2的实施步骤:
此文档最近两天会更新,请大家关注!
时间: 2024-10-15 08:31:22