mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes #5353 create etc/hostname file in debian if it does not exist
This commit is contained in:
parent
7520bac8ce
commit
dee960716b
1 changed files with 6 additions and 0 deletions
|
@ -146,6 +146,12 @@ class DebianStrategy(GenericStrategy):
|
||||||
HOSTNAME_FILE = '/etc/hostname'
|
HOSTNAME_FILE = '/etc/hostname'
|
||||||
|
|
||||||
def get_permanent_hostname(self):
|
def get_permanent_hostname(self):
|
||||||
|
if not os.path.isfile(self.HOSTNAME_FILE):
|
||||||
|
try:
|
||||||
|
open(self.HOSTNAME_FILE, "a").write("")
|
||||||
|
except IOError, err:
|
||||||
|
self.module.fail_json(msg="failed to write file: %s" %
|
||||||
|
str(err))
|
||||||
try:
|
try:
|
||||||
f = open(self.HOSTNAME_FILE)
|
f = open(self.HOSTNAME_FILE)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue