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 
96 
97 
98 
99 
100 
101 
102 
103 
104 ---

- name: "[OpenRC] Enable and stop service: php{{ services.php_fpm.version | default(7) }}-fpm (to deploy config changes)"
  service:
    name: php{{ services.php_fpm.version | default(7) }}-fpm
    enabled: no
    state: stopped
  when:
    - ansible_service_mgr == "openrc"

- name: "[systemd] Enable and start service: php-fpm7 (to deploy config changes)"
  systemd:
    name: php-fpm7
    enabled: no
    state: stopped
  when:
    - ansible_service_mgr == "systemd"
    - services.php_fpm.version is not defined or services.php_fpm.version == 7

- name: "[systemd] Enable and start service: php-fpm (to deploy config changes)"
  systemd:
    name: php-fpm
    enabled: no
    state: stopped
  when:
    - ansible_service_mgr == "systemd"
    - services.php_fpm.version == 8



- name: "[Alpine] Remove extra PHP{{ services.php_fpm.version | default(7) }} modules" 
  apk:
    name: "php{{ services.php_fpm.version | default(7) }}-{{ item }}"
    state: absent
  loop: "{{ query('list', services.php_fpm.extraModules)[0] }}"
  when:
    - ansible_distribution == "Alpine"

- name: "[Archlinux] Remove extra PHP7 modules" 
  pacman:
    name: "php7-{{ item }}"
    state: absent
  loop: "{{ query('list', services.php_fpm.extraModules)[0] }}"
  when:
    - ansible_distribution == "Archlinux"
    - services.php_fpm.version is not defined or services.php_fpm.version == 7

- name: "[Archlinux] Remove extra PHP8 modules" 
  pacman:
    name: "php-{{ item }}"
    state: absent
  loop: "{{ query('list', services.php_fpm.extraModules)[0] }}"
  when:
    - ansible_distribution == "Archlinux"
    - services.php_fpm.version == 8



- name: "[Alpine] Remove package: php7 php7-fpm" 
  apk:
    name: "php7 php7-fpm"
    state: ansent
  when:
    - ansible_distribution == "Alpine"
    - services.php_fpm.version is not defined or services.php_fpm.version == 7

- name: "[Alpine] Remove package: php8 php8-fpm" 
  apk:
    name: "php8 php8-fpm"
    state: ansent
  when:
    - ansible_distribution == "Alpine"
    - services.php_fpm.version == 8

- name: "[Archlinux] Remove package: php7 php7-fpm" 
  pacman:
    name:
      - "php7"
      - "php7-fpm"
    state: absent
  when:
    - ansible_distribution == "Archlinux"
    - services.php_fpm.version is not defined or services.php_fpm.version == 7

- name: "[Archlinux] Remove package: php php-fpm" 
  pacman:
    name:
      - "php"
      - "php-fpm"
    state: absent
  when:
    - ansible_distribution == "Archlinux"
    - services.php_fpm.version == 8



- name: "Delete leftovers"
  file:
    path: "{{ item }}"
    state: absent
  with_items:
    - /etc/php
    - /etc/php7
    - /etc/php8