Concerning: Ansible-Playbooks
Is it possible to run a command on the remote machine and store the resulting output into a variable? I am trying to get the kernel version and install the matching headers like this:
---
- hosts: all
tasks:
- name: install headers
become: yes
become_method: sudo
apt:
name: "{{ packages }}"
vars:
packages:
- linux-headers-`uname -r`
#- a lot of other packages here
Unfortunately uname -r
is not executed here.
I am aware of this question: Ansible: Store command's stdout in new variable? But it looks like this is another topic.