Skip to content

Commit

Permalink
修改README 修正密钥问题
Browse files Browse the repository at this point in the history
  • Loading branch information
YoLoveLife committed Jun 28, 2018
1 parent 1dc1445 commit 89bf29f
Show file tree
Hide file tree
Showing 39 changed files with 445 additions and 230 deletions.
65 changes: 45 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
devEops :laughing: 开发自运维平台
devEops :laughing: 开发自运维平台 :no_mouth: 后端
================================
[![Travis Build Status](https://travis-ci.org/YoLoveLife/DevOps.svg?branch=master)](https://travis-ci.org/YoLoveLife/DevOps)
[![Github All Releases](https://img.shields.io/github/downloads/atom/atom/total.svg)](https://github.com/YoLoveLife/devEops/releases)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md) :yum: </br>

Author: [YoLoveLife.com](http://www.yolovelife.com) :ok_hand: </br>
:heart: 感谢所有 :star: 我的人 你们是我努力的动力</br>
该项目为devEops的后端部分 前端部分请关注 :heart: [devEops-Web](https://github.com/YoLoveLife/devEopsWeb)</br>

运维体系解决方案(正在成长中)</br>
新的Vue前端已经逐步上线啦!</br>
前后段分离啦!告别之前的Jinja2</br>
:muscle: 实践以资产、应用信息为中心的运维平台</br>
django & rest-framework & bootstrap</br>
django模型 & rest-framework</br>
:muscle: 参考了诸多django项目 我的Django用的真的很棒</br>
travis & django TestCase</br>
:muscle: 单元测试 测试不规范但是努力去做
Expand All @@ -33,32 +34,56 @@ travis & django TestCase</br>
本开发自运维平台致力于IT资源信息的整合与自动化运维,通过服务、应用配置的信息整合来运维提供帮助。</br>
devEops正在不断成长
- 所有运维操作都基于信息整合的正确性和一致性(资产信息管理) :floppy_disk: </br>
- 基于WebSocket以及SSHProxy的软件堡垒机操作 </br>
- :bar_chart: 提供资产信息的统计,应用系统的占比、脚本|剧本的调用次数等</br>
- ~~可临时搜集应用上的信息(如MySQL的status等信息)~~</br>
- ~~所有运维操作(脚本 | 剧本)在提交的时候会自动注入资产信息并通过ansible远程执行~~</br>
- 所有资产信息、架构信息都存储在数据库中供所有运维人员操作</br>
- ~~开发人员可登陆平台提交工单发起防火墙修改、应用发布、日常运维 :clock9: 等操作,运维人员许可操作进行~~</br>
- ~~所有应用发布、日常运维工作日程展示 :date:~~ </br>
- 对接VMware|Aliyun自动拉取信息入库资产 </br>
- :bar_chart: 提供各类信息统计图表(资产|运维)等</br>
- 基于Ansile的运维元操作|任务的定义</br>
- 基于WebSocket以及SSHProxy的工单操作 </br>
- 基于Django自带auth认证体系的资产与权限关联</br>
- 域名管理与解析信息查询与刷新</br>
- 详细权限操作,区分开发人员以及运维人员 </br>

## <a name="looklike"> 平台一览 </a>
### 登陆界面
![LOGIN](img/login.png)</br>
### 仪表盘界面
根据资源的检出位置|操作系统类型|运维操作 等图表化展现</br>
~~并且每周提供可供保存的静态页面的报告(有!但是很丑!)
![DASHBOARD](img/dashboard.png)
### 资产管理
资产根据来源(VMWARE|ALIYUN)入库 运维人员进行归类
![GROUP](img/group.png)</br>
### 执行基于playbook的元操作
![JUMPER](img/playbook.png)</br>
### 批量主机信息上传
![UPLOAD](img/upload.png)</br>
### 脚本编写
![SCRIPT](img/script.png)</br>
### 时间线展示
![TIMELINE](img/timeline.png)</br>
应用组可定义架构图 关联跳板机以及密钥 :key: </br>
应用组可全局添加参数 该参数会注入运维操作中的变量中</br>
![HOST](img/host.png)
主机可以根据任意信息进行检索</br>
~~根据VMware|ALIYUN API可进行详细信息(~~监控|配置)获取查看</br>
### 域名管理
基于树结构的域名管理 定时解析域名 保证记录域名解析正确 供正反向查询
![DNS](img/dns.png)
### 密钥管理
基于服务器端直接生成的ssh-rsa密钥 私钥将会直接加密存储入数据库</br>
只有当您做运维操作|SSH连接的时候才会解析并且使用</br>
![KEY](img/key.png)
### QR-Code
基于Google-Authority的二次验证 目前用户体系中已经包含验证+生成</br>
![QRCODE](img/qrcode.png)
### 元操作及任务
基于Ansible的数据模型 将用户的Ansible直接存储入数据库中</br>
当用户使用任务直接从CMDB中导出需要执行的主机列表以及参数列表注入Ansible-API中</br>
![META](img/meta.png)
选择元操作所涉及的主机范围</br>
![META](img/meta_bt.png)
选择某个应用组下的若干个元操作组成一个任务</br>
![MISSION](img/mission.png)
### 工单系统
用户根据自身权限可以发布工单(涉及任务)进行执行</br>
![CODEWORK](img/work.png)
选择工单后用户可以进行执行 系统建立websocket将所有执行结果返回
![RUN](img/run.png)

## <a name="howtoinstall"> 如何安装 </a>
devEops依赖于python2.7、诸多python第三方模块、mysql数据库、redis缓存</br>
以下操作环境已经拥有python2.7、mysql数据库、redis缓存
devEops依赖于python3.5、诸多python第三方模块、mysql数据库、redis缓存</br>
以下操作环境已经拥有python3.5、mysql数据库、redis缓存
```bash
$ cd path/to/project/folder/

Expand Down
14 changes: 12 additions & 2 deletions apps/authority/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def public_key(self):

@public_key.setter
def public_key(self, public_key):
print('pub',aes.encrypt(public_key).decode())
self._public_key = aes.encrypt(public_key).decode()

@property
Expand Down Expand Up @@ -199,5 +198,16 @@ def check_status(self):
self._status = 1
return 1

@property
def to_yaml(self):
return '-o ProxyCommand="ssh -p{PORT} -W %h:%p -q root@{IP} nc"'.format(PORT=self.sshport,IP=self.connect_ip)
return {
u'set_fact':
{
'ansible_ssh_common_args':
'-o ProxyCommand="ssh -p{PORT} -i {KEY} -W %h:%p root@{IP}"'.format(
PORT=self.sshport,
IP=self.connect_ip,
KEY='{{KEY}}'
)
}
}
14 changes: 7 additions & 7 deletions apps/dashboard/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from celery.task import periodic_task
from celery.schedules import crontab
from pyecharts import Pie
from deveops.conf import ALIYUN_PAGESIZE,REDIS_PORT,REDIS_SPACE,EXPIREDTIME
from deveops.conf import ALIYUN_PAGESIZE,REDIS_PORT,REDIS_SPACE,EXPIREDTIME,DASHBOARD_TIME,EXPIRED_TIME,MANAGER_TIME
from deveops import settings
import redis, datetime, json, os
from deveops.utils import aliyun
Expand All @@ -22,7 +22,7 @@
connect = redis.StrictRedis(port=REDIS_PORT,db=REDIS_SPACE)


@periodic_task(run_every=crontab(minute="*"))
@periodic_task(run_every=DASHBOARD_TIME)
def weeklyDashboard():
import jinja2
loader = jinja2.FileSystemLoader(settings.BASE_DIR+'/apps/dashboard/docs/', encoding='utf-8')
Expand Down Expand Up @@ -110,7 +110,7 @@ def weeklyDashboard():
smtp.sendMail('devEops平台运维周报', msg, ['[email protected]'])#,'[email protected]','[email protected]','[email protected]'])


@periodic_task(run_every=crontab(minute=1,hour=1))
@periodic_task(run_every=EXPIRED_TIME)
def aliyunECSExpiredInfoCatch():
ExpiredAliyunECS.objects.all().delete()
countNumber = aliyun.fetch_ECSPage()
Expand All @@ -127,7 +127,7 @@ def aliyunECSExpiredInfoCatch():
ExpiredAliyunECS(**instance_data).save()


@periodic_task(run_every=crontab(minute=2,hour=1))
@periodic_task(run_every=EXPIRED_TIME)
def aliyunRDSInfoCatch():
ExpiredAliyunRDS.objects.all().delete()
countNumber = aliyun.fetch_RDSPage()
Expand All @@ -143,7 +143,7 @@ def aliyunRDSInfoCatch():
ExpiredAliyunRDS(**resolver.AliyunRDS2Json.decode(dt)).save()


@periodic_task(run_every=crontab(minute=3,hour=1))
@periodic_task(run_every=EXPIRED_TIME)
def aliyunKVStoreInfoCatch():
ExpiredAliyunKVStore.objects.all().delete()
countNumber = aliyun.fetch_KVStorePage()
Expand All @@ -158,7 +158,7 @@ def aliyunKVStoreInfoCatch():
ExpiredAliyunKVStore(**resolver.AliyunKVStore2Json.decode(dt)).save()


@periodic_task(run_every=crontab(minute=4,hour=1))
@periodic_task(run_every=EXPIRED_TIME)
def aliyunMongoDBInfoCatch():
ExpiredAliyunMongoDB.objects.all().delete()
countNumber = aliyun.fetch_MongoDBPage()
Expand All @@ -175,7 +175,7 @@ def aliyunMongoDBInfoCatch():
ExpiredAliyunMongoDB(**resolver.AliyunMongoDB2Json.decode(dt)).save()


@periodic_task(run_every=crontab(minute=10,hour=1))
@periodic_task(run_every=MANAGER_TIME)
def managerStatusCatch():
connect.delete('MANAGER_STATUS')

Expand Down
7 changes: 1 addition & 6 deletions apps/manager/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,19 @@

class HostFilter(django_filters.FilterSet):
connect_ip = django_filters.CharFilter(method="connect_ip_filter")
service_ip = django_filters.CharFilter(method="service_ip_filter")
info = django_filters.CharFilter(method="info_filter")
systype = django_filters.CharFilter(method="systype_filter")
position = django_filters.CharFilter(method="position_filter")
hostname = django_filters.CharFilter(method="hostname_filter")

class Meta:
model = models.Host
fields = ['groups', 'connect_ip', 'service_ip', 'hostname', 'sshport', 'info', 'systype', 'position']
fields = ['groups', 'connect_ip', 'hostname', 'sshport', 'info', 'systype', 'position']

@staticmethod
def connect_ip_filter(queryset, first_name, value):
return queryset.filter(connect_ip__icontains=value)

@staticmethod
def service_ip_filter(queryset, first_name, value):
return queryset.filter(service_ip__icontains=value)

@staticmethod
def info_filter(queryset, first_name, value):
details = models.HostDetail.objects.filter(info__icontains=value)
Expand Down
1 change: 0 additions & 1 deletion apps/manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class Host(models.Model):
# 相关信息
# connect_ip = models.GenericIPAddressField(default='', null=False)
connect_ip = models.CharField(max_length=15, default='', null=False)
service_ip = models.CharField(max_length=15, default='0.0.0.0', null=True)
# service_ip = models.GenericIPAddressField(default='0.0.0.0', null=True)

# 主机名称
Expand Down
41 changes: 0 additions & 41 deletions apps/manager/query.py

This file was deleted.

9 changes: 6 additions & 3 deletions apps/manager/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

class GroupSerializer(serializers.HyperlinkedModelSerializer):
users = serializers.PrimaryKeyRelatedField(many=True, queryset=ExtendUser.objects.all())
pmn_groups = serializers.PrimaryKeyRelatedField(many=True, queryset=models.PerGroup.objects.all())
pmn_groups = serializers.PrimaryKeyRelatedField(required=False, many=True, queryset=models.PerGroup.objects.all())
key = serializers.PrimaryKeyRelatedField(required=False, queryset=models.Key.objects.all(), allow_null=True)
jumper = serializers.PrimaryKeyRelatedField(required=False, queryset=models.Jumper.objects.all(), allow_null=True)
_status = serializers.IntegerField(required=True, source='status',)
_framework = serializers.PrimaryKeyRelatedField(queryset=models.FILE.objects.all(), allow_null=True)
_framework = serializers.PrimaryKeyRelatedField(required=False, queryset=models.FILE.objects.all(), allow_null=True, write_only=True)
framework = serializers.ImageField(source="_framework.image", read_only=True)
class Meta:
model = models.Group
Expand All @@ -26,6 +26,9 @@ class Meta:
read_only_fields = (
'id', 'uuid', 'framework'
)
write_onlu_fields = (
'_framework'
)

def update(self, instance, validated_data):
# instance.framework_update()
Expand Down Expand Up @@ -111,7 +114,7 @@ class HostSerializer(serializers.ModelSerializer):
class Meta:
model = models.Host
fields = (
'id', 'detail', 'connect_ip', 'service_ip', 'hostname', 'sshport', '_status', 'groups',
'id', 'detail', 'connect_ip', 'hostname', 'sshport', '_status', 'groups',
'passwd', 'uuid'
)
read_only_fields = (
Expand Down
Loading

0 comments on commit 89bf29f

Please sign in to comment.