Skip to content

Commit b92d585

Browse files
authored
fix(ansible): pub key storing location for agnocast ppa package (#6603)
* fix pub key storing location for agnocast ppa package Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp> * delete unnecessary comments Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp> * fix ansible-lint Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp> * use copy module Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp> * remove legacy settings Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp> --------- Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
1 parent db9a31d commit b92d585

1 file changed

Lines changed: 70 additions & 5 deletions

File tree

ansible/roles/agnocast/tasks/main.yaml

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
# Remove legacy agnocast PPA configuration (if exists)
2+
- name: Remove legacy agnocast PPA via add-apt-repository
3+
ansible.builtin.command: add-apt-repository --remove ppa:t4-system-software/agnocast -y
4+
register: agnocast_legacy_ppa_remove
5+
failed_when: false
6+
changed_when: agnocast_legacy_ppa_remove.rc == 0
7+
become: true
8+
9+
- name: Remove legacy agnocast sources.list files
10+
ansible.builtin.shell: rm -f /etc/apt/sources.list.d/*agnocast*.list
11+
args:
12+
executable: /bin/bash
13+
register: agnocast_legacy_sources_remove
14+
changed_when: false
15+
become: true
16+
17+
- name: Remove legacy agnocast GPG keys from trusted.gpg.d
18+
ansible.builtin.shell: rm -f /etc/apt/trusted.gpg.d/*agnocast*.gpg
19+
args:
20+
executable: /bin/bash
21+
register: agnocast_legacy_gpg_remove
22+
changed_when: false
23+
become: true
24+
125
# TODO(rej55, sykwer): IPv6 support
226
- name: Save current IPv6 settings
327
ansible.builtin.shell: |
@@ -18,11 +42,52 @@
1842
- { name: net.ipv6.conf.default.disable_ipv6 }
1943
become: true
2044

21-
- name: Add agnocast PPA repository while IPv6 is disabled
22-
ansible.builtin.apt_repository:
23-
repo: ppa:t4-system-software/agnocast
24-
state: present
25-
update_cache: false
45+
- name: Create /etc/apt/keyrings directory
46+
ansible.builtin.file:
47+
path: /etc/apt/keyrings
48+
state: directory
49+
mode: "0755"
50+
become: true
51+
52+
- name: Download agnocast PPA GPG key while IPv6 is disabled
53+
ansible.builtin.get_url:
54+
url: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xCFDB1950382092423DF37D3E075CD8B5C91E5ACA
55+
dest: /tmp/agnocast-ppa.asc
56+
mode: "0644"
57+
register: agnocast_gpg_key_download
58+
59+
- name: Convert GPG key to binary format and install
60+
ansible.builtin.shell: |
61+
gpg --dearmor < /tmp/agnocast-ppa.asc > /etc/apt/keyrings/agnocast-ppa.gpg
62+
chmod 0644 /etc/apt/keyrings/agnocast-ppa.gpg
63+
args:
64+
creates: /etc/apt/keyrings/agnocast-ppa.gpg
65+
become: true
66+
67+
- name: Verify GPG key fingerprint
68+
ansible.builtin.shell: |
69+
set -o pipefail
70+
gpg --show-keys /etc/apt/keyrings/agnocast-ppa.gpg | grep -q 'CFDB1950382092423DF37D3E075CD8B5C91E5ACA'
71+
args:
72+
executable: /bin/bash
73+
register: agnocast_gpg_verify
74+
failed_when: agnocast_gpg_verify.rc != 0
75+
changed_when: false
76+
77+
- name: Display GPG key verification success
78+
ansible.builtin.debug:
79+
msg: "GPG key fingerprint verified successfully: CFDB1950382092423DF37D3E075CD8B5C91E5ACA"
80+
81+
- name: Add agnocast repository
82+
ansible.builtin.copy:
83+
dest: /etc/apt/sources.list.d/agnocast.sources
84+
content: |
85+
Types: deb
86+
URIs: http://ppa.launchpad.net/t4-system-software/agnocast/ubuntu
87+
Suites: jammy
88+
Components: main
89+
Signed-By: /etc/apt/keyrings/agnocast-ppa.gpg
90+
mode: "0644"
2691
become: true
2792

2893
- name: Restore original IPv6 settings # noqa: no-changed-when

0 commit comments

Comments
 (0)