我如何从需要使用Ansbile进行身份验证的网站获取一些数据?

问题描述 投票:0回答:2

我一直试图登录网页并从中获取/下载一些特定数据,但无法成功。可能吗?

ansible python-module
2个回答
0
投票

如果需要下载特定文件,并且可以通过http://username:[email protected]/path/file.conf进行下载,则可以使用get_url模块:

- 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


0
投票

如果您需要任意身份验证,为什么不只用普通的python / bash编写它并使用Ansible触发脚本,以使您不受Ansible身份验证支持的约束?

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

© www.soinside.com 2019 - 2024. All rights reserved.