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
(cherry picked from commit c665c379bf)
This commit is contained in:
Juan Badia Payno 2021-09-30 14:21:02 +02:00
parent d4e7df0338
commit 17859a5704
1 changed files with 8 additions and 16 deletions

View File

@ -57,23 +57,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