From 006769b051676ddf94993286265aa45e18425159 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Mon, 1 Jan 2024 10:47:43 -0700 Subject: [PATCH] Fix "Update hostname." task. --- README.org | 16 +++++----------- roles_t/campus/handlers/main.yml | 4 ---- roles_t/campus/tasks/main.yml | 9 ++++++--- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/README.org b/README.org index 2d0dcfb..256dee2 100644 --- a/README.org +++ b/README.org @@ -5188,20 +5188,14 @@ Clients should be using the expected host name. dest: "{{ item.file }}" loop: - { file: /etc/hostname, - content: "{{ inventory_hostname }}" } + content: "{{ inventory_hostname }}\n" } - { file: /etc/mailname, - content: "{{ inventory_hostname }}.{{ domain_priv }}" } - when: inventory_hostname != ansible_hostname - notify: Update hostname. - -#+END_SRC + content: "{{ inventory_hostname }}.{{ domain_priv }}\n" } -#+CAPTION: [[file:roles_t/campus/handlers/main.yml][=roles_t/campus/handlers/main.yml=]] -#+BEGIN_SRC conf :tangle roles_t/campus/handlers/main.yml :mkdirp yes ---- - name: Update hostname. become: yes command: hostname -F /etc/hostname + when: inventory_hostname != ansible_hostname #+END_SRC ** Enable Systemd Resolved @@ -5238,8 +5232,8 @@ and include the institute's private domain in their search lists. #+END_SRC #+CAPTION: [[file:roles_t/campus/handlers/main.yml][=roles_t/campus/handlers/main.yml=]] -#+BEGIN_SRC conf :tangle roles_t/campus/handlers/main.yml - +#+BEGIN_SRC conf :tangle roles_t/campus/handlers/main.yml :mkdirp yes +--- - name: Reload Systemd. become: yes command: systemctl daemon-reload diff --git a/roles_t/campus/handlers/main.yml b/roles_t/campus/handlers/main.yml index adb4f4e..c929d42 100644 --- a/roles_t/campus/handlers/main.yml +++ b/roles_t/campus/handlers/main.yml @@ -1,8 +1,4 @@ --- -- name: Update hostname. - become: yes - command: hostname -F /etc/hostname - - name: Reload Systemd. become: yes command: systemctl daemon-reload diff --git a/roles_t/campus/tasks/main.yml b/roles_t/campus/tasks/main.yml index 9773336..e185415 100644 --- a/roles_t/campus/tasks/main.yml +++ b/roles_t/campus/tasks/main.yml @@ -11,11 +11,14 @@ dest: "{{ item.file }}" loop: - { file: /etc/hostname, - content: "{{ inventory_hostname }}" } + content: "{{ inventory_hostname }}\n" } - { file: /etc/mailname, - content: "{{ inventory_hostname }}.{{ domain_priv }}" } + content: "{{ inventory_hostname }}.{{ domain_priv }}\n" } + +- name: Update hostname. + become: yes + command: hostname -F /etc/hostname when: inventory_hostname != ansible_hostname - notify: Update hostname. - name: Install systemd-resolved. become: yes -- 2.25.1