ansible-ad-hoc

Use Ansible facts in an Ansible ad-hoc command

女生的网名这么多〃 提交于 2021-01-27 06:06:08
问题 Is it possible to use what would normally be included in ansible_facts in an Ansible adhoc command? For example, I have a file at /tmp/myFile on all of my servers and I'd like to do: ansible all -i [inventory file] -m fetch -a "src=/tmp/myFile dest=myFile-[insert ansible_hostname here]" Without having to make a whole playbook for it. 回答1: No you cannot refer to ansible facts in ansible cli. This is because when you run ansible ... -m fetch you are not getting the facts of the host(s) you are

Use Ansible facts in an Ansible ad-hoc command

偶尔善良 提交于 2021-01-27 06:05:00
问题 Is it possible to use what would normally be included in ansible_facts in an Ansible adhoc command? For example, I have a file at /tmp/myFile on all of my servers and I'd like to do: ansible all -i [inventory file] -m fetch -a "src=/tmp/myFile dest=myFile-[insert ansible_hostname here]" Without having to make a whole playbook for it. 回答1: No you cannot refer to ansible facts in ansible cli. This is because when you run ansible ... -m fetch you are not getting the facts of the host(s) you are

Ansible ad-hoc command filter JSON output by key or property

混江龙づ霸主 提交于 2019-12-19 11:56:38
问题 I'd like to filter the JSON output of ad-hoc ansible commands - e.g. grab the long list of "facts" for multiple hosts, and show only one that could be several levels deep, such as ansible_lsb.description , so I can quickly compare what versions of software they're running, check accurate times or timezones, whatever. This works: ansible myserver -m setup -a 'filter=ansible_lsb' myserver | SUCCESS => { "ansible_facts": { "ansible_lsb": { "codename": "wheezy", "description": "Debian GNU/Linux 7