From 25020e469f4a6f913ebaf21a3dc812d1fcbfa53a Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 26 Jul 2022 13:58:38 +0100 Subject: [PATCH] Don't assume /etc/hosts exists The baremetal role adds entries to /etc/hosts. If the file does not exist, it will fail: TASK [baremetal : Ensure localhost in /etc/hosts] **************************************** fatal: [compute2]: FAILED! => {"changed": false, "msg": "Destination /etc/hosts does not exist !", "rc": 257} Though surprising, this is possible, and we should not assume that /etc/hosts exists. This change modifies the above task to create the file if it does not exist. Closes-Bug: #1982837 Change-Id: Ic419ee13a10b3fa1b890cfec23bab0a67489eb96 --- roles/baremetal/tasks/pre-install.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/baremetal/tasks/pre-install.yml b/roles/baremetal/tasks/pre-install.yml index 4ed43dd..4438626 100644 --- a/roles/baremetal/tasks/pre-install.yml +++ b/roles/baremetal/tasks/pre-install.yml @@ -4,6 +4,8 @@ dest: /etc/hosts regexp: "^127.0.0.1.*" line: "127.0.0.1 localhost" + create: true + mode: 0644 state: present become: True when: customize_etc_hosts | bool