init: ops-assistant codebase
This commit is contained in:
17
runbooks/cf_dns_update.yaml
Normal file
17
runbooks/cf_dns_update.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
version: 1
|
||||
name: cf_dns_update
|
||||
description: 更新 DNS 记录(按 record_id)
|
||||
steps:
|
||||
- id: update_dns
|
||||
action: ssh.exec
|
||||
on_fail: stop
|
||||
with:
|
||||
target: hwsg
|
||||
command: "CF_ACCOUNT_ID=${env_cf_account_id} CF_API_TOKEN=${env_cf_api_token} INPUT_ZONE_ID=${env.INPUT_ZONE_ID} INPUT_RECORD_ID=${env.INPUT_RECORD_ID} INPUT_TYPE=${env.INPUT_TYPE} INPUT_NAME=${env.INPUT_NAME} INPUT_CONTENT=${env.INPUT_CONTENT} INPUT_TTL=${env.INPUT_TTL} INPUT_PROXIED=${env.INPUT_PROXIED} python3 - <<'PY'\nimport os, requests\nzone=os.getenv('INPUT_ZONE_ID','')\nrec=os.getenv('INPUT_RECORD_ID','')\ntoken=os.getenv('CF_API_TOKEN','')\nemail=os.getenv('CF_API_EMAIL','')\nheaders={'Authorization':'Bearer '+token,'Content-Type':'application/json'}\nurl=f'https://api.cloudflare.com/client/v4/zones/{zone}/dns_records/{rec}'\npayload={\n 'type': os.getenv('INPUT_TYPE',''),\n 'name': os.getenv('INPUT_NAME',''),\n 'content': os.getenv('INPUT_CONTENT',''),\n}\nif os.getenv('INPUT_TTL',''):\n payload['ttl']=int(os.getenv('INPUT_TTL'))\nif os.getenv('INPUT_PROXIED','')!='':\n payload['proxied']=os.getenv('INPUT_PROXIED').lower()=='true'\nresp=requests.put(url, headers=headers, json=payload, timeout=15)\nprint(resp.text)\nPY"
|
||||
- id: assert
|
||||
action: assert.json
|
||||
on_fail: stop
|
||||
with:
|
||||
source_step: update_dns
|
||||
required_paths:
|
||||
- "success"
|
||||
Reference in New Issue
Block a user