From: Kienan Stewart Date: Thu, 15 Jun 2023 14:07:37 +0000 (-0400) Subject: ansible: Add optional play to replace common hostname patterns during release-ugprades X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=770f5ebe451fbde8557fcb9a042dacab5a398e2d;p=lttng-ci.git ansible: Add optional play to replace common hostname patterns during release-ugprades Change-Id: Id60d624b91fd6e66347017f337b4048a319ac1c5 --- diff --git a/automation/ansible/playbooks/release-upgrade.yml b/automation/ansible/playbooks/release-upgrade.yml index aeeeb13..fcc2d70 100644 --- a/automation/ansible/playbooks/release-upgrade.yml +++ b/automation/ansible/playbooks/release-upgrade.yml @@ -67,6 +67,24 @@ with_items: - "/var/backups/pre-{{next_release}}-backup.tgz" - "/var/backups/dpkg-selections-pre-{{next_release}}.txt" +- name: Update hostname + hosts: all + vars: + # eg. ansible-playbook -e '{"UPDATE_HOSTNAME":true}' playbooks/release-upgrade.yml + update_hostname: "{{lookup('vars', 'UPDATE_HOSTNAME', default='false')}}" + tasks: + - debug: + msg: "update_hostname: {{update_hostname}}" + - replace: + path: /etc/hostname + regexp: "{{ansible_distribution_release}}" + replace: "{{next_release}}" + when: update_hostname | bool + - replace: + path: /etc/hostname + regexp: "deb{{ansible_distribution_version}}" + replace: "deb{{ansible_distribution_version|int + 1 }}" + when: update_hostname | bool and ansible_distribution == 'Debian' - name: Debian major version upgrade hosts: all vars: