Debian Codegraph @

ansible_collections/community/sops/tests/ee/roles/lookup_sops/tasks/main.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Test lookup with missing file
7 set_fact:
8 sops_file_does_not_exists: "{{ lookup('community.sops.sops', 'file-does-not-exists.sops.yml') }}"
9 ignore_errors: true
10 register: sops_lookup_missing_file
11
12 - assert:
13 that:
14 - "sops_lookup_missing_file is failed"
15 - "'could not locate file in lookup: file-does-not-exists.sops.yml' in sops_lookup_missing_file.msg"
16
17 - name: Test lookup with missing file with empty_on_not_exist
18 set_fact:
19 sops_file_does_not_exists_empty: "{{ lookup('community.sops.sops', 'file-does-not-exists.sops.yml', empty_on_not_exist=true) }}"
20 register: sops_lookup_missing_file_empty_on_not_exist
21
22 - assert:
23 that:
24 - "sops_lookup_missing_file_empty_on_not_exist is success"
25 - "sops_file_does_not_exists_empty == ''"
26
27 - name: Test lookup of non-sops file
28 set_fact:
29 sops_wrong_file: "{{ lookup('community.sops.sops', 'wrong.yaml') }}"
30 ignore_errors: true
31 register: sops_lookup_wrong_file
32
33 - assert:
34 that:
35 - "sops_lookup_wrong_file is failed"
36 - "'sops metadata not found' in sops_lookup_wrong_file.msg"
37
38 - name: Test simple lookup
39 set_fact:
40 sops_success: "{{ lookup('community.sops.sops', 'simple.sops.yaml') }}"
41 register: sops_lookup_simple
42
43 - assert:
44 that:
45 - "sops_lookup_simple is success"
46 - "sops_success == 'foo: bar'"