From c665c379bf0d13b4f555d4fbe8dba50a975995b1 Mon Sep 17 00:00:00 2001 From: Juan Badia Payno Date: Thu, 30 Sep 2021 14:21:02 +0200 Subject: [PATCH] bnr Use replace instead of lineinfile and grouped similar tasks in a loop Currently when the backup is executed and the history is kept, there was two tasks that modify the configuration adding "timestamp" to the name of the files of a couple of variables. The modification of the configuration was done by lineinfile, but it added the line whether exits or not. That's why the use of the replace module instead of lineinfile. This patch grouped these two tasks in one with a loop and also added the variable OUTPUT_PREFIX_PXE to be configured in case of integration with ironic. Change-Id: I0260c8b5d1a6ccbddf1029ee9a3af35cb77fd525 --- .../backup_and_restore/tasks/run_backup.yml | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/tripleo_ansible/roles/backup_and_restore/tasks/run_backup.yml b/tripleo_ansible/roles/backup_and_restore/tasks/run_backup.yml index b20ba2c66..310a658b6 100644 --- a/tripleo_ansible/roles/backup_and_restore/tasks/run_backup.yml +++ b/tripleo_ansible/roles/backup_and_restore/tasks/run_backup.yml @@ -76,23 +76,15 @@ tags: - bar_create_recover_image -- name: Modify ISO_PREFIX on /etc/rear/local.conf - lineinfile: +- name: Configuring /etc/rear/local.conf + replace: path: /etc/rear/local.conf - regexp: "^ISO_PREFIX.*" - line: ISO_PREFIX=$HOSTNAME-{{ bar_timestamp.stdout }} - when: - - tripleo_backup_and_restore_historical - tags: - - bar_create_recover_image - -- name: Modify BACKUP_PROG_ARCHIVE on /etc/rear/local.conf - lineinfile: - path: /etc/rear/local.conf - regexp: "^BACKUP_PROG_ARCHIVE.*" - line: BACKUP_PROG_ARCHIVE=$HOSTNAME-{{ bar_timestamp.stdout }} - when: - - tripleo_backup_and_restore_historical + regexp: "^{{ item }}.*" + replace: "{{ item }}=$HOSTNAME-{{ bar_timestamp.stdout }}" + loop: + - ISO_PREFIX + - BACKUP_PROG_ARCHIVE + - OUTPUT_PREFIX_PXE tags: - bar_create_recover_image