отправить многострочную форму с модулем ansible uri - PullRequest
0 голосов
/ 25 сентября 2019

Я пытаюсь загрузить многострочный файл в контроллер appdynamics, используя модуль ansible uri.Любой совет?

Как вы заметите во фрагментах, я новичок в 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

Actual - Iполучить ответ 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  
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...