Python + Django + Ansible Playbook automated operation and maintenance of the project combat tutorial

Python + Django + Ansible Playbook automated operation and maintenance of the project combat tutorial

 I. Getting Started guide

  • DevOps
    DevOps (Development and Operations of a combination of English) is a set of processes, methods and systems collectively, to facilitate communication between the development (application / software engineering), Technical Operations and Quality Assurance (QA) department, collaboration and integration . Its appearance is increasingly clear understanding of the software industry due to: In order to timely delivery of software products and services, development and operations must work closely together.
  • Django
  • python

Automated asset discovery scan

  • basis
  1. paramkio Log Scanning
  2. Login scanning pexpect
  3. telnetlib port scan
  4. nmap scan survival
  5. Assets scanning action
  • Advanced
  1. SDK call the scan ESXI
  2. snmp network equipment
  3. KVM virtual machine scan
  4. docker container scanning

ansible automation tasks

  1. ansible installation
  2. python ansible
  3. ansible adhoc
  4. ansible playbook
  5. Core classes call
  • Advanced
  1. Interface package api
  2. Methods rewrite
  3. Redis message store
  4. Mongo Event Log

Second, the acquaintance engineering and environmental structures

1 overall engineering design automation

  • Automated asset discovery scan
  • With a python program scans all assets found within the enterprise, when the asset changes can automatically detect and complete asset changes.
  • Such as: ip, hardware model, SN, MAC, system version
  • ansible automation tasks execution
  • Ansible use of ad-hoc and automate tasks playbook batch host

2, python and other basic installation environment

1) python installation

2) setuptools installation

3) pip installation tool

3, Mysql, Mongo, Redis installed

1) MySQL installation:

apt-get install mysql-server

 

2) Mongo installation:

apt-get install mongodb

 Start / restart mongodb: /etc/init.d/mongodb start / restart

 View mongodb listening port: netstat -luntp | grep mongo

 Using Client simulated landing mongodb: direct input mongo

 mongodb Profile Modified:

  we /etc/mongodb.conf

# The mongodb.conf code inside the bind_ip changed address 0.0.0.0 
bind_ip = 0.0.0.0 

# After you modify the save, remember to restart mongodb

 

3) Redis installed:

apt-get install redis-server

Modify the configuration file:

 vim /etc/redis/redis.conf

Copy the code
# Will bind 127.0.0.1 redis.conf changed in 0.0.0.0 
the bind 0.0.0.0 

after # modify save and reboot 
/etc/init.d/redis-server Start 


# simulate client connection redis server, direct input: 
redis- cli
Copy the code

 

4, let the project run up in Ubuntu

1) This project is already completed, we pulled off the project on GitHub

git command: git clone

1
git clone https: / / github.com / iopsgroup / imoocc

2) found from the project: requirements.tex file, we run in a virtual environment

First, create a virtual environment:

mkvirtualenv imoocc # Create a virtual environment 

workon imoocc # to enter the virtual environment

 

Then, in imoocc virtual environment, install project depends environment:

pip install -r ./requirements.txt

 

3) Create a database in mysql, the need to use the data consistent with the project

 

4) The project used in the data table structure, migrate to the local database:

# Execute the following two lines of code 
Python manege.py makemigrations 

Python manage.py the migrate

 

5) run the project:

python manage.py runserver 0.0.0.0:8000

 Three, DevOPS engineering Quick Start guide

1、Ipython 

 A python-based interactive interpreter. Auto-completion, history, obtain object information

Installation: python / Script

1
pip install ipython

2. Create a django DevOPS projects under Ubuntu

1) Create a virtual environment

1
mkvirtualenv devops_pro   # Ubuntu默认使用python2版本

2) new directory under your home directory: project

1
mkdir project

3) in a virtual environment, into the project directory, install django

1
pip install django = = 1.8 . 2

4) New Project: mydevops

1
django - admin startproject mydevops

 At this point, the project is created, enter mydevops directory, you can see there: a manage.py file, a directory mydevops

 

5) New app

1
python manage.py startapp appname

 

Guess you like

Origin www.cnblogs.com/itye/p/11683744.html