Skip to content

Commit b76235b

Browse files
author
kogeler
committed
secure_apt role was added
Signed-off-by: kogeler <[email protected]>
1 parent 009b835 commit b76235b

File tree

7 files changed

+84
-16
lines changed

7 files changed

+84
-16
lines changed

.gitignore

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
.*.swp
2-
.terraform
3-
plan.out
4-
*.tfstate.backup
52
/*json
63
/*key
74
*private.key
85
*service-account-key.json
96
*.private_key_encrypted
10-
.idea
117
/ansible/collections
12-
venv
8+
venv
9+
.idea

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Ansible Collection - paritytech.chain_operations
1+
# Ansible Collection - paritytech.chain
22

33
## Install Ansible collections
44

@@ -7,7 +7,15 @@ Create `requirements.yml` file in your playbook repository (or add to the existi
77
collections:
88
- name: https://github.com/paritytech/ansible-galaxy.git
99
type: git
10-
version: main
10+
version: 1.6.2
11+
```
12+
13+
or
14+
15+
```yaml
16+
collections:
17+
- name: paritytech.chain
18+
version: 1.6.2
1119
```
1220
1321
If you want to install collections in the project space, you have to run:
@@ -24,4 +32,9 @@ ansible-galaxy collection install -f -r requirements.yml
2432

2533
## Roles
2634

27-
Node role - [README](./roles/node/README.md)
35+
* key_inject - [README](./roles/key_inject/README.md)
36+
* node - [README](./roles/node/README.md)
37+
* node_backup - [README](./roles/node_backup/README.md)
38+
* secure_apt - [README](./roles/secure_apt/README.md)
39+
* state_exporter - [README](./roles/state_exporter/README.md)
40+
* ws_health_exporter - [README](./roles/ws_health_exporter/README.md)

galaxy.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ namespace: paritytech
88
name: chain
99

1010
# The version of the collection. Must be compatible with semantic versioning
11-
version: 1.6.0
11+
version: 1.6.2
1212

1313
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
1414
readme: README.md
1515

1616
# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
1717
# @nicks:irc/im.site#channel'
1818
authors:
19-
- Devops Team <[email protected]>
19+
- Devops Team <[email protected]>
2020

2121
### OPTIONAL but strongly recommended
2222
# A short summary description of the collection
@@ -25,7 +25,7 @@ description: parity chain operations
2525
# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only
2626
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
2727
license:
28-
- GPL-2.0-or-later
28+
- GPL-2.0-or-later
2929

3030
# The path to the license file for the collection. This path is relative to the root of the collection. This key is
3131
# mutually exclusive with 'license'
@@ -42,20 +42,19 @@ tags: []
4242
dependencies: {}
4343

4444
# The URL of the originating SCM repository
45-
repository: "https://github.com/paritytech/ansible-galaxy.git"
45+
repository: https://github.com/paritytech/ansible-galaxy.git
4646

4747
# The URL to any online docs
48-
documentation: http://docs.example.com
48+
documentation: https://github.com/paritytech/ansible-galaxy
4949

5050
# The URL to the homepage of the collection/project
51-
homepage: http://example.com
51+
homepage: https://parity.io
5252

5353
# The URL to the collection issue tracker
54-
issues: http://example.com/issue/tracker
54+
issues: https://github.com/paritytech/ansible-galaxy/issues
5555

5656
# A list of file glob-like patterns used to filter any files or directories that should not be included in the build
5757
# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This
5858
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
5959
# and '.git' are always filtered
6060
build_ignore: []
61-

roles/secure_apt/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Role Name
2+
=========
3+
4+
A role to apply an APT repository + key securely as the apt_key Ansible module is deprecated
5+
6+
Requirements
7+
--------------
8+
9+
* You have to be able to use `become`
10+
11+
Example Playbook
12+
----------------
13+
14+
- hosts: servers
15+
roles:
16+
- paritytech.common.secure_apt
17+
vars:
18+
secure_apt_key: B53DC80D13EDEF05
19+
secure_apt_repositories:
20+
- https://packages.cloud.google.com/apt cloud-sdk-{{ ansible_distribution_release }} main

roles/secure_apt/defaults/main.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
secure_apt_keyserver: keyserver.ubuntu.com
3+
4+
secure_apt_key: ""
5+
6+
secure_apt_repositories: []
7+
8+
secure_apt_update_cache: true

roles/secure_apt/tasks/main.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
3+
- name: Create custom keyring directory
4+
ansible.builtin.file:
5+
path: "{{ _secure_apt_keyring_folder }}"
6+
state: directory
7+
mode: 0755
8+
9+
- name: Add APT key
10+
ansible.builtin.apt_key:
11+
id: "{{ secure_apt_key }}"
12+
keyring: "{{ _secure_apt_keyring_folder }}/{{ secure_apt_key }}.gpg"
13+
keyserver: "{{ secure_apt_keyserver }}"
14+
# Causes a fatal error in check mode due to apt-key + grep
15+
# more info: https://github.com/ansible/ansible/issues/28820
16+
ignore_errors: "{{ ansible_check_mode }}"
17+
18+
- name: Set restrictive permissions for key file
19+
ansible.builtin.file:
20+
path: "{{ _secure_apt_keyring_folder }}/{{ secure_apt_key }}.gpg"
21+
mode: 0444
22+
# Causes a fatal error in check mode
23+
ignore_errors: "{{ ansible_check_mode }}"
24+
25+
- name: Add APT repository
26+
ansible.builtin.apt_repository:
27+
repo: "deb [arch=amd64 signed-by={{ _secure_apt_keyring_folder }}/{{ secure_apt_key }}.gpg] {{ item }}"
28+
update_cache: "{{ secure_apt_update_cache }}"
29+
loop: "{{ secure_apt_repositories }}"

roles/secure_apt/vars/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
_secure_apt_keyring_folder: /usr/local/share/keyring

0 commit comments

Comments
 (0)