奥登德
autond的Python项目详细描述
汽车项目
auton是一个免费的开源软件,我们开发它来通过http协议在远程服务器上运行程序和命令行。 有两个程序,客户端为auton,服务器端为autond。 auton只是将命令行转换为http协议的助手,它能够转换基本参数、文件参数和环境变量。 例如,您可以使用auton from ci/cd在远程服务器上运行,只需配置端点即可:
如果需要执行新版本的软件,但不能在旧服务器上安装,则也可以使用auton。 或者测试程序执行。
快速启动
在Docker中使用Autond
docker-compose up -d
安装
服务器端自动发送
pip install autond
客户端的auton
pip install auton
环境变量
自动结束
Variable | Description | Default |
---|---|---|
^{ | Configuration file contents (e.g. ^{ | |
^{ | Log file path | /var/log/autond/daemon.log |
^{ | autond pid file path | /run/auton/autond.pid |
^{ | auton group | auton or root |
^{ | auton user | auton or root |
自动
Variable | Description | Default |
---|---|---|
^{ | user for authentication | |
^{ | password for authentication | |
^{ | name of endpoint | |
^{ | Log file path | /var/log/auton/auton.log |
^{ | Do not exit with return code if present | False |
^{ | auton job uid | random 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_basic
和auth_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环境变量:
Variable | Description |
---|---|
^{ | 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'
使用-
:
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=-'