未分类
python中的subprocess.Popen()使用
python中的subprocess.Popen()使用 从python2.4版本开始,可以用subprocess这个模块来产生子进程,并连接到子进程的标准输入/输出/错误中去,还可以得到子进程的返回值。 Read more…
SECURITY
自签名证书详解
总结下来,其实生成证书就两句话:
1 2 3 4 5 6 7 8 9 |
DOMAIN='www.example.com' SUBJECT="/C=US/ST=Mars/L=iTranswarp/O=iTranswarp/OU=iTranswarp/CN=$DOMAIN" openssl req -nodes -new -subj $SUBJECT -keyout $DOMAIN.key -out $DOMAIN.csr printf "subjectAltName=DNS:localhost,IP:192.168.1.1" | \ openssl x509 -req -sha256 -days 3650 -in $DOMAIN.csr \ -signkey $DOMAIN.key -out $DOMAIN.crt \ -extfile /dev/stdin |
SECURITY
内网一键生成 LetsEncrypt HTTPS证书
HTTPS当前越来越重要,所以经常会有公司去花钱买,我们也一样,有时候确实需要https,但是收费的用不起,所以打起了免费的主义。 LetsEncrypt是不错的选择,但是我们如果在内网该如何克服呢,没错,使用ngrok。 Read more…
未分类
How To Setup DNS Slave Auto Configuration Using Virtualmin/Webmin
实现步骤 由于bind主从集群安装完成后, Read more…
未分类
创建虚拟环境: Ansible, Python3, and Virtualenvs on CentOS and RHEL and MacOS
要为ansible运行创建一个最新的虚拟环境, 以下是步骤: Read more…
未分类
批量插入/替换整段代码到指定位置
需求是用ansible来修改nginx配置文件,添加代理gotty打开终端的逻辑,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
--- - name: modify nginx configure gather_facts: F hosts: nginx pre_tasks: - name: define variables set_fact: nginx_conf: /data/middleware/nginx/conf.d/upstream-tomcat.conf tasks: - name: "modify nginx configure - part 1" shell: cmd: | time=$(date +%F) sed -i "1i\# modified at $time" upstream-tomcat.conf Bstr='\# modified at' Estr='upstream dashboard' sed -n " /$Bstr/ { n :start /$Estr/! { N b start } p } " map.txt | sed " /$Bstr/ { n :start /$Estr/! { N b start } r /dev/stdin d } " {{ nginx_conf }} > {{ nginx_conf }}.new mv -f {{ nginx_conf }}.new {{ nginx_conf }} - name: "modify nginx configure - part 2" shell: cmd: | Bstr='# --- END FOR KUBOARD ---' Estr='location.*.\/redis\/' sed -n " /$Bstr/ { n :start /$Estr/! { N b start } p } " location.txt | sed " /$Bstr/ { n :start /$Estr/! { N b start } r /dev/stdin d } " {{ nginx_conf }} > {{ nginx_conf }}.new mv -f {{ nginx_conf }}.new {{ nginx_conf }} |