TASK [teamcity_backup : Create TeamCity backup via API] *****************************************************************************************************************************
ok: [138.201.152.166] => {"cache_control": "no-store", "changed": false, "connection": "close", "content": "ScheduledBackup_20170929_015922.zip", "content_type": "text/plain", "cookies": {"TCSESSIONID": "99E068D2587365EA57823B81D8A2FE0A"}, "date": "Thu, 28 Sep 2017 23:59:22 GMT", "failed": false, "msg": "OK (unknown bytes)", "redirected": false, "server": "Apache-Coyote/1.1", "set_cookie": "TCSESSIONID=99E068D2587365EA57823B81D8A2FE0A; Path=/; HttpOnly, RememberMe=\"\"; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly", "status": 200, "transfer_encoding": "chunked", "url": "http://teamcity:8111/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=false&fileName=ScheduledBackup"}
TASK [teamcity_backup : debug] ******************************************************************************************************************************************************
ok: [138.201.152.166] => {
"data_c": "VARIABLE IS NOT DEFINED!"
}
这里是http响应机构:
"content": "ScheduledBackup_20170929_015922.zip"
data_c没有定义,但我不明白为什么......你能帮助我吗?
角色/名/任务/ main.yml:
- name: Create TeamCity backup via API
uri:
url: 'http://teamcity:8111/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=false&fileName=ScheduledBackup'
method: POST
user: "{{ teamcity_backup_user }}"
password: "{{ teamcity_backup_user_password }}"
force_basic_auth: yes
return_content: yes
register: data_c
- debug: var=data_c
答案 0 :(得分:1)
缩进有问题,试试这个:
- name: Create TeamCity backup via API
uri:
url: 'http://teamcity:8111/httpAuth/app/rest/server/backup?includeConfigs=true&includeDatabase=true&includeBuildLogs=false&fileName=ScheduledBackup'
method: POST
user: "{{ teamcity_backup_user }}"
password: "{{ teamcity_backup_user_password }}"
force_basic_auth: yes
return_content: yes
register: data_c
- debug: var=data_c