Skip to content

Commit

Permalink
Update to use tempfile directory
Browse files Browse the repository at this point in the history
Signed-off-by: Webster Mudge <[email protected]>
  • Loading branch information
wmudge committed Aug 21, 2024
1 parent 18ae977 commit 9e7f015
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions roles/rdbms/server/tasks/postgresql/template_fix.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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

0 comments on commit 9e7f015

Please sign in to comment.