diff --git a/roles/bootstrap-os/tasks/bootstrap-coreos.yml b/roles/bootstrap-os/tasks/bootstrap-coreos.yml
index b806d9f6dd2cb3343ee0084a834fb31e7e65c0ee..892da1c04463ca106456e4848a3e475ff2bda7f2 100644
--- a/roles/bootstrap-os/tasks/bootstrap-coreos.yml
+++ b/roles/bootstrap-os/tasks/bootstrap-coreos.yml
@@ -50,11 +50,3 @@
     name: "{{ item }}"
   with_items: "{{pip_python_modules}}"
 
-- name: Check configured hostname
-  shell: hostname
-  register: configured_hostname
-  check_mode: no
-
-- name: Assign inventory name to unconfigured hostnames
-  shell: sh -c "echo \"{{inventory_hostname}}\" > /etc/hostname; hostname \"{{inventory_hostname}}\""
-  when: (configured_hostname.stdout == 'localhost')
diff --git a/roles/bootstrap-os/tasks/main.yml b/roles/bootstrap-os/tasks/main.yml
index 4adefb39448bc5cd0392298960cd1236d8292a04..73268031e8027076848aa9bda4b177ae41825f78 100644
--- a/roles/bootstrap-os/tasks/main.yml
+++ b/roles/bootstrap-os/tasks/main.yml
@@ -16,4 +16,15 @@
   register: ostree
 
 - set_fact:
-    is_atomic: "{{ ostree.stat.exists }}"
\ No newline at end of file
+    is_atomic: "{{ ostree.stat.exists }}"
+
+- name: Gather nodes hostnames
+  setup:
+    gather_subset: '!all'
+    filter: ansible_hostname
+
+- name: Assign inventory name to unconfigured hostnames
+  hostname:
+    name: "{{inventory_hostname}}"
+  when: ansible_hostname == 'localhost'
+