如何从需要 Ansible 身份验证的网站获取一些数据?
How do I get some data from a website which requires authentication with Ansbile?
我一直在尝试登录网页并从那里 get/download 一些特定数据,但无法成功。可能吗?
如果您需要下载特定文件,并且可以通过 http://username:password@example.com/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
如果您需要任意身份验证,为什么不直接写成正常 python/bash 并使用 Ansible 触发脚本,这样您就不会受到 Ansible 身份验证支持的限制?
https://docs.ansible.com/ansible/latest/modules/script_module.html
我一直在尝试登录网页并从那里 get/download 一些特定数据,但无法成功。可能吗?
如果您需要下载特定文件,并且可以通过 http://username:password@example.com/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
如果您需要任意身份验证,为什么不直接写成正常 python/bash 并使用 Ansible 触发脚本,这样您就不会受到 Ansible 身份验证支持的限制?
https://docs.ansible.com/ansible/latest/modules/script_module.html