From 9e7f0152a00f0f856f11523b20b2ea463cb11794 Mon Sep 17 00:00:00 2001 From: Webster Mudge Date: Wed, 21 Aug 2024 18:42:54 -0400 Subject: [PATCH] Update to use tempfile directory Signed-off-by: Webster Mudge --- .../server/tasks/postgresql/template_fix.yml | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/roles/rdbms/server/tasks/postgresql/template_fix.yml b/roles/rdbms/server/tasks/postgresql/template_fix.yml index 1a04815e..deb49cd1 100644 --- a/roles/rdbms/server/tasks/postgresql/template_fix.yml +++ b/roles/rdbms/server/tasks/postgresql/template_fix.yml @@ -1,4 +1,4 @@ -# Copyright 2023 Cloudera, Inc. All Rights Reserved. +# Copyright 2024 Cloudera, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,24 +12,28 @@ # See the License for the specific language governing permissions and # limitations under the License. ---- +- name: Create a temporary SQL directory + ansible.builtin.tempfile: + state: directory + suffix: sql + register: __sql - name: Copy SQL to change template to UTF-8 - copy: + ansible.builtin.copy: src: files/utf8-template.sql - dest: "{{ local_temp_dir }}" + dest: "{{ __sql.path }}" owner: postgres group: postgres mode: 0660 - name: Run SQL to change template to UTF-8 - command: "psql -f {{ local_temp_dir }}/utf8-template.sql" + ansible.builtin.command: "psql -f {{ __sql.path }}/utf8-template.sql" become: yes become_user: postgres -- name: Remove SQL file - file: - path: "{{ local_temp_dir }}/utf8-template.sql" +- name: Remove temporary SQL directory + ansible.builtin.file: + path: "{{ __sql.path }}" state: absent become: yes become_user: postgres