From 9532aec12f8df86c97ce42855fceaf8fa50814e8 Mon Sep 17 00:00:00 2001 From: Pantelis Roditis Date: Thu, 21 Nov 2024 13:16:22 +0200 Subject: [PATCH] introduce exec_before_replace flag for cases where we want the exec commands before the replace operations --- ansible/Dockerfiles/example/autoregister.yml | 9 ++++++++- ansible/Dockerfiles/example/variables.yml | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ansible/Dockerfiles/example/autoregister.yml b/ansible/Dockerfiles/example/autoregister.yml index a8077076c..29cb63241 100644 --- a/ansible/Dockerfiles/example/autoregister.yml +++ b/ansible/Dockerfiles/example/autoregister.yml @@ -58,6 +58,13 @@ replace: 'ETSCTF_{{item.code}}' backup: no + - name: BUILD_COMMANDS.exec + become_user: "{{item.become|default('root')}}" + become: true + when: BUILD_COMMANDS is defined and BUILD_COMMANDS.exec is defined and EXEC_BEFORE_REPLACE is defined + with_items: "{{BUILD_COMMANDS.exec}}" + raw: "{{item.cmd}}" + - name: BUILD_COMMANDS.replace when: BUILD_COMMANDS is defined and BUILD_COMMANDS.replace is defined @@ -71,7 +78,7 @@ - name: BUILD_COMMANDS.exec become_user: "{{item.become|default('root')}}" become: true - when: BUILD_COMMANDS is defined and BUILD_COMMANDS.exec is defined + when: BUILD_COMMANDS is defined and BUILD_COMMANDS.exec is defined and EXEC_BEFORE_REPLACE is not defined with_items: "{{BUILD_COMMANDS.exec}}" raw: "{{item.cmd}}" diff --git a/ansible/Dockerfiles/example/variables.yml b/ansible/Dockerfiles/example/variables.yml index 8d1e55df9..56f43f3d0 100644 --- a/ansible/Dockerfiles/example/variables.yml +++ b/ansible/Dockerfiles/example/variables.yml @@ -224,6 +224,8 @@ ETSCTF_TREASURES: #INI_FILES: # - { file: "/path/to/file.ini", section: "SECTION", option: OPTION, value: "VALUE"} +# Uncoment the following to run exec before replace +# EXEC_BEFORE_REPLACE: true # These commands are executed at build time by ansible BUILD_COMMANDS: # exec: