From 68b50ca05b067492fd4cea1bf73aadd9aff725ef Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sun, 19 Apr 2020 17:20:10 -0500 Subject: [PATCH] Rearrange set-hostnames and cloud-init removal In launch-node, we run two playbooks that aren't part of base. One sets the system's hostname and removes cloud-init, the other runs unattended update. We need to run the hostname setting in our functional tests so that the hosts behave as expected, but running the cloud-init removal is a little weird, since our test nodes already don't have it. Make it so that set-hostname actually just sets the hostname, and then run it in run-base. For running puppet, we need the host to have the correct hostname. Move cloud-init removal to the base-server role. Also move the autoremove into base-server, since it's probably a nice way to get rid of excess things. Change-Id: I53cb8c515444a7d73b839e799c5794b067429daa --- playbooks/roles/base-server/tasks/Debian.yaml | 4 ++++ playbooks/roles/set-hostname/README.rst | 3 +-- playbooks/roles/set-hostname/tasks/main.yml | 16 ++++++++-------- playbooks/set-hostnames.yaml | 2 +- playbooks/zuul/run-base.yaml | 2 ++ 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/playbooks/roles/base-server/tasks/Debian.yaml b/playbooks/roles/base-server/tasks/Debian.yaml index c74c71bef8..342c3577d4 100644 --- a/playbooks/roles/base-server/tasks/Debian.yaml +++ b/playbooks/roles/base-server/tasks/Debian.yaml @@ -41,8 +41,12 @@ - popularity-contest - lxd - lxd-client + - cloud-init state: absent +- name: Get rid of extra depends + command: apt-get autoremove -y + - name: Configure file limits copy: mode: 0644 diff --git a/playbooks/roles/set-hostname/README.rst b/playbooks/roles/set-hostname/README.rst index 5fc2cdca20..957763ea43 100644 --- a/playbooks/roles/set-hostname/README.rst +++ b/playbooks/roles/set-hostname/README.rst @@ -1,7 +1,6 @@ Set hostname -Remove ``cloud-init`` and statically set the hostname, hosts and -mailname +Statically set the hostname, hosts and mailname **Role Variables** diff --git a/playbooks/roles/set-hostname/tasks/main.yml b/playbooks/roles/set-hostname/tasks/main.yml index f7a82a514c..bf27c1f3fb 100644 --- a/playbooks/roles/set-hostname/tasks/main.yml +++ b/playbooks/roles/set-hostname/tasks/main.yml @@ -1,11 +1,11 @@ ---- -- name: Remove cloud-init - package: - name: cloud-init - state: absent - -- name: Get rid of cloud-init depends - command: apt-get autoremove -y +# Setting hostname with systemd apparently +# requires dbus. We have this on our cloud-provided +# nodes, but not on the minimal ones we get from +# nodepool. +- name: ensure dbus for working hostnamectl + apt: + name: dbus + state: present # Set hostname and /etc/hosts # Inspired by: diff --git a/playbooks/set-hostnames.yaml b/playbooks/set-hostnames.yaml index 4c608c5c68..4134d2b718 100644 --- a/playbooks/set-hostnames.yaml +++ b/playbooks/set-hostnames.yaml @@ -1,4 +1,4 @@ -- hosts: "{{ target }}" +- hosts: "!disabled" gather_facts: false user: root roles: diff --git a/playbooks/zuul/run-base.yaml b/playbooks/zuul/run-base.yaml index 9d011f070b..49dcbe7547 100644 --- a/playbooks/zuul/run-base.yaml +++ b/playbooks/zuul/run-base.yaml @@ -90,6 +90,8 @@ dest: /home/zuul/src/opendev.org/opendev/system-config/playbooks/host_vars/bridge.openstack.org.yaml become: true + - name: Set hostname on host + command: ansible-playbook -v /home/zuul/src/opendev.org/opendev/system-config/playbooks/set-hostnames.yaml - name: Run base.yaml command: ansible-playbook -v /home/zuul/src/opendev.org/opendev/system-config/playbooks/base.yaml - name: Run bridge service playbook