ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

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 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
---

- name: "[Alpine] Fail when Option 'system.alpineVersion' not set"
  fail:
    msg: The option 'system.alpineVersion' has to be set!
  when:
    - ansible_distribution == "Alpine"
    - system.alpineVersion is not defined

- name: "[Alpine] Get signature from personal repo"
  get_url:
    url: https://repo.ctu.cx/alpine/isa-60c52eb0.rsa.pub
    dest: /etc/apk/keys/isa-60c52eb0.rsa.pub
  when:
    - ansible_distribution == "Alpine"
    - system.enableOwnRepos is defined
    - system.enableOwnRepos is true

- name: "[Alpine] Update file: /etc/apk/repositories"
  template:
    src: repositories.j2
    dest: /etc/apk/repositories
  register: apk_repos
  when:
    - ansible_distribution == "Alpine"


- name: "[Archlinux] Install package: patch"
  pacman:
    name: patch
    update_cache: yes
  when:
    - ansible_distribution == "Archlinux"
    - system.enableOwnRepos is defined
    - system.enableOwnRepos is true

- name: "[Archlinux] Patch file: /etc/pacman.conf (add isas aur-repo)"
  ansible.posix.patch:
    src: pacman.conf.patch
    dest: /etc/pacman.conf
  when:
    - ansible_distribution == "Archlinux"
    - system.enableOwnRepos is defined
    - system.enableOwnRepos is true


- name: "[Alpine] Update repos"
  raw: "apk update && apk upgrade"
  when:
    - ansible_distribution == "Alpine"
    - apk_repos.changed

- name: "[Archlinux] Update repos"
  pacman:
    update_cache: yes
  register: pacman_update
  when:
    - ansible_distribution == "Archlinux"

# TODO: make this check work 
#- fail:
#    msg: "[Archlinux] Repos have been updated, please upgrade the system manually and restart the playbook"
#  when:
#    - ansible_distribution == "Archlinux"
#    - pacman_update.changed


- name: "[Alpine] Install common packages"
  apk:
    name: "{{ packages }}"
    update_cache: yes
  when: ansible_distribution == "Alpine"

- name: "[Archlinux] Install common packages"
  pacman:
    name: "{{ packages }}"
    update_cache: yes
  when: ansible_distribution == "Archlinux"


- name: "[Alpine] Install extra packages"
  apk:
    name: "{{ system.extraPackages }}"
    update_cache: yes
  when:
    - ansible_distribution == "Alpine"
    - system.extraPackages is defined

- name: "[Archlinux] Install extra packages"
  pacman:
    name: "{{ system.extraPackages }}"
    update_cache: yes
  when:
    - ansible_distribution == "Archlinux"
    - system.extraPackages is defined