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 
---

- name: "Copy homeserver-config to: /etc/synapse/homeserver.yaml"
  copy:
    content: "#\n# !!! This file is managed by Ansible !!!\n#\n\n{{ services.synapse.homeserverConfig | to_nice_yaml }}\nlog_config: '/etc/synapse/log.yaml'\n"
    dest: "/etc/synapse/homeserver.yaml"
    mode: 0655
    owner: synapse
    group: synapse
  notify: "Restart synapse"

- name: "Copy log-config to: /etc/synapse/log.yaml"
  copy:
    content: "#\n# !!! This file is managed by Ansible !!!\n#\n\n{{ services.synapse.logConfig | to_nice_yaml }}"
    dest: "/etc/synapse/log.yaml"
    mode: 0655
    owner: synapse
    group: synapse
  notify: "Restart synapse"

- name: "[Alpine] Copy web-config to: /etc/riot-web/config.json"
  copy:
    src: "{{ services.synapse.webClient.configFile }}"
    dest: "/etc/riot-web/config.json"
    mode: 0644
  when:
    - system.enableOwnRepos is false
    - ansible_distribution == "Alpine"
    - services.synapse.webClient.enable is defined
    - services.synapse.webClient.enable is true

- name: "[Alpine] Copy web-config to: /etc/schildichat-web/config.json"
  copy:
    src: "{{ services.synapse.webClient.configFile }}"
    dest: "/etc/schildichat-web/config.json"
    mode: 0644
  when:
    - system.enableOwnRepos is true
    - ansible_distribution == "Alpine"
    - services.synapse.webClient.enable is defined
    - services.synapse.webClient.enable is true

- name: "[Archlinux] Copy web-config to: /etc/webapps/element/config.json"
  copy:
    src: "{{ services.synapse.webClientConfig }}"
    dest: "/etc/webapps/element/config.json"
    mode: 0644
  when:
    - ansible_distribution == "Archlinux" 
    - services.synapse.webClient.enable is defined
    - services.synapse.webClient.enable is true

- name: "[Alpine] Create directory: /var/log/synapse"
  file: 
    path: "/var/log/synapse"
    state: directory
    mode: 0755
    owner: synapse
    group: synapse
  when:
    - ansible_distribution == "Alpine" 

- name: Create PostgreSQL-database for Synapse
  become: yes
  become_user: postgres
  community.postgresql.postgresql_db:
    name: synapse
    encoding: UTF-8
    lc_collate: C
    lc_ctype: C
    template: template0
  when:
    services.synapse.setupPostgreSQL is true

- name: Create PostgreSQL-user for Synapse
  become: yes
  become_user: postgres
  community.postgresql.postgresql_user:
    db: synapse
    name: synapse
  when:
    services.synapse.setupPostgreSQL is true

- name: Grant all privileges
  become: yes
  become_user: postgres
  community.postgresql.postgresql_privs:
    db: synapse
    privs: ALL
    type: database
    role: synapse
  when:
    services.synapse.setupPostgreSQL is true