0

in handlers/main.yml I've got:

- name: get API information for wp-config
       uri:
        url: "https://api.wordpress.org/secret-key/1.1/salt/"
        return_contents: yes
       register: api_info

The tasks I'm trying to run are:

- 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 }}"

Unfortunately the value of variable api_info is not the content itself but:

{'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': ''}

How can I get the actual content of the site?

Thanks in advance!

0

there is a small typo, the parameter is return_content not return_contents and the the uri module will return the contents of the uri call under api_info.content

---

- 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 }}"
1
  • This is the second time I've posted an ansible playbook on the forum and in the previous post, the same problem. A typo. Although this could be harder to trace, as "return_contents" could also have been a valid option. Thanks for pointing it out. – Lethargos Oct 25 '18 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.