summaryrefslogtreecommitdiff
path: root/roles/apt-repo/blackmagic/tasks/main.yml
blob: e376fe9fc87eeb8e63193785e79da4ce3c4c50c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- name: install repo key
  copy:
    src: repo.gpg
    dest: /etc/apt/keyrings/spreadspace.gpg
  register: apt_repo_blackmagic_key

## TODO: remove once all servers have been converted
- name: remove repository key from old locations
  loop:
  - /etc/apt/trusted.gpg.d/blackmagic.gpg
  - /etc/apt/keyrings/blackmagic.gpg
  file:
    path: "{{ item }}"
    state: absent


- name: configure repo authentication
  when:
    - ansible_distribution == "Debian"
    - (ansible_distribution_release | debian_release_compare('<', 'buster'))
  lineinfile:
    path: /etc/apt/auth.conf
    regexp: "^machine build.spreadspace.org "
    line: "machine build.spreadspace.org login {{ apt_repo_blackmagic_auth.username }} password {{ apt_repo_blackmagic_auth.password }}"
    create: yes
    mode: 0600
  register: apt_repo_blackmagic_authconf_legacy

- name: configure repo authentication
  when: (ansible_distribution == "Ubuntu") or
        (ansible_distribution == "Debian" and (ansible_distribution_release | debian_release_compare('>=', 'buster')))
  block:
  - name: remove old repo authentication
    lineinfile:
      path: /etc/apt/auth.conf
      regexp: "^machine build.spreadspace.org "
      state: absent
    register: apt_repo_blackmagic_authconf_legacy_remove

  - name: configure repo authentication
    copy:
      content: |
        machine build.spreadspace.org
        login {{ apt_repo_blackmagic_auth.username }}
        password {{ apt_repo_blackmagic_auth.password }}
      dest: /etc/apt/auth.conf.d/blackmagic.conf
      mode: 0600
    register: apt_repo_blackmagic_authconf


- name: add repository entry
  copy:
    content: |
      deb [signed-by=/etc/apt/keyrings/spreadspace.gpg] https://build.spreadspace.org/ {{ ansible_distribution_release }} blackmagic
    dest: /etc/apt/sources.list.d/blackmagic.list
  register: apt_repo_blackmagic_sources

- name: update apt cache
  when: apt_repo_blackmagic_key is changed or
        apt_repo_blackmagic_authconf_legacy is changed or
        apt_repo_blackmagic_authconf_legacy_remove is changed or
        apt_repo_blackmagic_authconf is changed or
        apt_repo_blackmagic_sources is changed
  command: apt-get update