Add --with-colons option

This option tells gpg to use a colon-separated output format intended for parsing
by scripts rather than reading by humans. From my experience it is also less likely
to truncate the key id we are grepping for here, which would cause the grep
command to miss the key id, even when it exists in the key database.
This commit is contained in:
Charlie O'Keefe 2018-04-12 14:10:36 -06:00
parent 1e696ce2be
commit 90151b3471
1 changed files with 1 additions and 1 deletions

View File

@ -1,6 +1,6 @@
---
- name: Check that the secret key exists.
local_action: "shell gpg2 --list-secret-keys | grep {{ gpg_key_id }}"
local_action: "shell gpg2 --list-secret-keys --with-colons | grep {{ gpg_key_id }}"
register: gpg_list_keys_result
environment:
GNUPGHOME: "{{ lookup('env', 'HOME') }}/.gnupg"