Set hostname if not set
This commit is contained in:
parent
f51ff2c29f
commit
0db3e3c135
1 changed files with 24 additions and 0 deletions
24
deploy.yml
24
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 }}"
|
||||
|
|
Loading…
Add table
Reference in a new issue