From 0db3e3c13574f0a8a35a4421f5ffa3e1e40fc4ac Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sat, 29 Jan 2022 21:17:51 +0000 Subject: [PATCH] Set hostname if not set --- deploy.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/deploy.yml b/deploy.yml index ff7d9dc..20a24a9 100644 --- a/deploy.yml +++ b/deploy.yml @@ -23,6 +23,30 @@ - thunderbird tasks: + - name: check hostname + ansible.builtin.command: + argv: + - hostnamectl + - hostname + - --static + register: hostname_check + changed_when: false + + - name: set hostname + ansible.builtin.command: + argv: + - hostnamectl + - hostname + - --static + - >- + {{ + lookup( + 'password', + '/dev/null chars=ascii_lowercase,digits length=4' + ) + }} + when: hostname_check.stdout == "" + - name: remove unneeded packages ansible.builtin.package: name: "{{ item }}"