mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-17 22:30:59 +00:00
hostname module: don't filter hostnamectl with awk
There's no need to filter hostnamectl's output with awk because its man
page says:
hostnamectl [OPTIONS...] {COMMAND}
--static, --transient, --pretty
If status is used (or no explicit command is given) and one
of those fields is given, hostnamectl will print out just
this selected hostname.
E.g. hostnamectl --static status => ansible.example.org
This commit is contained in:
committed by
Michael DeHaan
parent
0749112286
commit
138b45e32f
@@ -285,7 +285,7 @@ class FedoraStrategy(GenericStrategy):
|
|||||||
(rc, out, err))
|
(rc, out, err))
|
||||||
|
|
||||||
def get_permanent_hostname(self):
|
def get_permanent_hostname(self):
|
||||||
cmd = 'hostnamectl status | awk \'/^ *Static hostname:/{printf("%s", $3)}\''
|
cmd = 'hostnamectl --static status'
|
||||||
rc, out, err = self.module.run_command(cmd, use_unsafe_shell=True)
|
rc, out, err = self.module.run_command(cmd, use_unsafe_shell=True)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" %
|
self.module.fail_json(msg="Command failed rc=%d, out=%s, err=%s" %
|
||||||
|
|||||||
Reference in New Issue
Block a user