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 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 ---

# alpine
- name: "[Alpine] Generate php-fpm listener configs"
  template:
    src: php-fpm-listener.conf.j2
    dest: /etc/php{{ services.php_fpm.version | default(7) }}/php-fpm.d/{{item.key}}.conf
    owner: root
    group: root
    mode: 0644
  loop: "{{ lookup('dict', services.php_fpm.listeners, wantlist=True) }}"
  register: php_fpm_deployed_configs
  notify: "Restart php-fpm"
  when:
    - ansible_distribution == "Alpine"
    - services.php_fpm.listeners is defined

- name: "[Alpine] Collect files in directory: /etc/php{{ services.php_fpm.version | default(7) }}/php-fpm.d"
  find:
    path: "/etc/php{{ services.php_fpm.version | default(7) }}/php-fpm.d"
    hidden: yes
  register: php_fpm_found_files
  check_mode: no
  changed_when: false
  when:
    - ansible_distribution == "Alpine"
    - services.php_fpm.listeners is defined

- name: "[Alpine] Remove unmanaged files in directory: /etc/php{{ services.php_fpm.version | default(7) }}/php-fpm.d"
  file:
    path: "/etc/php{{ services.php_fpm.version | default(7) }}/php-fpm.d/{{ item.path | basename }}"
    state: absent
  with_items:
    - "{{ php_fpm_found_files.files }}"
  notify: "Restart php-fpm"
  when:
    - ansible_distribution == "Alpine"
    - services.php_fpm.listeners is defined
    - (item.path) not in ( php_fpm_deployed_configs | json_query('results[].invocation.module_args.dest') | default([]) )



# archlinux (php7)
- name: "[Archlinux] Generate php7-fpm listener configs"
  template:
    src: php-fpm-listener.conf.j2
    dest: /etc/php7/php-fpm.d/{{item.key}}.conf
    owner: root
    group: root
    mode: 0644
  loop: "{{ lookup('dict', services.php_fpm.listeners, wantlist=True) }}"
  register: php_fpm_deployed_configs
  notify: "Restart php-fpm"
  when:
    - ansible_distribution == "Archlinux"
    - services.php_fpm.version is not defined or services.php_fpm.version == 7
    - services.php_fpm.listeners is defined

- name: "[Archlinux] Collect files in directory: /etc/php7/php-fpm.d"
  find:
    path: "/etc/php7/php-fpm.d"
    hidden: yes
  register: php_fpm_found_files
  check_mode: no
  changed_when: false
  when:
    - ansible_distribution == "Alpine"
    - services.php_fpm.version is not defined or services.php_fpm.version == 7
    - services.php_fpm.listeners is defined

- name: "[Alpine] Remove unmanaged files in directory: /etc/php7/php-fpm.d"
  file:
    path: "/etc/php7/php-fpm.d/{{ item.path | basename }}"
    state: absent
  with_items:
    - "{{ php_fpm_found_files.files }}"
  notify: "Restart php-fpm"
  when:
    - ansible_distribution == "Alpine"
    - services.php_fpm.version is not defined or services.php_fpm.version == 7
    - services.php_fpm.listeners is defined
    - (item.path) not in ( php_fpm_deployed_configs | json_query('results[].invocation.module_args.dest') | default([]) )



# archlinux (php8)
- name: "[Archlinux] Generate php8-fpm listener configs"
  template:
    src: php-fpm-listener.conf.j2
    dest: /etc/php/php-fpm.d/{{item.key}}.conf
    owner: root
    group: root
    mode: 0644
  loop: "{{ lookup('dict', services.php_fpm.listeners, wantlist=True) }}"
  register: php_fpm_deployed_configs
  notify: "Restart php-fpm"
  when:
    - ansible_distribution == "Archlinux"
    - services.php_fpm.version == 8
    - services.php_fpm.listeners is defined

- name: "[Archlinux] Collect files in directory: /etc/php/php-fpm.d"
  find:
    path: "/etc/php/php-fpm.d"
    hidden: yes
  register: php_fpm_found_files
  check_mode: no
  changed_when: false
  when:
    - ansible_distribution == "Archlinux"
    - services.php_fpm.version == 8
    - services.php_fpm.listeners is defined

- name: "[Alpine] Remove unmanaged files in directory: /etc/php/php-fpm.d"
  file:
    path: "/etc/php/php-fpm.d/{{ item.path | basename }}"
    state: absent
  with_items:
    - "{{ php_fpm_found_files.files }}"
  notify: "Restart php-fpm"
  when:
    - ansible_distribution == "Archlinux"
    - services.php_fpm.version == 8
    - services.php_fpm.listeners is defined
    - (item.path) not in ( php_fpm_deployed_configs | json_query('results[].invocation.module_args.dest') | default([]) )