Added proper set hostname

gitea-rework
Jef Roosens 2021-12-11 18:00:19 +01:00
parent e189517d27
commit 2da928a24b
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
3 changed files with 28 additions and 3 deletions

View File

@ -0,0 +1,8 @@
---
- name: update hosts
template:
src: hosts.j2
dest: /etc/hosts
owner: root
group: root
mode: 644

View File

@ -0,0 +1,5 @@
127.0.0.1 localhost {{ hostname }}
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

View File

@ -1,5 +1,17 @@
---
- name: Check current hostname
register: cur_hostname
shell: hostname
changed_when: false
- name: yeet
debug:
msg: "{{ cur_hostname }} - {{ hostname }}"
- name: Set hostname
hostname:
name: "{{ hostname }}"
use: debian
shell: "hostnamectl set-hostname {{ hostname }}"
# hostname:
# name: "{{ hostname }}"
# use: debian
notify: update hosts
when: cur_hostname.stdout != hostname