在处理程序/main.ml中,我得到了:
- name: get API information for wp-config
uri:
url: "https://api.wordpress.org/secret-key/1.1/salt/"
return_contents: yes
register: api_info我试图运行的任务是:
- name: copy sample config file
copy:
src: /var/www/wordpress/wp-config-sample.php
dest: /var/www/wordpress/wp-config.php
remote_src: yes
notify: get API information for wp-config
- name: run API handler now
meta: flush_handlers
- name: insert unique key and salts in wp-config
lineinfile:
path: /var/www/wordpress/wp-config.php
regex: "put your unique phrase here"
insertafter: "put your unique phrase here"
line: "{{ api_info }}"不幸的是,变量api_info的值不是内容本身,而是:
{'status': 200, 'cookies': {}, 'date': 'Thu, 25 Oct 2018 14:53:42 GMT', 'url': 'https://api.wordpress.org/secret-key/1.1/salt/', 'transfer_encoding': 'chunked', 'changed': False, 'server': 'nginx', 'failed': False, 'connection': 'close', 'content_type': 'text/plain;charset=utf-8', 'msg': 'OK (unknown bytes)', 'redirected': False, 'x_frame_options': 'SAMEORIGIN', 'cookies_string': ''}我怎样才能得到网站的实际内容?
提前感谢!
发布于 2018-10-25 15:27:07
有一个小错误,参数是return_content而不是return_contents,uri模块将返回api_info.content下uri调用的内容。
---
- hosts: localhost
tasks:
- name: get API information for wp-config
uri:
url: "https://api.wordpress.org/secret-key/1.1/salt/"
return_content: True
method: GET
register: api_info
- debug:
msg: "{{ api_info.content }}"https://serverfault.com/questions/937207
复制相似问题