奥登德

autond的Python项目详细描述


汽车项目

auton是一个免费的开源软件,我们开发它来通过http协议在远程服务器上运行程序和命令行。 有两个程序,客户端为auton,服务器端为autond。 auton只是将命令行转换为http协议的助手,它能够转换基本参数、文件参数和环境变量。 例如,您可以使用auton from ci/cd在远程服务器上运行,只需配置端点即可:

如果需要执行新版本的软件,但不能在旧服务器上安装,则也可以使用auton。 或者测试程序执行。

快速启动

在Docker中使用Autond

docker-compose up -d

docker-compose.yml

安装

服务器端自动发送

pip install autond

客户端的auton

pip install auton

环境变量

自动结束

VariableDescriptionDefault
^{}Configuration file contents
(e.g. ^{})
^{}Log file path/var/log/autond/daemon.log
^{}autond pid file path/run/auton/autond.pid
^{}auton groupauton or root
^{}auton userauton or root

自动

VariableDescriptionDefault
^{}user for authentication
^{}password for authentication
^{}name of endpoint
^{}Log file path/var/log/auton/auton.log
^{}Do not exit with return code if presentFalse
^{}auton job uidrandom uuid
^{}autond URI(s)
(e.g. http://auton-01.example.org:8666,http://auton-02.example.org:8666)

自动结束配置

参见配置示例etc/auton/auton.yml.example

终点

在本例中,我们声明了三个端点:ansible playbook ssh、ansible playbook http和curl。 他们使用subpc插件。

endpoints:ansible-playbook-ssh:plugin:subprocconfig:prog:ansible-playbooktimeout:3600args:-'/etc/ansible/playbooks/ssh-install.yml'-'--tags'-'sshd'become:enabled:trueenv:DISPLAY_SKIPPED_HOSTS:'false'ansible-playbook-http:plugin:subprocconfig:prog:ansible-playbooktimeout:3600args:-'/etc/ansible/playbooks/http-install.yml'-'--tags'-'httpd'become:enabled:trueenv:DISPLAY_SKIPPED_HOSTS:'false'curl:plugin:subprocconfig:prog:curltimeout:3600

认证

要启用身份验证,必须在general部分中添加auth_basicauth_basic_file行:

auth_basic:'Restricted'auth_basic_file:'/etc/auton/auton.passwd'

使用htpasswd生成auth_basic_file

htpasswd -c -s /etc/auton/auton.passwd foo

您必须为每个模块添加路由auth: true

modules:job:routes:run:handler:'job_run'regexp:'^run/(?P<endpoint>[^\/]+)/(?P<id>[a-z0-9][a-z0-9\-]{7,63})$'safe_init:trueauth:trueop:'POST'status:handler:'job_status'regexp:'^status/(?P<endpoint>[^\/]+)/(?P<id>[a-z0-9][a-z0-9\-]{7,63})$'auth:trueop:'GET'

使用节users指定端点允许的用户:

ansible-playbook-ssh:plugin:subprocusers:maintainer:truebob:trueconfig:prog:ansible-playbooktimeout:3600args:-'/etc/ansible/playbooks/ssh-install.yml'-'--tags'-'sshd'become:enabled:trueenv:DISPLAY_SKIPPED_HOSTS:'false'

插件子程序

suboc插件使用pythonsubprocess执行程序。

执行期间预定义的auton环境变量:

VariableDescription
^{}Mark the job is executed in AUTON environment
^{}Current time in local time zone
^{}Current time in GMT
^{}Current job uid passed from client
^{}Unique ID of the current job

使用关键字proc指定程序路径:

endpoints:curl:plugin:subprocconfig:prog:curl

使用关键字workdir更改工作目录:

endpoints:curl:plugin:subprocconfig:prog:curlworkdir:somedir/

使用关键字search_paths指定要搜索的路径prog

endpoints:curl:plugin:subprocconfig:prog:curlsearch_paths:-/usr/local/bin-/usr/bin-/bin

使用节become与其他用户一起执行:

endpoints:curl:plugin:subprocconfig:prog:curlbecome:enabled:trueuser:foo

使用关键字timeout在n秒后引发异常(默认值:60秒):

endpoints:curl:plugin:subprocconfig:prog:curltimeout:3600

使用节args定义始终存在的参数:

endpoints:curl:plugin:subprocconfig:prog:curlargs:-'-s'-'-4'

使用关键字disallow-args禁用客户端的参数:

endpoints:curl:plugin:subprocconfig:prog:curlargs:-'-vvv'-'https://example.com'disallow-args:true

使用节argfiles定义始终存在的参数文件:

endpoints:curl:plugin:subprocconfig:prog:curlargfiles:-arg:'--key'filepath:/tmp/private_key-arg:'-d@'filepath:/tmp/data

使用关键字disallow-argfiles禁用来自客户端的参数文件:

endpoints:curl:plugin:subprocconfig:prog:curlargfiles:-arg:'--key'filepath:/tmp/private_key-arg:'-d@'filepath:/tmp/datadisallow-argfiles:true

使用env部分定义始终存在的环境变量:

endpoints:curl:plugin:subprocconfig:prog:curlenv:HTTP_PROXY:http://proxy.example.com:3128/HTTPS_PROXY:http://proxy.example.com:3128/

使用envfiles部分定义始终存在的环境变量文件:

endpoints:curl:plugin:subprocconfig:prog:curlenvfiles:-somedir/foo.env-somedir/bar.env

使用关键字disallow-env禁用客户端的环境变量:

endpoints:curl:plugin:subprocconfig:prog:curlenv:HTTP_PROXY:http://proxy.example.com:3128/HTTPS_PROXY:http://proxy.example.com:3128/disallow-env:true

自动命令行

端点卷曲示例:

获取urlhttps://example.com

auton --endpoint curl --uri http://localhost:8666 -a 'https://example.com'

使用自动身份验证获取urlhttps://example.com

auton --endpoint curl --uri http://localhost:8666 --auth-user foo --auth-passwd bar -a 'https://example.com'

添加环境变量http_proxy:

auton --endpoint curl --uri http://localhost:8666 -a 'https://example.com' -e 'HTTP_PROXY=http://proxy.example.com:3128/'

从本地文件加载环境变量:

auton --endpoint curl --uri http://localhost:8666 -a 'https://example.com' --load-envfile foo.env

告诉autond从其本地fs加载环境变量文件:

auton --endpoint curl --uri http://localhost:8666 -a 'https://example.com' --envfile /etc/auton/auton.env

添加多个autond uri以获得高可用性:

auton --endpoint curl --uri http://localhost:8666 --uri http://localhost:8667 -a 'https://example.com'

添加参数文件以发送本地文件:

auton --endpoint curl --uri http://localhost:8666 -A '--cacert=cacert.pem' -a 'https://example.com'

添加多个参数:

auton --endpoint curl --uri http://localhost:8666 --multi-args '-vvv -u foo:bar https://example.com' --multi-argsfiles '-d@=somedir/foo.txt -d@=bar.txt --cacert=cacert.pem'

使用-

从stdin获取文件内容

cat foo.txt | auton --endpoint curl --uri http://localhost:8666 --multi-args '-vvv -u foo:bar sftp://example.com' --multi-argsfiles '--key=private_key.pem --pubkey=public_key.pem -T=-'

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在ArrayList中比较数字   java在Kotlin中使异步调用同步   让“Scala编程”junit示例在IntelliJ中工作的java问题   java Servlet侦听器未在ContextListener中设置属性   将Microsoft SQL Server数据库连接到我的Java项目   加载资源时出现java“需要注册工厂”异常   java如何使用POI检查excel中的重复记录?   java如何更改机器生成的代码   java如何确保重写的方法是同步的   用Spring编写Hibernate时的java XML奥秘   java管理mysql数据库中存储的用户权限   java如何运行。来自Javascript的jar方法   java我想在Web应用程序中进行身份验证&对桌面应用程序使用相同的凭据。我该怎么做?