我正在尝试使用ansible uri模块将多行文件上传到appdynamics控制器。有什么建议吗?
您会在摘要中注意到,我是Ansible的新手...
它在shell:curl上正常工作,但是对于更结构化的播放,我似乎无法正确获得输出。
作品- name: import health rule xml via curl
shell: "curl -i -X POST {{ APPD_HEALTH_RULE_URL }}/{{ APPD_APPLICATIAON_ID }}?overwrite={{ OVERWRITE_EXISTING_RULE }} -H {{ APPD_AUTH_TOKEN }} -F file=@{{ WORKSPACE }}/infrastructure_health_rule_template.xml"
register: health_rule
不起作用
- name: import health rule to application
uri:
url: "{{ APPD_HEALTH_RULE_URL }}/{{ APPD_APPLICATIAON_ID }}?overwrite={{ OVERWRITE_EXISTING_RULE }}"
method: POST
headers:
Authorization : "{{ APPD_TOKEN }}"
Content-Type : "multipart/form-data"
return_content : yes
follow_redirects : all
body_format : raw
body : msg="{{lookup('file', '{{ WORKSPACE }}/infrastructure_health_rule_template.xml') }}"
status_code:
- 100
- 200
- 201
- 202
- 300
- 301
- 302
- 307
register: health_rule
预期结果-我能够将健康规则成功导入AppD
实际-我收到200条回复,什么都没有发生。
响应:
ok: [localhost] => {
"age": "0",
"changed": false,
"connection": "close",
"content": "the request was rejected because no multipart boundary was found \n",
"cookies": {
"JSESSIONID": "NUMBERS & STUFF"
},
"cookies_string": "JSESSIONID=NUMBERS & STUFF",
"date": "Wed, 25 Sep 2019 20:25:07 GMT",
"elapsed": 0,
"invocation": {
"module_args": {
"attributes": null,
"backup": null,
"body": "<health-rules controller-version=\"VERSION HERE\">\n <health-rule>\n <name>Disk_Space_too_low</name>\n <type>INFRASTRUCTURE</type>\n <description/>\n <enabled>True</enabled>\n <is-default>false</is-default>\n <always-enabled>true</always-enabled>\n <duration-min>35</duration-min>\n <wait-time-min>35</wait-time-min>\n <affected-entities-match-criteria>\n <affected-infra-match-criteria>\n <type>NODES</type>\n <node-match-criteria>\n <type>CUSTOM</type>\n <match-type>STARTSWITH</match-type>\n <match-pattern>i-</match-pattern>\n <inverse>True</inverse>\n <node-meta-info-match-criteria/>\n <vm-sys-properties/>\n <env-properties/>\n </node-match-criteria>\n </affected-infra-match-criteria>\n </affected-entities-match-criteria>\n <critical-execution-criteria>\n <entity-aggregation-scope>\n <type>ANY</type>\n <value>0</value>\n </entity-aggregation-scope>\n <policy-condition>\n <type>leaf</type>\n <display-name>Hardware Resources|Volumes|Used %</display-name>\n <condition-value-type>ABSOLUTE</condition-value-type>\n <condition-value>90.0</condition-value>\n <operator>GREATER_THAN</operator>\n <condition-expression/>\n <use-active-baseline>False</use-active-baseline>\n <trigger-on-no-data>False</trigger-on-no-data>\n <metric-expression>\n <type>leaf</type>\n <function-type>VALUE</function-type>\n <value>0</value>\n <is-literal-expression>False</is-literal-expression>\n <display-name></display-name>\n <metric-definition>\n <type>LOGICAL_METRIC</type>\n <logical-metric-name>Hardware Resources|Volumes|Used (%)</logical-metric-name>\n </metric-definition>\n </metric-expression>\n </policy-condition>\n </critical-execution-criteria>\n <warning-execution-criteria>\n <entity-aggregation-scope>\n <type>ANY</type>\n <value>0</value>\n </entity-aggregation-scope>\n <policy-condition>\n <type>leaf</type>\n <display-name>Hardware Resources|Volumes|Used %</display-name>\n <condition-value-type>ABSOLUTE</condition-value-type>\n <condition-value>80.0</condition-value>\n <operator>GREATER_THAN</operator>\n <condition-expression/>\n <use-active-baseline>False</use-active-baseline>\n <trigger-on-no-data>False</trigger-on-no-data>\n <metric-expression>\n <type>leaf</type>\n <function-type>VALUE</function-type>\n <value>0</value>\n <is-literal-expression>False</is-literal-expression>\n <display-name></display-name>\n <metric-definition>\n <type>LOGICAL_METRIC</type>\n <logical-metric-name>Hardware Resources|Volumes|Used (%)</logical-metric-name>\n </metric-definition>\n </metric-expression>\n </policy-condition>\n </warning-execution-criteria>\n</health-rule>\n</health-rules>",
"body_format": "raw",
"client_cert": null,
"client_key": null,
"content": null,
"creates": null,
"delimiter": null,
"dest": null,
"directory_mode": null,
"follow": false,
"follow_redirects": "all",
"force": false,
"force_basic_auth": false,
"group": null,
"headers": {
"Authorization": "Bearer REALLY LONG STRING OF CHARACTERS",
"Content-Type": "multipart/form-data"
},
"http_agent": "ansible-httpget",
"method": "POST",
"mode": null,
"owner": null,
"regexp": null,
"remote_src": null,
"removes": null,
"return_content": true,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"status_code": [
100,
200,
201,
202,
300,
301,
302,
307
],
"timeout": 30,
"unix_socket": null,
"unsafe_writes": null,
"url": "####### URL #######",
"url_password": null,
"url_username": null,
"use_proxy": true,
"validate_certs": true
}
},
"msg": "OK (unknown bytes)",
"redirected": false,
"server": "AppDynamics",
"set_cookie": "JSESSIONID=NUMBERS & STUFF; Path=/controller; HttpOnly;Secure",
"status": 200,
"transfer_encoding": "chunked",
"url": "####### URL #######,
"via": "1.1 varnish",
"x_content_type_options": "Nosniff",
"x_frame_options": "SAMEORIGIN",
"x_varnish": "1299636501",
"x_xss_protection": "1; mode=block"
}
META: ran handlers
META: ran handlers
PLAY RECAP ***************************************************************************************************************
localhost : ok=5 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0