趁周末把ansible action plugin 写了一个简单的例子,我们日常工作中可能很少会用到action plugin ,但是如果我们能通过action plugin 做一些初始化的工作,例如设定一些默认值,这样我们的ansible playbook 可能会简介很多 例如我们写了一个module需要传递2个参数,如果我们这个mod……
ansible filter (编写你自己的ansible filter) 置顶
有时候我们写自己的playbook的时候变量处理真的是特别让人头大,有些变量的操作在python中就很简单,但是放到ansible playbook中就会很麻烦,所以,我们今天来看一下如何编写自己的ansible filter来帮助我们处理一下变量 直接看例子吧:
1 2 3 4 5 6 7 8 9 10 11 |
#!/usr/bin/python class FilterModule(object): def filters(self): return { 'a_filter': self.a_filter, 'another_filter': self.b_filter } def a_filter(self, a_variable): a_new_variable = a_variable + ' CRAZY NEW FILTER' return a_new_variable |
我们来分……
如何创建自己的ansible module 置顶
如何通过Python 自动寻找代理增加网站的流量(刷流量PV) 置顶
iowait 过高问题的查找及解决linux 置顶
aws eks node 自动化扩展工具 Karpenter
ReplicationController and ReplicaSet in Kubernetes
public key fingerprint
Index brackets must contain either a literal number or a literal string. terraform taint
aws eks 中 的权限 AWS IAM 权限挂钩的
asyncio python 协程
python 中的协程其实就是一种高效的任务切换模式: 遇到需要等待的(例如io等待), 直接跳到其他任务去执行,不会傻傻的等到io结束才向下执行 先看一个如果没有异步的例子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import asyncio import time def func1(): print("this is func1 ") time.sleep(2) print("this is end of func1") def func2(): print("this is func2 ") time.sleep(2) print("this is end of func2") if __name__ == '__main__': func1() func2() |
运行结果:
1 2 3 4 5 |
this is func1 this is end of func1 this is func2 this is end of func2 python asyntest.py 0.06s user 0.02s system 1% cpu 4.105 total |
也就是说,我们如果……
如何快速分析我们存储在s3中的文件(日志)
Route53 Routing policy
aws 启用mfa以后,如何使用cli 命令行
限制读取s3的某个文件夹下文件的权限
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 |
{ "Statement": [ { "Action": [ "s3:ListBucket" ], "Condition": { "StringLike": { "s3:prefix": [ "folder/2020/04/*" ] } }, "Effect": "Allow", "Resource": [ "arn:aws:s3:::my-s3" ] }, { "Action": [ "s3:GetObject*" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::my-s3/folder/2020/04/*" ] } ], "Version": "2012-10-17" } |
例如我们只想开放给某个role 我们s3中特定的一个文件夹下的东西 我的s3 叫my-s3 GetObject 是说如果你知道路径了,直接下载没问题,但是如果你想使用一些
1 |
--recursive |
这种下……