Skip to content

Commit

Permalink
Fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
klention committed Dec 18, 2024
1 parent 3097f7a commit 5069421
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 30 deletions.
4 changes: 2 additions & 2 deletions automation/add_pgnode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
tasks_from: copy_certificate
vars:
tls_job: fetch
when: tls_cert_generate|bool
when: tls_cert_generate | bool

roles:
- role: ansible-role-firewall
Expand Down Expand Up @@ -242,7 +242,7 @@
tasks_from: copy_certificate
vars:
tls_job: copy
when: tls_cert_generate|bool
when: tls_cert_generate | bool

roles:
- role: wal-g
Expand Down
62 changes: 34 additions & 28 deletions automation/roles/tls_certificate/tasks/copy_certificate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ansible.builtin.fetch:
src: "{{ item }}"
dest: "/tmp/tls/"
flat: yes
flat: true
loop:
- "{{ tls_privatekey_path | default('/etc/tls/server.key') }}"
- "{{ tls_cert_path | default('/etc/tls/server.crt') }}"
Expand All @@ -13,35 +13,41 @@
- tls_job == 'fetch'

- block:
- name: Ensure TLS directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ tls_owner | default('postgres') }}"
group: "{{ tls_owner | default('postgres') }}"
mode: "0750"
loop:
- "{{ tls_privatekey_path | default('/etc/tls/server.key') | dirname }}"
- "{{ tls_cert_path | default('/etc/tls/server.crt') | dirname }}"
- name: Ensure TLS directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ tls_owner | default('postgres') }}"
group: "{{ tls_owner | default('postgres') }}"
mode: "0750"
loop:
- "{{ tls_privatekey_path | default('/etc/tls/server.key') | dirname }}"
- "{{ tls_cert_path | default('/etc/tls/server.crt') | dirname }}"

- name: Copy TLS certificate and key to the new node
ansible.builtin.copy:
src: "/tmp/tls/{{ item | basename }}"
dest: "{{ item }}"
loop:
- "{{ tls_privatekey_path | default('/etc/tls/server.key') }}"
- "{{ tls_cert_path | default('/etc/tls/server.crt') }}"
- name: Copy TLS certificate and key to the new node
ansible.builtin.copy:
src: "/tmp/tls/{{ item | basename }}"
dest: "{{ item }}"
loop:
- "{{ tls_privatekey_path | default('/etc/tls/server.key') }}"
- "{{ tls_cert_path | default('/etc/tls/server.crt') }}"

- name: Set proper permissions for TLS files
ansible.builtin.file:
path: "{{ item.path }}"
owner: "{{ tls_owner | default('postgres') }}"
group: "{{ tls_owner | default('postgres') }}"
mode: "{{ item.mode }}"
state: file
loop:
- { path: "{{ tls_privatekey_path | default('/etc/tls/server.key') }}", mode: "0400" }
- { path: "{{ tls_cert_path | default('/etc/tls/server.crt') }}", mode: "0644" }
- name: Set proper permissions for TLS files
ansible.builtin.file:
path: "{{ item.path }}"
owner: "{{ tls_owner | default('postgres') }}"
group: "{{ tls_owner | default('postgres') }}"
mode: "{{ item.mode }}"
state: file
loop:
- { path: "{{ tls_privatekey_path | default('/etc/tls/server.key') }}", mode: "0400" }
- { path: "{{ tls_cert_path | default('/etc/tls/server.crt') }}", mode: "0644" }

- name: Delete TLS certificate and key from the ansible controller
ansible.builtin.file:
path: "/tmp/tls/"
state: absent
delegate_to: localhost
when:
- tls_job is defined
- tls_job == 'copy'

0 comments on commit 5069421

Please sign in to comment.