Write variable to a file in Ansible

前端 未结 4 730
感动是毒
感动是毒 2020-12-24 04:34

I am pulling JSON via the URI module and want to write the received content out to a file. I am able to get the content and output it to the debugger so I know the content

4条回答
  •  执笔经年
    2020-12-24 04:55

    We can directly specify the destination file with the dest option now. In the below example, the output json is stored into the /tmp/repo_version_file

    - name: Get repository file repo_version model to set ambari_managed_repositories=false
      uri:
        url: 'http://:8080/api/v1/stacks/HDP/versions/3.1/repository_versions/1?fields=operating_systems/*'
        method: GET
        force_basic_auth: yes
        user: xxxxx
        password: xxxxx
        headers:
          "X-Requested-By": "ambari"
          "Content-type": "Application/json"
        status_code: 200
        dest: /tmp/repo_version_file
    

提交回复
热议问题