S
S
silverjoe2016-11-27 18:48:08
linux
silverjoe, 2016-11-27 18:48:08

Ansible and `uname -r` or $(uname -r) runs on localhost. Why?

Faced such a bug (or feature?):
when trying to execute the command

ansible group01 -m apt -s -a "name=linux-headers-`uname -r` state=present"

or
ansible group01 -m apt -s -a "name=linux-headers-$(uname -r) state=present"

I receive in response:
hostXXX | FAILED >> {
    "failed": true,
    "msg": "No package matching 'linux-headers-16.1.0' is available"
}

I 'm running under Mac OS X.
Ansible version 1.9.3
on the remote host uname -r shows:
4.2.0-42-generic

if I execute uname -r in the terminal
16.1.0

Why is that? And how to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
silverjoe, 2016-11-28
@silverjoe

There was a discussion, but someone deleted it, they suggested a solution:
Melkij left a comment on the answer to the Ansible question and `uname -r` or $(uname -r) works on the local host. Why?
As a result, it turned out to be like this:

ansible a-install -m raw -s -a "apt install -y linux-headers-$(uname\ -r)"

M
Mystray, 2016-11-28
@Mystray

'uname=linux-headers-`uname -r` state=present'
in 'single' quotes, or escape \`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question