Skip to content

Commit

Permalink
Make ansible task idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Feb 5, 2024
1 parent 5213d70 commit 2100b2d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tf/environments/production/ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
- ca-certificates
- dirmngr

- name: Check if ClickHouse GPG keyring exists
ansible.builtin.stat:
path: /usr/share/keyrings/clickhouse-keyring.gpg
register: keyring_check

- name: Create a temporary directory for GPG
ansible.builtin.tempfile:
state: directory
register: gnupg_temp_dir
when: not keyring_check.stat.exists

- name: Import ClickHouse GPG key
ansible.builtin.command:
Expand All @@ -28,11 +34,13 @@
creates: "/usr/share/keyrings/clickhouse-keyring.gpg"
environment:
GNUPGHOME: "{{ gnupg_temp_dir.path }}"
when: not keyring_check.stat.exists

- name: Remove temporary directory
ansible.builtin.file:
path: "{{ gnupg_temp_dir.path }}"
state: absent
when: not keyring_check.stat.exists

- name: Ensure the keyring is readable
ansible.builtin.file:
Expand Down

0 comments on commit 2100b2d

Please sign in to comment.