Skip to content

Commit

Permalink
use ansible DEFAULT_LOCAL_TMP for files stored on the ansible control…
Browse files Browse the repository at this point in the history
…ler (fin ... fixes issue #354)
  • Loading branch information
Klaus Zerwes authored and Klaus Zerwes committed Nov 11, 2024
1 parent 395fb94 commit 152bd93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions roles/beats/tasks/beats-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@
block:
- name: Check the existance of cert on localhost
ansible.builtin.stat:
path: /tmp/{{ ansible_hostname }}-beats.zip
path: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-beats.zip"
register: beats_check_temporary_cert

- name: Move temporary zip file
ansible.builtin.copy:
src: /tmp/{{ ansible_hostname }}-beats.zip
dest: "/tmp/{{ ansible_hostname }}-beats.zip_{{ ansible_date_time.iso8601_micro }}"
src: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-beats.zip"
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-beats.zip_{{ ansible_date_time.iso8601_micro }}"
mode: preserve
when: beats_check_temporary_cert.stat.exists
register: beats_move_cert_file

- name: Remove temporary cert file
ansible.builtin.file:
path: /tmp/{{ ansible_hostname }}-beats.zip
path: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-beats.zip"
state: absent
when: beats_move_cert_file.changed

Expand Down Expand Up @@ -139,7 +139,7 @@
- name: Fetch certificate from ca host to master
ansible.builtin.fetch:
src: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}-beats.zip"
dest: "/tmp/{{ ansible_hostname }}-beats.zip"
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-beats.zip"
flat: yes
delegate_to: "{{ elasticstack_ca }}"
tags:
Expand All @@ -149,7 +149,7 @@

- name: Copy the certificate to actual node
ansible.builtin.unarchive:
src: "/tmp/{{ ansible_hostname }}-beats.zip"
src: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-beats.zip"
dest: "/etc/beats/certs/"
owner: root
group: root
Expand Down Expand Up @@ -196,7 +196,7 @@
- name: Fetch ca certificate from ca host to master
ansible.builtin.fetch:
src: "{{ elasticstack_ca_dir }}/ca.crt"
dest: /tmp/ca.crt
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt"
flat: yes
delegate_to: "{{ elasticstack_ca }}"
tags:
Expand All @@ -206,7 +206,7 @@

- name: Copy the ca certificate to actual node
ansible.builtin.copy:
src: /tmp/ca.crt
src: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt"
dest: /etc/beats/certs
owner: root
group: root
Expand Down
16 changes: 8 additions & 8 deletions roles/kibana/tasks/kibana-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@
block:
- name: Check the existance of cert on localhost
ansible.builtin.stat:
path: /tmp/{{ ansible_hostname }}-kibana.p12
path: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-kibana.p12"
register: kibana_check_temporary_cert

- name: Move temporary cert file
ansible.builtin.copy:
src: /tmp/{{ ansible_hostname }}-kibana.p12
dest: "/tmp/{{ ansible_hostname }}-kibana.p12_{{ ansible_date_time.iso8601_micro }}"
src: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-kibana.p12"
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-kibana.p12_{{ ansible_date_time.iso8601_micro }}"
mode: preserve
when: kibana_check_temporary_cert.stat.exists
register: kibana_move_cert_file

- name: Remove temporary cert file
ansible.builtin.file:
path: /tmp/{{ ansible_hostname }}-kibana.p12
path: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-kibana.p12"
state: absent
when: kibana_move_cert_file.changed

Expand Down Expand Up @@ -180,7 +180,7 @@
- name: Fetch certificate from ca host to master
ansible.builtin.fetch:
src: "{{ elasticstack_ca_dir }}/{{ ansible_hostname }}-kibana.p12"
dest: "/tmp/"
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-kibana.p12"
flat: yes
delegate_to: "{{ elasticstack_ca }}"
tags:
Expand All @@ -190,7 +190,7 @@

- name: Copy the certificate to actual node
ansible.builtin.copy:
src: "/tmp/{{ ansible_hostname }}-kibana.p12"
src: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/{{ ansible_hostname }}-kibana.p12"
dest: "/etc/kibana/certs"
owner: root
group: kibana
Expand All @@ -215,7 +215,7 @@
- name: Fetch ca certificate from ca host to master
ansible.builtin.fetch:
src: "{{ elasticstack_ca_dir }}/ca.crt"
dest: /tmp/ca.crt
dest: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt"
flat: yes
delegate_to: "{{ elasticstack_ca }}"
tags:
Expand All @@ -225,7 +225,7 @@

- name: Copy the ca certificate to actual node
ansible.builtin.copy:
src: /tmp/ca.crt
src: "{{ lookup('config', 'DEFAULT_LOCAL_TMP') | dirname }}/ca.crt"
dest: /etc/kibana/certs
owner: root
group: kibana
Expand Down

0 comments on commit 152bd93

Please sign in to comment.