Debian Codegraph @

ansible_collections/community/sops/roles/install/tasks/main.yml

raw
1 ---
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4 # SPDX-FileCopyrightText: 2022, Felix Fontein
5
6 - name: Gather required information on localhost
7 when: sops_install_on_localhost
8 ansible.builtin.setup:
9 gather_subset:
10 - '!all'
11 - '!min'
12 - architecture
13 - distribution
14 - distribution_major_version
15 - distribution_version
16 - os_family
17 - pkg_mgr
18 delegate_to: localhost
19 delegate_facts: true
20 run_once: true
21
22 - vars:
23 _community_sops_install_facts: >-
24 {{ hostvars['localhost' if sops_install_on_localhost else inventory_hostname].ansible_facts }}
25 block:
26 - name: Show system information
27 ansible.builtin.debug:
28 msg: |-
29 Architecture: {{ _community_sops_install_facts.architecture }}
30 Distribution: {{ _community_sops_install_facts.distribution }} {{ _community_sops_install_facts.distribution_major_version }}
31 Distribution version: {{ _community_sops_install_facts.distribution_version }}
32 OS family: {{ _community_sops_install_facts.os_family }}
33 System package manager: {{ _community_sops_install_facts.pkg_mgr }}
34
35 - name: Include distribution specific variables
36 ansible.builtin.include_vars: '{{ lookup("ansible.builtin.first_found", params) }}'
37 vars:
38 params:
39 files:
40 - >-
41 D-{{ _community_sops_install_facts.distribution }}-{{ _community_sops_install_facts.distribution_version }}.yml
42 - >-
43 D-{{ _community_sops_install_facts.distribution }}-{{ _community_sops_install_facts.distribution_major_version }}.yml
44 - >-
45 D-{{ _community_sops_install_facts.distribution }}.yml
46 - >-
47 OS-{{ _community_sops_install_facts.os_family }}-{{ _community_sops_install_facts.distribution_major_version }}.yml
48 - >-
49 OS-{{ _community_sops_install_facts.os_family }}.yml
50 - default.yml
51 paths:
52 - '{{ role_path }}/vars'
53
54 - name: Start determining source
55 ansible.builtin.set_fact:
56 _community_sops_install_effective_sops_source: '{{ sops_source }}'
57
58 - name: Auto-detect source to install SOPS from
59 ansible.builtin.include_tasks: detect_source.yml
60 when: _community_sops_install_effective_sops_source == 'auto'
61
62 - name: Install SOPS from GitHub
63 ansible.builtin.include_tasks: github.yml
64 when: _community_sops_install_effective_sops_source == 'github'
65
66 - name: Install SOPS from system package repositories
67 ansible.builtin.include_tasks: system.yml
68 when: _community_sops_install_effective_sops_source == 'system'
69
70 - name: Install system packages
71 ansible.builtin.package:
72 name: '{{ _community_sops_install_system_packages_actual }}'
73 allow_downgrade: '{{ true if _community_sops_install_allow_downgrade and sops_version != "latest" else omit }}'
74 become: '{{ sops_become_on_install }}'
75 delegate_to: '{{ "localhost" if sops_install_on_localhost else omit }}'
76 run_once: '{{ sops_install_on_localhost }}'
77 when: _community_sops_install_system_packages_actual | length > 0
78
79 - name: Install unsigned system packages
80 ansible.builtin.package:
81 name: '{{ _community_sops_install_system_packages_unsigned_actual }}'
82 allow_downgrade: '{{ true if _community_sops_install_allow_downgrade and sops_version != "latest" else omit }}'
83 disable_gpg_check: true
84 become: '{{ sops_become_on_install }}'
85 delegate_to: '{{ "localhost" if sops_install_on_localhost else omit }}'
86 run_once: '{{ sops_install_on_localhost }}'
87 when: _community_sops_install_system_packages_unsigned_actual | length > 0
88
89 - name: Install packages from URL/path (Debian)
90 ansible.builtin.apt:
91 deb: '{{ _community_sops_install_system_package_deb_actual }}'
92 allow_downgrade: '{{ true if _community_sops_install_allow_downgrade and sops_version != "latest" else omit }}'
93 become: '{{ sops_become_on_install }}'
94 delegate_to: '{{ "localhost" if sops_install_on_localhost else omit }}'
95 run_once: '{{ sops_install_on_localhost }}'
96 when: _community_sops_install_system_package_deb_actual is string
97
98 - name: Set results
99 ansible.builtin.set_fact:
100 sops_installed: true
101 delegate_to: '{{ "localhost" if sops_install_on_localhost else omit }}'
102 delegate_facts: '{{ true if sops_install_on_localhost else omit }}'