git push origin --delete namepython
git log --pretty=format:"%h:%s:%an"linux
git rebase 变基 将提交记录合并成一条直线git
git fetch 只拉取不合并web
git merge 合并docker
.gitignoreshell
git tag 查看标签json
git tag -a name -m "" 建立标签vim
git tag -a name -m "" hash值 给以前的建立一个标签ruby
git tag -d name 删除bash
git push origin --tags 将本地的标签都推送到远程
git show name 查看详情
git push origin :refs/tags/name
git checkout name 切换标签
git checkout filename 将指定文件会退到最近一次提交的地方
给别人贡献代码
正则
openpyxl
from openpyxl import Workbook wb=Workbook() wb1=wb.create_sheet("name",index) wb.active wb1.title="" wb1["A3"]= wb1.cell(row=3,column=3,vlaue="") wb1.append([]) wb.save("1.xlsx")
from openpyxl import load_workbook #data_only 获取函数的值 read_only 只读 wb=load_workbook(filename,data_only=True,read_only=True) wb.sheetnames wb1=wb["name"] wb1["A3"].value wb1.cell(row=3,column=4).value wb1.rows wb1.columns 不能用read_only wb1.max_row wb1.max_column
用来批量在远程主机上执行命令或者脚本的一个工具
python 2.7
saltstack python
puppet ruby https ssl认证
pip install
下载源码
python setup.py build
python setup.py install
编译安装
1.epel源(第三方的rpm包)
编译安装
yum 安装 rpm
https://opsx.alibaba.com/mirror 阿里镜像网站
163
sohu
ali
腾讯
清华
北大
中科院
docke ce 社区版本 开源
docker ee 商业版本 oracle redhat
128 是管理者 控制节点
129 130 131 是被控节点
#安装wget yum install -y wget #下载epel源 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo #安装ansible yum install -y ansible
ansible --help Usage: ansible <host-pattern> [options] -a MODULE_ARGS #模块参数 ,一个命令就是一个模块 -C, --check 不会真正的执行,可是会白跑一次,干跑 -f FORKS 指定进程数,高并发 --list-hosts 列出匹配到的主机列表 -m MODULE_NAME, 指定模块 --syntax-check 语法检查 -k, --ask-pass 输入密码
ping 走的是ICMP 协议(做业)
/etc/ansible/ansible.cfg #配置文件 /etc/ansible/hosts /etc/ansible/roles # hosts # This is the default ansible 'hosts' file. # # It should live in /etc/ansible/hosts # # - Comments begin with the '#' character #号用来注释 # - Blank lines are ignored 空行能够被忽略 # - Groups of hosts are delimited by [header] elements # - You can enter hostnames or ip addresses 能够输入主机名或者ip地址 # - A hostname/ip can be a member of multiple groups 一个ip或者主机能够被分在多个组 #10.0.0.129 #10.0.0.130 #10.0.0.131 [web] 10.0.0.129 10.0.0.130 [db] 10.0.0.130 10.0.0.131 [cache] 10.0.0.131 #www[001:006].example.com www001 - www006
ansible 10.0.0.129 -m ping -k ansible 10.0.0.130 -m ping ansible 10.0.0.131 -m ping ansible 10.0.0.130,10.0.0.129 -m ping ansible all -m ping ansible web -m ping ansible web,db -m ping ansible "web:&db" -m ping ansible 'web:!db' -m ping
ssh-keygen #生成秘钥 一直回车 秘钥对 公钥 私钥 ssh-copy-id root@ip #将本地的key复制到远程机器 vi /etc/ssh/sshd_config 修改UserDNS no sed -i "s@#UseDNS yes@UseDNS no@" /etc/ssh/sshd_config systemctl restart sshd 重启sshd
交集 有相同的
并集 合并的集合
差集 相差的集合
单个的ip地址
多个的ip地址 用,隔开
全部的ip地址 all
单个的组
多个的组
Usage: ansible-doc [-l|-F|-s] [options] [-t <plugin type> ] [plugin] -j 以json的方式返回全部的模块信息 -l 列出全部的模块 -s 简短的方式来展现模块信息 [root@bogon ~]# ansible-doc -l|wc -l 2834 ansible-doc ping 查看详细信息
A10 F5
aws 亚马逊云
azure 微软云
ansible web -a "pwd" 执行命令 ansible web -a "ls" ansible web -a "chdir=/tmp pwd" 先切换目录在执行命令,通常用在编译 ansible web -a "creates=/tmp pwd" 命令不会被执行,由于/tmp是存在的 ansible web -a "creates=/tmp2 pwd" 命令会被执行,由于/tmp2目录是不存在的 ansible web -a "removes=/tmp2 pwd" 命令不会被执行 ,由于/tmp2目录不存在 ansible web -a "removes=/tmp pwd" 命令会被执行,由于/tmp存在 ansible web -a "creates=/data mkdir /data" /data目录会被建立,由于/data不存在
查看用户是否建立成功
id alex tail -1 /etc/passwd tail -1 /etc/shadow su alex
设置密码
echo "1" |passwd --stdin alex
ansible web -m shell -a "chdir=/tmp pwd" ansible 10.0.0.129 -m shell -a "bash a.sh" 执行脚本 文件能够没有执行权限 ansible 10.0.0.129 -m shell -a "/root/a.sh" 执行脚本 文件必需要有执行权限 ansible 10.0.0.129 -m shell -a "python a.py" ansible 10.0.0.129 -m shell -a "/root/a.py" 若是说脚本里面指定了解释器,那么就用执行的解释器来解释,若是没有指定解释器的话,则用bash shabang
补充
[root@localhost ~]# cat a.sh #!/bin/bash echo "shell" [root@localhost ~]# bash a.sh shell [root@localhost ~]# chmod +x a.sh [root@localhost ~]# ./a.sh shell [root@localhost ~]# python a.py 停车坐爱枫林晚,霜叶红于二月花 [root@localhost ~]# ./a.py -bash: ./a.py: Permission denied [root@localhost ~]# chmod +x a.py [root@localhost ~]# ./a.py 停车坐爱枫林晚,霜叶红于二月花 [root@localhost ~]# cat a.py #!/usr/bin/python #coding:utf-8 print("停车坐爱枫林晚,霜叶红于二月花")
文件必须得有执行权限 ansible web -m script -a "/root/a.sh" ansible web -m script -a "a.sh" ansible web -m script -a "chdir=/tmp a.sh" 先切换目录在执行脚本 ansible web -m script -a "creates=/root/a.sh a.sh" 判断的是远程主机上是否存在文件,若是存在就跳过 ansible web -m script -a "removes=/root/a.sh a.sh" 判断远程主机上是否存在,若是存在的话就执行
git 使用ssh的方式上传或者下载文件
pycharm里面的git客户端
ansible
安装 epel源
host-pattern格式
ping
ansible 是基于ssh的
command 执行远程主机上的命令,不支持特殊字符 $ < > | & !
shell 执行远程主机上的命令或者脚本
script 执行本地的脚本(管理机上) 脚本必需要有执行的权限
icmp
把crm分页 找出来
复习linux
用户
用户组
yum
pip
crontab
systemctl
service
vim