Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Problem downloading sha256sum.txt from github #143

Closed
sysbot opened this issue Jan 31, 2020 · 2 comments
Closed

Problem downloading sha256sum.txt from github #143

sysbot opened this issue Jan 31, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@sysbot
Copy link

sysbot commented Jan 31, 2020

What happened?
When running the ansible-node-exporter, upon running this task:

    - name: Get checksum list from github
      set_fact:
        _checksums: "{{ lookup('url', 'https://github.com/prometheus/node_exporter/releases/download/v' + node_exporter_version + '/sha256sums.txt', wantlist=True) | list }}"
      run_once: true

I get the following issue.

[19:01:16] cloudalchemy.node-exporter : Get checksum list from github | host | FAILED | 1742ms
{

It seemed that the results return is a 302, which the url did not follow. The option to follow seemed to be added in Ansible Devel. Switching to use uri worked.

Did you expect to see some different?

Expect this to succeed.

How to reproduce it (as minimally and precisely as possible):
Attempt to run/use the role.

Environment
Ubuntu 18.04

  • Role version:
https://github.com/cloudalchemy/ansible-node-exporter/releases/tag/0.19.0
  • Ansible version information:
root@c86f70a56fc7:/work# ansible --version
ansible 2.7.1
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.9 (default, Nov  7 2019, 10:44:02) [GCC 8.3.0]
  • Variables:
https://github.com/cloudalchemy/ansible-node-exporter/blob/master/tasks/preflight.yml#L78
  • Ansible playbook execution Logs:
[19:01:16] cloudalchemy.node-exporter : Get checksum list from github | host | FAILED | 1742ms
{
  - msg: An unhandled exception occurred while running the lookup plugin 'url'. Error was a <class 'ansible.errors.AnsibleError'>, original message: Received HTTP error for https://github.com/prometheus/node_exporter/releases/download/v0.18.1/sha256sums.txt : HTTP Error 400: Bad Request

Anything else we need to know?:
Work around at the moment is to patch the task with

    - name: Download checksum list from github
      uri:
        url: "{{ 'https://github.com/prometheus/node_exporter/releases/download/v' + node_exporter_version + '/sha256sums.txt' }}"
        method: GET
        return_content: true
        status_code: 200
        body_format: json
      register: _raw_checksum
      until: _raw_checksum.status == 200
      retries: 5
      run_once: true

    - name: "Get checksum list from github results"
      set_fact:
        _checksums: "{{ _raw_checksum.content.split('\n') }}"
      run_once: true

@sysbot sysbot added the bug Something isn't working label Jan 31, 2020
@paulfantom
Copy link
Member

I cannot reproduce it. Could you check if adding retries to set_fact task solves it?

@sysbot
Copy link
Author

sysbot commented Feb 2, 2020

Thanks for verifying. I found the issue. This is related to urllib automatically pick up netrc in [this][1]. When ~/.netrc exist, running NETRC= ansible-playbook ... will fix the issue.

[1] ansible/ansible#27293

@sysbot sysbot closed this as completed Feb 2, 2020
till added a commit to pngmbh/ansible-node-exporter that referenced this issue Jul 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants