-
Notifications
You must be signed in to change notification settings - Fork 14
/
update-postgres.yml
73 lines (72 loc) · 2.17 KB
/
update-postgres.yml
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
---
- hosts:
- perun_servers
remote_user: root
vars:
tomcat_versions:
jessie: "tomcat7"
stretch: "tomcat8"
buster: "tomcat9"
tomcat_owner: "{{tomcat_owners[ansible_lsb.codename]}}"
tomcat_group: "{{tomcat_owners[ansible_lsb.codename]}}"
tomcatN: "{{tomcat_versions[ansible_lsb.codename]}}"
pre_tasks:
- name: Require Debian
assert:
that:
- ansible_distribution == "Debian"
- ansible_distribution_major_version in ["9","10"]
msg: "Only Debian 9+ is supported"
- name: "get package facts"
package_facts:
manager: "apt"
- name: "find postgresql-11"
when: "'postgresql-11' in ansible_facts.packages"
set_fact:
postgresql_package: "postgresql-11"
- name: "find postgresql-12"
when: "'postgresql-12' in ansible_facts.packages"
set_fact:
postgresql_package: "postgresql-12"
- name: "assert some postgres"
assert:
that: postgresql_package is defined
- debug:
var: postgresql_package
- debug:
var: tomcatN
tasks:
- name: "get service facts"
service_facts:
- name: "get ldapc service status"
set_fact:
ldapc_should_run: "{{ansible_facts.services['perun-ldapc'].state == 'running'}}"
- name: "stop perun-ldapc service"
service:
name: perun-ldapc
state: stopped
- name: "stop tomcat service"
service:
name: "{{ tomcatN }}"
state: stopped
- name: "Unhold package {{ postgresql_package }} from upgrading"
dpkg_selections:
name: "{{ postgresql_package }}"
selection: install
- name: "upgrade {{ postgresql_package }}"
apt:
name: "{{ postgresql_package }}"
state: latest
- name: "Hold package {{ postgresql_package }} from upgrading"
dpkg_selections:
name: "{{ postgresql_package }}"
selection: hold
- name: "start tomcat service"
service:
name: "{{ tomcatN }}"
state: started
- name: "start perun-ldapc"
when: ansible_facts.services['perun-ldapc'] is defined and ldapc_should_run
service:
name: perun-ldapc
state: started