首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >注释:插入wordpress的内容、唯一的键和变量中的salt

注释:插入wordpress的内容、唯一的键和变量中的salt
EN

Server Fault用户
提问于 2018-10-25 14:57:10
回答 1查看 350关注 0票数 0

在处理程序/main.ml中,我得到了:

代码语言:javascript
复制
- name: get API information for wp-config
       uri:
        url: "https://api.wordpress.org/secret-key/1.1/salt/"
        return_contents: yes
       register: api_info

我试图运行的任务是:

代码语言:javascript
复制
- 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的值不是内容本身,而是:

代码语言:javascript
复制
{'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': ''}

我怎样才能得到网站的实际内容?

提前感谢!

EN

回答 1

Server Fault用户

发布于 2018-10-25 15:27:07

有一个小错误,参数是return_content而不是return_contentsuri模块将返回api_info.content下uri调用的内容。

代码语言:javascript
复制
---

- 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 }}"
票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/937207

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档