forked from ansible-collections/ansible-consul
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab7ac20
commit cb0ab1b
Showing
4 changed files
with
46 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
# File: tasks/encrypt_gossip.yml - Gossip encryption tasks for Consul | ||
|
||
- block: | ||
- name: Check for key on previously boostrapped server | ||
shell: 'cat {{ consul_config_path }}/bootstrap/config.json | grep "encrypt" | sed -E ''s/"encrypt": "(.+)",?/\1/'' | sed ''s/^ *//;s/ *$//''' | ||
register: consul_key_read | ||
run_once: true | ||
|
||
- name: Save encryption key (from existing config) | ||
set_fact: consul_raw_key={{ consul_key_read.stdout }} | ||
ignore_errors: yes | ||
|
||
when: consul_raw_key is not defined and bootstrap_marker.stat.exists | ||
|
||
- name: Writing key locally to share with other servers that are new | ||
local_action: copy content={{ consul_raw_key }} dest=/tmp/consul_raw.key | ||
become: no | ||
when: consul_raw_key is defined and bootstrap_marker.stat.exists | ||
|
||
- name: Reading key for servers that are missing it | ||
set_fact: consul_raw_key="{{ lookup('file', '/tmp/consul_raw.key') }}" | ||
when: consul_raw_key is not defined and bootstrap_marker.stat.exists | ||
|
||
- name: Deleting key file | ||
local_action: file path=/tmp/consul_raw.key state=absent | ||
become: no | ||
when: consul_raw_key is defined and bootstrap_marker.stat.exists | ||
|
||
- block: | ||
- name: Generate gossip encryption key | ||
shell: "PATH={{ consul_bin_path }}:$PATH consul keygen" | ||
register: consul_keygen | ||
run_once: true | ||
|
||
- name: Save encryption key | ||
set_fact: consul_raw_key={{ consul_keygen.stdout }} | ||
when: consul_raw_key is not defined and not bootstrap_marker.stat.exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v1.9.0 | ||
v1.9.1 |