Debian Codegraph @

ansible_collections/community/sops/tests/integration/targets/age/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: Determine whether sops, age, and sops with age are supported
7 set_fact:
8 supports_sops_and_age: >-
9 {{ sops_installed and age_installed and sops_version_remote is version('3.7.0', '>=') }}
10
11 - when: supports_sops_and_age
12 block:
13 - name: Create local temporary directory
14 tempfile:
15 state: directory
16 suffix: .test
17 delegate_to: localhost
18 register: local_tmp_dir
19
20 - name: Record local temporary directory
21 set_fact:
22 local_tmp_dir: "{{ local_tmp_dir.path }}"
23
24 - name: Create age keys
25 command: age-keygen --output {{ local_tmp_dir }}/{{ item }}
26 delegate_to: localhost
27 loop:
28 - identity_1
29 - identity_2
30 - identity_3
31 - identity_4
32
33 - vars:
34 identity_files:
35 - name: identities_all
36 id_files:
37 - identity_1
38 - identity_2
39 - identity_3
40 - identity_4
41 - name: identities_1_2_3
42 id_files:
43 - identity_1
44 - identity_2
45 - identity_3
46 - name: identities_4
47 id_files:
48 - identity_4
49 block:
50 - name: Create local identity files
51 copy:
52 dest: '{{ local_tmp_dir }}/{{ item.name }}'
53 content: |
54 {% for id_file in item.id_files %}
55 {{ lookup('file', local_tmp_dir ~ '/' ~ id_file) }}
56 {% endfor %}
57 delegate_to: localhost
58 loop: '{{ identity_files }}'
59
60 - name: Create remote identity files
61 copy:
62 dest: '{{ remote_tmp_dir }}/{{ item.name }}'
63 content: |
64 {% for id_file in item.id_files %}
65 {{ lookup('file', local_tmp_dir ~ '/' ~ id_file) }}
66 {% endfor %}
67 loop: '{{ identity_files }}'
68
69 - name: Read identity public keys
70 set_fact:
71 identity_1: "{{ lookup('file', local_tmp_dir ~ '/identity_1') | regex_search('public key: ([a-zA-Z0-9]+)', '\\1') | first }}"
72 identity_2: "{{ lookup('file', local_tmp_dir ~ '/identity_2') | regex_search('public key: ([a-zA-Z0-9]+)', '\\1') | first }}"
73 identity_3: "{{ lookup('file', local_tmp_dir ~ '/identity_3') | regex_search('public key: ([a-zA-Z0-9]+)', '\\1') | first }}"
74 identity_4: "{{ lookup('file', local_tmp_dir ~ '/identity_4') | regex_search('public key: ([a-zA-Z0-9]+)', '\\1') | first }}"
75
76 - include_tasks: test.yml
77 always:
78 - name: Delete temporary directory
79 file:
80 path: '{{ local_tmp_dir }}'
81 state: absent
82 delegate_to: localhost