Search code examples
ansiblepython-module

How do I get some data from a website which requires authentication with Ansbile?


I have been trying to login a web page and get/download some specific data from there, but couldn't make it. Is it possible?


Solution

  • If you need to download a specific file, and you can get it via http://username:[email protected]/path/file.conf then you can use the get_url module:

    - name: < Fetch file that requires authentication.
      get_url:
        url: http://example.com/path/file.conf
        dest: /etc/foo.conf
        url_username: bar
        url_password: '{{ mysecret }}'
    

    https://docs.ansible.com/ansible/latest/modules/get_url_module.html