DevOps Tools

DevOps Tools

OS Software Configure Managment

Install

Ubuntu

$ cd /usr/local/src/
$ git clone https://github.com/oscm/devops.git
$ cd devops
$ python3 setup.py sdist
$ python3 setup.py install

CentOS

$ cd /usr/local/src/
$ git clone https://github.com/oscm/devops.git
$ cd devops
$ python3 setup.py sdist
$ python3 setup.py install --prefix=/srv/devops

Help

$ deployment backup production appmanager.example.com
Usage: deployment [options] {branch|stage} project

Options:
  -h, --help            show this help message and exit

  stage:
	{development | testing | production | stable | unstable | alpha |
	beta} <host>.<domain>

	-r REVERT, --revert=REVERT
						revert to revision
	--clean             
	-s, --silent        Silent mode. Don't output anything
	--backup=BACKUP     backup remote to local

  branch:
	branch management

	-c master|trunk, --checkout=master|trunk
						checkout branch
	-n branch, --new=branch
						Create new branch
	-d branch, --delete=branch
						delete branch
	--release=RELEASE   release version exampe:2015-01-15

  merge:
	merge {development | testing | production}

	-t master, --to=master
						such as master
	-f your, --from=your
						from branch

  unittest:
	unittest {development | testing | production}

  Example: 
	deployment testing www.example.com
	deployment production www.example.com --clean
	deployment testing bbs.example.com --backup=/tmp/backup

  Homepage: http://netkiller.github.com	Author: Neo <netkiller@msn.com>

Configure

$ mkdir ~/{development,testing,production}
$ mkdir ~/{exclude,log}
$ mkdir ~/{stable,unstable,nightly}

$ vim ~/testing/example.com.ini 
[www]
;repository=git@192.168.2.1:example.com/www.example.com
repository=https://github.com/oscm/shell.git
source=/tmp/repo
option=--delete --password-file=confure/production/example.com/passwd
exclude=testing/www.example.com.lst
logfile=/tmp/www.example.com
remote=www@192.168.2.15
destination=example.com/www.example.com

[inf]
repository=git@192.168.6.1:example.com/inf.example.com
delete=Y
mode=ssh
backup=~/backup
exclude=inf.example.com.lst
remote=www@220.82.21.3,www@220.82.21.13
destination=example.com/inf.example.com	

[bbs]
repository=https://github.com/example.com/bbs.example.com.git
remote=www@192.168.2.15
destination=example.com/bbs.example.com

[images]
repository=https://github.com/example.com/images.example.com.git
remote=www@192.168.2.15
destination=example.com/images.example.com
branch=freebsd

[windows]
repository=git@192.168.2.1:example.com/windows.example.com
delete=Y
mode=ssh
backup=/cygdrive/d/backup
remote=administrator@158.99.11.168
destination=/cygdrive/d/windows.example.com

yuicompressor

yuicompressor=all|css|js

[m]
repository=git@localhost:netkiller.cn/m.netkiller.cn.git
branch=development
delete=Y
mode=ssh
backup=~/backup
remote=www@www.netkiller.cn
destination=netkiller.cn/m.netkiller.cn
include=m.netkiller.cn.lst
exclude=m.netkiller.cn.lst
yuicompressor=css

* You need to install yuicompressor. FYI:
curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/java/devel/YUICompressor.sh | bash

gulp

[m]
repository=git@localhost:netkiller.cn/m.netkiller.cn.git
branch=development
delete=Y
mode=ssh
backup=~/backup
remote=www@www.netkiller.cn
destination=netkiller.cn/m.netkiller.cn
include=m.netkiller.cn.lst
exclude=m.netkiller.cn.lst
gulp=all
gulp.path=/www/gulp
gulp.gulpfile=gulpfile.js

* cd <gulp.path> && gulp <gulp.gulpfile> 

Parameter replaces

create config file under the stage folder.
vim config/testing/www.example.com.ini
[config/database.php]
host=localhost
port=3306
user=root
password=passw0rd
[config/redis.php]
host=localhost
port=6379

Format of config item

repository: git uri
source: directory for checkout and rsync
option: rsync argv
exclude: exclude file for rsync
remote: remote host
destination: destination directory
branch: git branch, defualt is master

show me the projects

$ deployment testing
example.com.ini
['www', 'images', 'api', 'bbs', 'news', 'blog', 'music', 'video']

Deploy Project

$ deployment testing bbs.example.com
receiving incremental file list

sent 82 bytes  received 3228 bytes  601.82 bytes/sec
total size is 243879  speedup is 73.68

Revert

$ deployment testing www.example.com -r master	
$ deployment testing www.example.com -r b1f13fade4c069ff077ce5f26fc3cb1e3c6df902	

$ deployment testing www.example.com -r 838cba5
HEAD is now at 838cba5... Merge branch 'master' of https://github.com/oscm/linux
* (detached from 838cba5)
  master
sending incremental file list
.git/
.git/index
		7344 100%    6.34MB/s    0:00:00 (xfer#1, to-check=117/157)

sent 3230 bytes  received 148 bytes  519.69 bytes/sec
total size is 234676  speedup is 69.47

Branch management

Show current branch

$ deployment branch testing bbs.example.com 
* master

Create branch

$ deployment branch testing bbs.example.com -n development
Switched to a new branch 'development'
$ deployment branch testing bbs.example.com -n testing
Switched to a new branch 'testing'
$ deployment branch testing bbs.example.com -n production
Switched to a new branch 'production'

$ deployment branch testing bbs.example.com 
  development
  master
* production
  testing

Checkout branch

$ deployment branch testing bbs.example.com -c master
HEAD is now at f9ed461 Update 5.5.8.sh
Switched to branch 'master'

$ deployment branch testing bbs.example.com 
  development
* master
  production
  testing	

Delete branch

$ deployment branch testing bbs.example.com -d beat
error: Cannot delete the branch 'beat' which you are currently on.

$ deployment branch testing bbs.example.com --delete=beat
error: Cannot delete the branch 'beat' which you are currently on.

$ deployment branch testing bbs.example.com -c master
HEAD is now at f9ed461 Update 5.5.8.sh
Switched to branch 'master'

$ deployment branch testing bbs.example.com --delete=beat
Deleted branch beat (was f9ed461).

$ deployment branch testing bbs.example.com 
* master	  

Release version

$ deployment branch testing bbs.example.com --release=10.0-RELEASE
$ git tag 
10.0-RELEASE

Backup

$ deployment testing bbs.example.com --backup=/tmp/backup

Reset

$ deployment testing bbs.example.com --clean

Merge

$ deployment merge www.example.com -t master -f testing

merge to testing form development

$ deployment merge testing www.example.com 

Merge to development from project1

$ deployment development www.example.com -f project1

-----------------------------------------------------------

Deploy a java project

First of all, create a user for runtime environment.
login to remove server and then running following command.

# groupadd -g 80 www
# adduser -o --home /www --uid 80 --gid 80 -c "Web Application" wwwAssign a password to www user.

# passwd wwwChanging password for user www.New UNIX password: Retype new UNIX password: 
passwd: all authentication tokens updated successfully.

Create project directory.
# su - www
# mkdir /www/example.com

Create a configuration file for the project.

$ cat production/example.com.ini 
[www]
repository=git@192.168.0.1:example.com/www.example.com
delete=Ymode=ssh
backup=~/backup
exclude=www.example.com.lst
remote=www@223.25.22.72destination=example.com/www.example.com
dist=WebRootremote_before=Yremote_after=Y

Create an exclude list

$ touch exclude/www.cf88.com.lst

Create remove shell

Before shell.

Before running 'libexec/www.example.com.before' during the deployment.Such as build, package, shutdown tomcat...$ cat libexec/www.example.com.before 
/srv/apache-tomcat/bin/shutdown.sh
sleep 5pkill -f apache-tomcat

After shell

After running 'libexec/www.example.com.after' during the deployment.

$ cat libexec/www.example.com.after 
/srv/apache-tomcat/bin/startup.sh

Use locally available keys to authorise logins on a remote machine

$ ssh-copy-id www@223.25.22.72/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
www@223.25.22.72's password: 

Number of key(s) added: 1Now try logging into the machine, with:   "ssh 'www@223.25.22.72'"and check to make sure that only the key(s) you wanted were added.

Deploy locally available project to remove server.

$ deployment production www.example.com

本文分享自微信公众号 - Netkiller(netkiller-ebook),作者:景峯

原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。

原始发表时间:2017-06-07

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Email 服务器之 SPF 记录

    节选自《Netkiller Mail 手札》 6.1. Sender Policy Framework 6.1.1. 分析 SPF 记录 从主域开始查看 txt...

    netkiller old
  • Apache Ant 实现自动化部署

    Apache Ant 实现自动化部署 这篇文章帮你解决下列问题: 源码获取,源码编译,处理配置文件,应用部署,远程备份,部署回撤,启动,服务器状态,停止 ---...

    netkiller old
  • 因果图在运维工作中的应用

    因果图在运维工作中的应用 目录 1. 什么是因果图 2. 为什么使用因果图 3. 何时使用因果图 4. 何处使用因果图 5. 谁来负责制作因果图 6. 怎样使用...

    netkiller old
  • apache配置多站点

    Apache在安装之后默认只是指向一个站点,即127.0.0.1,如果要进行多站点的配置,需要更改一些配置。

    似水的流年
  • apache配置多站点

    Apache在安装之后默认只是指向一个站点,即127.0.0.1,如果要进行多站点的配置,需要更改一些配置。 1.让Apache在启动时能加载虚拟主机...

    似水的流年
  • windows Apache服务器简单配置虚拟域名(转载)

    #<VirtualHost *:80> #    ServerAdmin webmaster@dummy-host2.example.com #    Docu...

    lin_zone
  • apache配置多站点

    Apache在安装之后默认只是指向一个站点,即127.0.0.1,如果要进行多站点的配置,需要更改一些配置。

    似水的流年
  • DMA方式

    DMA方式是一种完全由硬件进行组信息传送的控制方式。具有程序中断方式的优点,即在数据准备阶段,CPU与外设并行工作。DMA方式在外设与内存之间开辟一条“直接数据...

    week
  • 「GitHub」上一些可以涨薪的开源项目

    大家好,我是程序员小吴,今天我给大家找到了一些GitHub上关于面试的开源项目,大家各取所需,希望这些开源的项目能帮你在这个寒冬用很短的时间准备好面试和来年的跳...

    五分钟学算法
  • .net core实践系列之短信服务-目录

    经过两周多的业余时间,终于把该系列的文章写完了。第一次写系列,可能部分关键点并没有覆盖到,如果有疑问的朋友可以随时反馈给我。另外也感谢在我发布文章时给予我方案建...

    陈珙

扫码关注云+社区

领取腾讯云代金券