]> git.somenet.org - root/pub/somesible.git/blob - roles/server/docker-compose/dco-service/tasks/main.yml
roles/service/mattermost/defaults
[root/pub/somesible.git] / roles / server / docker-compose / dco-service / tasks / main.yml
1 #####################################
2 ### someone's ansible provisioner ###
3 #####################################
4 # Part of: https://git.somenet.org/root/pub/somesible.git
5 # 2017-2024 by someone <someone@somenet.org>
6 #
7 ---
8 - name: create config dir /etc/docker/compose-{{dco_svc_name}}
9   file:
10     path: "/etc/docker/compose-{{dco_svc_name}}"
11     state: directory
12     mode: 0750
13     owner: "root"
14     group: "root"
15
16
17 # fail here, if wrong dco_svc_name given
18 - name: copy config dirtree for service {{dco_svc_name}}
19   file:
20     path: "/etc/docker/compose-{{dco_svc_name}}/{{item.path}}"
21     state: directory
22     owner: "root"
23     group: "root"
24   with_filetree:
25     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/svc-{{dco_svc_name}}/config/"
26     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/svc-{{dco_svc_name}}/config/"
27     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/svc-{{dco_svc_name}}/config/"
28     - "default/svc-{{dco_svc_name}}/config/"
29   when: item.state == 'directory'
30   notify: restart docker-compose@{{dco_svc_name}}.service
31
32
33 - name: copy config filetree for service {{dco_svc_name}}
34   copy:
35     src:  "{{item.src}}"
36     dest: "/etc/docker/compose-{{dco_svc_name}}/{{item.path}}"
37     owner: "root"
38     group: "root"
39   with_filetree:
40     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/svc-{{dco_svc_name}}/config/"
41     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/svc-{{dco_svc_name}}/config/"
42     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/svc-{{dco_svc_name}}/config/"
43     - "default/svc-default/config/"
44   when: item.state == 'file'
45   notify: restart docker-compose@{{dco_svc_name}}.service
46
47
48 - name: create volume dir for service {{dco_svc_name}}
49   file:
50     path: "/srv/docker-compose/svc-{{dco_svc_name}}"
51     state: directory
52     mode: 0750
53     owner: "root"
54     group: "root"
55
56
57 - name: copy volume dirtree for service {{dco_svc_name}}
58   file:
59     path: "/srv/docker-compose/svc-{{dco_svc_name}}/{{item.path}}"
60     state: directory
61     owner: "root"
62     group: "root"
63   with_filetree:
64     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/svc-{{dco_svc_name}}/volumes/"
65     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/svc-{{dco_svc_name}}/volumes/"
66     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/svc-{{dco_svc_name}}/volumes/"
67     - "default/svc-default/volumes/"
68   when: item.state == 'directory'
69   notify: restart docker-compose@{{dco_svc_name}}.service
70
71
72 - name: copy volume filetree for service {{dco_svc_name}}
73   copy:
74     src:  "{{item.src}}"
75     dest: "/srv/docker-compose/svc-{{dco_svc_name}}/{{item.path}}"
76     owner: "root"
77     group: "root"
78   with_filetree:
79     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/svc-{{dco_svc_name}}/volumes/"
80     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/svc-{{dco_svc_name}}/volumes/"
81     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/svc-{{dco_svc_name}}/volumes/"
82     - "default/svc-default/volumes/"
83   when: item.state == 'file'
84   notify: restart docker-compose@{{dco_svc_name}}.service
85
86
87 - name: enable and start docker-compose@{{dco_svc_name}}.service
88   systemd:
89     name: docker-compose@{{dco_svc_name}}.service
90     daemon_reload: yes
91     enabled: yes
92     state: started
93   when: dco_svc_cron == ''
94
95
96 - name: generate docker-compose-{{dco_svc_name}}.timer
97   template:
98     src: "{{item}}"
99     dest: "/etc/systemd/system/docker-compose-{{dco_svc_name}}.timer"
100     mode: 0644
101     owner: "root"
102     group: "root"
103   with_first_found:
104     - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/docker-compose.timer.j2"
105     - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/docker-compose.timer.j2"
106     - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/docker-compose.timer.j2"
107     - "default/docker-compose.timer.j2"
108   when: dco_svc_cron != ''
109
110
111 - name: enable and start docker-compose-{{dco_svc_name}}.timer
112   systemd:
113     name: docker-compose-{{dco_svc_name}}.timer
114     daemon_reload: yes
115     enabled: yes
116     state: started
117   when: dco_svc_cron != ''